summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/twoup/twoup.sty
blob: f23fb3897a537712233d5b434a659116dfc5c912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
%%
%% This is file `twoup.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% twoup.dtx  (with options: `package')
%% 
%%  m This is the twoup package
%%  o Copyright 2005-07 by Mogens Lemvig Hansen,
%%  g Please find my e-mail address in the left margin
%%  e
%%  n Run twoup.dtx through LaTeX and read the documentation in twoup.dvi
%%  s
%%  @ This work may be distributed and/or modified under the
%%  k conditions of the LaTeX Project Public License, either version 1.3
%%  a of this license or (at your option) any later version.
%%  y The latest version of this license is in
%%  j   http://www.latex-project.org/lppl.txt
%%  u and version 1.3 or later is part of all distributions of LaTeX
%%  . version 2005/12/01 or later.
%%  c
%%  o This work has the LPPL maintenance status 'maintained'.
%%  m
%%    The Current Maintainer of this work is Mogens Lemvig Hansen.
%% 
%%    This work consists of the files twoup.dtx and twoup.ins
%%    and the derived file twoup.sty.
%% 
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{twoup}[2007/02/26 version 1.3]
\DeclareOption{noheadfoot}{%
   \setlength{\headheight}{0pt}%
   \setlength{\headsep}{0pt}%
   \setlength{\footskip}{0pt}%
   \let\ps@plain\ps@empty
   \pagestyle{empty}}
\DeclareOption{nofoot}{%
   \setlength{\footskip}{0pt}%
   \let\ps@plain\ps@empty
   \pagestyle{headings}}
\DeclareOption{nohead}{%
   \setlength{\headheight}{0pt}%
   \setlength{\headsep}{0pt}%
   \pagestyle{plain}}
\DeclareOption{letterpaper}{%
   \def\TwoUp@info{-pletter -W5.5in -H8.5in}%
   \def\TwoUp@paper{letter}}%
\DeclareOption{legalpaper}{%
   \def\TwoUp@info{-plegal -W7in -H8.5in}%
   \def\TwoUp@paper{legal}}%
\DeclareOption{executivepaper}{%
   \def\TwoUp@info{-pexecutive -W5.25in -H7.25in}%
   \def\TwoUp@paper{executive}}%
\DeclareOption{a4paper}{%
   \def\TwoUp@info{-pa4 -Pa5}%
   \def\TwoUp@paper{a4}}%
\DeclareOption{a5paper}{%
   \def\TwoUp@info{-pa5 -W105mm -H148mm}%
   \def\TwoUp@paper{a5}}%
\DeclareOption{b5paper}{%
   \def\TwoUp@info{-pb5 -W125mm -H176mm}%
   \def\TwoUp@paper{b5}}%
\DeclareOption{dvips}{%
   \def\TwoUp@special{%
      \special{papersize=\the\paperwidth,\the\paperheight}}}
\DeclareOption{nospecial}{%
   \def\TwoUp@special{\relax}}
\ExecuteOptions{dvips}
\ProcessOptions
\ifx\TwoUp@info\undefined
   \setlength{\@tempdima}{8.5in}
   \ifdim\paperwidth=\@tempdima
      \setlength{\@tempdima}{11in}
      \ifdim\paperheight=\@tempdima
         \def\TwoUp@info{-pletter -W5.5in -H8.5in}
      \fi
      \setlength{\@tempdima}{14in}
      \ifdim\paperheight=\@tempdima
         \def\TwoUp@info{-plegal -W7in -H8.5in}
      \fi
   \fi
   \setlength{\@tempdima}{210mm}
   \ifdim\paperwidth=\@tempdima
      \setlength{\@tempdima}{297mm}
      \ifdim\paperheight=\@tempdima
         \def\TwoUp@info{-pa4 -Pa5}
      \fi
   \fi
\fi
\ifx\TwoUp@info\undefined
   \PackageWarningNoLine{twoup}{Unknown paper size.
      You may want to use a \MessageBreak
      paper size option like letterpaper}
   \setlength{\@tempdima}{0.99627\paperwidth}
   \@settopoint\@tempdima
   \edef\TwoUp@info{-w\the\@tempdima}
   \setlength{\@tempdima}{0.99627\paperheight}
   \@settopoint\@tempdima
   \edef\TwoUp@info{\TwoUp@info\space -h\the\@tempdima}
   \setlength{\@tempdima}{0.5\paperheight}
   \setlength{\@tempdima}{0.99627\@tempdima}
   \@settopoint\@tempdima
   \edef\TwoUp@info{\TwoUp@info\space -W\the\@tempdima}
   \setlength{\@tempdima}{0.99627\paperwidth}
   \@settopoint\@tempdima
   \edef\TwoUp@info{\TwoUp@info\space -H\the\@tempdima}
\fi
\setlength{\@tempdima}{\paperwidth}
\setlength{\paperwidth}{0.5\paperheight}
\setlength{\paperheight}{\@tempdima}
\@ifpackageloaded{2up}{%
   \source{\magstep0}{\paperwidth}{\paperheight}%
   \target{\magstep0}{2\paperwidth}{\paperheight}%
}{%
\@ifpackageloaded{booklet}{%
   \source{\magstep0}{\paperwidth}{\paperheight}%
   \target{\magstep0}{2\paperwidth}{\paperheight}%
}{%
   \TwoUp@special
   \AtEndDocument{\typeout{^^J%
      Package twoup Info: Use psnup with these options:^^J%
      psnup \TwoUp@info\space -2 \jobname.ps twoup.ps^^J}}
   \ifx\TwoUp@paper\undefined\else
      \AtEndDocument{\typeout{^^J%
         Package twoup Info: You may have to add these
         three lines to your .ps file:^^J%
         \@percentchar\@percentchar BeginPaperSize: \TwoUp@paper^^J%
         \TwoUp@paper^^J%
         \@percentchar\@percentchar EndPaperSize^^J}}
   \fi%
}}%
\setlength{\@tempdima}{1in}
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-\@tempdima}
\if@twoside
   \setlength{\evensidemargin}{0.33\@tempdima}
   \setlength{\oddsidemargin}{\@tempdima}
   \addtolength{\oddsidemargin}{-\evensidemargin}
\else
   \setlength{\oddsidemargin}{0.5\@tempdima}
   \setlength{\evensidemargin}{\oddsidemargin}
\fi
\addtolength{\oddsidemargin}{-1in}
\addtolength{\evensidemargin}{-1in}
\setlength{\topmargin}{0.5in}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-2\topmargin}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}
\addtolength{\textheight}{-\topskip}
\divide\textheight\baselineskip
\@tempcnta\textheight
\setlength{\textheight}{\@tempcnta\baselineskip}
\addtolength{\textheight}{\topskip}
\addtolength{\topmargin}{-1in}
\newcommand{\cleartolastpage}{%
   \clearpage
   \@ifstar
      {\def\TwoUp@blankpagestyle{\thispagestyle{empty}}\cleartolastp@ge}
      {\let\TwoUp@blankpagestyle\relax\cleartolastp@ge}}
\if@twoside
   \newcommand{\cleartolastp@ge}[1][4]{%
      \@tempcnta#1\relax
      \cleartol@stp@ge}%
\else
   \newcommand{\cleartolastp@ge}[1][2]{%
      \@tempcnta#1\relax
      \cleartol@stp@ge}%
\fi
\newcommand{\cleartol@stp@ge}[1][0]{%
   \@tempcntb\c@page
   \divide\@tempcntb\@tempcnta
   \multiply\@tempcntb\@tempcnta
   \advance\@tempcntb#1\relax
   \ifnum\@tempcntb<\c@page
      \advance\@tempcntb\@tempcnta
   \fi
   \loop\ifnum\c@page<\@tempcntb
      \hbox{}\TwoUp@blankpagestyle\newpage
   \repeat
}
\endinput
%%
%% End of file `twoup.sty'.