Debian Codegraph @

texmf-dist/source/latex/booklet/booklet.dtx

raw
1 % \iffalse meta-comment
2 % booklet.dtx
3 % Author: Peter Wilson (Herries Press)
4 % Maintainer: Will Robertson (will dot robertson at latex-project dot org)
5 % Copyright 2000--2005 Peter R. Wilson
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either
9 % version 1.3c of this license or (at your option) any
10 % later version: <http://www.latex-project.org/lppl.txt>
11 %
12 % This work has the LPPL maintenance status "maintained".
13 % The Current Maintainer of this work is Will Robertson.
14 %
15 % This work consists of the files listed in the README file.
16 %
17 %
18 %<*driver>
19 \documentclass[twoside]{ltxdoc}
20 \usepackage{url}
21 \usepackage[draft=false,
22 plainpages=false,
23 pdfpagelabels,
24 bookmarksnumbered,
25 hyperindex=false
26 ]{hyperref}
27 \providecommand{\phantomsection}{}
28 \makeatletter
29 \@mparswitchfalse
30 \makeatother
31 \EnableCrossrefs
32 \CodelineIndex
33 %%\OnlyDescription
34 \renewcommand{\MakeUppercase}[1]{#1}
35 \pagestyle{headings}
36 \setcounter{StandardModuleDepth}{1}
37 \begin{document}
38 \DocInput{booklet.dtx}
39 \end{document}
40 %</driver>
41 %
42 % \fi
43 %
44 % \CheckSum{629}
45 %
46 % \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
47 % \DoNotIndex{\@centercr,\@cite}
48 % \DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue}
49 % \DoNotIndex{\@input,\@ixpt,\@m}
50 % \DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
51 % \DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
52 % \DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
53 % \DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
54 % \DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
55 % \DoNotIndex{\advance,\Alph,\alph}
56 % \DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
57 % \DoNotIndex{\bullet}
58 % \DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
59 % \DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
60 % \DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
61 % \DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup}
62 % \DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
63 % \DoNotIndex{\fbox}
64 % \DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
65 % \DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule}
66 % \DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
67 % \DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
68 % \DoNotIndex{\input}
69 % \DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark}
70 % \DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright}
71 % \DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
72 % \DoNotIndex{\NeedsTeXFormat,\newdimen}
73 % \DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
74 % \DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
75 % \DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip}
76 % \DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
77 % \DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright}
78 % \DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
79 % \DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman}
80 % \DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
81 % \DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
82 % \DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
83 % \DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
84 % \DoNotIndex{\viipt,\vipt,\vskip,\vspace}
85 % \DoNotIndex{\wd,\xiipt,\year,\z@}
86 %
87 % \changes{v0.5}{2001/08/11}{First public release}
88 % \changes{v0.6}{2001/08/26}{Reduced use of boxes}
89 % \changes{v0.6a}{2002/10/05}{Improved documentation, no technical changes}
90 % \changes{v0.6b}{2004/04/16}{Changed license and contact details}
91 % \changes{v0.7}{2005/03/23}{Improved print setup for memoir}
92 % \changes{v0.7a}{2005/06/01}{Additional documentation}
93 % \changes{v0.7b}{2009/09/02}{New maintainer}
94 %
95 % \def\dtxfile{booklet.dtx}
96 % \def\fileversion{v0.5} \def\filedate{2001/08/11}
97 % \def\fileversion{v0.6} \def\filedate{2001/08/26}
98 % \def\fileversion{v0.6a} \def\filedate{2002/10/05}
99 % \def\fileversion{v0.6b} \def\filedate{2004/04/16}
100 % \def\fileversion{v0.7} \def\filedate{2005/03/23}
101 % \def\fileversion{v0.7a} \def\filedate{2005/06/01}
102 % \def\fileversion{v0.7b} \def\filedate{2009/09/02}
103 % \newcommand*{\Lpack}[1]{\textsf {#1}} ^^A typeset a package
104 % \newcommand*{\Lopt}[1]{\textsf {#1}} ^^A typeset an option
105 % \newcommand*{\file}[1]{\texttt {#1}} ^^A typeset a file
106 % \newcommand*{\Lcount}[1]{\textsl {\small#1}} ^^A typeset a counter
107 % \newcommand*{\pstyle}[1]{\textsl {#1}} ^^A typeset a pagestyle
108 % \newcommand*{\Lenv}[1]{\texttt {#1}} ^^A typeset an environment
109 %
110 % \title{Printing booklets with LaTeX\thanks{This
111 % file (\texttt{\dtxfile}) has version number \fileversion, last revised
112 % \filedate.}}
113 %
114 % \author{%
115 % Author: Peter Wilson, Herries Press\\
116 % Maintainer: Will Robertson\\
117 % \texttt{will dot robertson at latex-project dot org}
118 % }
119 % \date{\filedate}
120 % \maketitle
121 % \begin{abstract}
122 % The \Lpack{booklet} package provides some aid in printing
123 % simple booklets or signatures for longer books.
124 %
125 % \end{abstract}
126 % \tableofcontents
127 %
128 %
129 %
130 % \section{Introduction}
131 %
132 % In normal usage the \Lpack{booklet} package subverts LaTeX into
133 % putting pairs of pages onto a single page. For example, the contents
134 % of pairs of A4
135 % portrait pages can be rotated and printed as two A5 portrait
136 % pages side by side on an A4 landscape page.
137 %
138 % In 1993 Timothy Van Zandt wrote the \Lpack{2up} generic macros
139 % for printing more than one page on a physical sheet~\cite{2UP};
140 % his original code and documentation is in appendices~\ref{sec:2upcode}
141 % and~\ref{sec:2updoc}.
142 % The \Lpack{booklet}
143 % package is a poorman's version of some of the \Lpack{2up} macros
144 % specifically for (pdf)LaTeX.
145 %
146 % The \Lpack{2up} and \Lpack{booklet} packages cannot be used
147 % simultaneously in one document.
148 %
149 % This manual is typeset according to the conventions of the
150 % \LaTeX{} \textsc{docstrip} utility which enables the automatic
151 % extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
152 %
153 % Section~\ref{sec:usc} describes the usage of the \Lpack{booklet}
154 % package and
155 % commented source code is in Section~\ref{sec:code}. Timothy Van Zandt's
156 % original macros and documentation are supplied in the appendices.
157 %
158 %
159 %
160 % \section{The \Lpack{booklet} package} \label{sec:usc}
161 %
162 % The code provided by the \Lpack{booklet} package is meant to help
163 % with some aspects of booklet printing.
164 %
165 % Basically, the pages of documents processed with the \Lpack{booklet}
166 % package will be reordered and scaled so that they can be printed as
167 % four pages per physical sheet of paper, two pages per side of the
168 % sheet. The default expectation is that the original document is in
169 % a portrait orientation and the pages are printed rotated onto a landscape
170 % sheet. Folding the sheet in half will produce a half-sized document, again
171 % with portrait orientation.
172 %
173 % Professionally printed books have many pages printed per sheet of (large)
174 % paper, which is then folded and cut where necessary to produce a
175 % \emph{signature} of several smaller sheets. Folding a sheet in
176 % half produces a one sheet \emph{folio} signature with four pages.
177 % Folding it in half again and cutting
178 % along the original fold gives a two sheet \emph{quarto} signature
179 % with eight pages. Folding in half again,
180 % results in a four sheet \emph{octavo} signature with 16 pages, and so on
181 % through \emph{16mo}, \emph{32mo}, to \emph{64mo} with six folds and 128 pages.
182 % \emph{Octavo} is the most popular of these.
183 %
184 % Other folds can produce other signatures. For example a \emph{sexto},
185 % obtained by folding in half and then folding in thirds, is a three sheet
186 % signature with 12 pages.
187 %
188 % The main differences between the \Lpack{2up} macros and the
189 % \Lpack{booklet} package are:
190 % \begin{itemize}
191 % \item \Lpack{2up} is generic but \Lpack{booklet} can only be used
192 % with (pdf)LaTeX.
193 % \item \Lpack{2up} can be used for more than booklets
194 % \item \Lpack{booklet} adds the notion of signatures and reduces the need for |\box|es.
195 % \item \Lpack{booklet} adds means of automatically controlling
196 % portrait/landscape printing.
197 % \end{itemize}
198 %
199 % \subsection{Options}
200 %
201 % When the \Lopt{noprint} option is used the package is essentially vacuous.
202 % That is, it behaves as though it had not been used at all, with the
203 % exception that LaTeX will not hiccup at any of the package commands that
204 % may be used in the document; these commands will also do nothing.
205 %
206 % The \Lopt{print} option must be used if you want the package to work
207 % as advertised. The reasons for the \Lopt{print} and \Lopt{noprint}
208 % options are explained later in Section~\ref{sec:usage}.
209 %
210 % The \Lpack{booklet} package can also take one option from each of
211 % two groups.
212 %
213 % The first group of options specifies how many pages there should be
214 % to a hypothetical signature. The options are: \Lopt{four}, \Lopt{eight},
215 % \Lopt{sixteen}, and \Lopt{thirtytwo}. TeX has to hold all the pages
216 % for a signature before it outputs any of them, and TeX is memory limited.
217 %
218 % If you have a duplex printer you can print out the document double-sided
219 % and then just fold the sheets forming each signature ready for binding.
220 % If you don't have a duplex printer, then the sheets can be photocopied
221 % (1-to-2 sided) ready for folding.
222 %
223 % The second group of options are for selecting one of the package's
224 % predefined layouts. These options include:
225 % \begin{itemize}
226 % \item[\Lopt{twouparticle}] --- for portrait pages with wide margins
227 % (similar to those in the standard LaTeX \Lpack{article}, \Lpack{book}
228 % and \Lpack{report} classes)
229 % and no marginal notes, to go on landscape sheets.
230 % \item[\Lopt{largetypeblock}] --- for portrait pages with a larger
231 % (wider and/or longer) typeblock
232 % and/or marginal notes, to go on landscape sheets.
233 % \item[\Lopt{1to1}] --- for portrait pages where the original is
234 % designed to fit on half-sized paper, to go on landscape sheets.
235 % \item[\Lopt{landscape}] --- for landscape pages to go onto
236 % portrait sheets. Pairs of original landscape pages will be
237 % printed at the top and bottom of a portrait page.
238 % This option is called automatically if the
239 % \Lopt{landscape} option is used for the document class.
240 %
241 % \end{itemize}
242 %
243 % The default options are \Lopt{noprint}, \Lopt{twouparticle} and
244 % \Lopt{thirtytwo}.
245 %
246 % \subsection{Commands}
247 %
248 % The \emph{source} is the document as it would
249 % be normally typeset by LaTeX (i.e., without using the \Lpack{booklet}
250 % package).
251 %
252 % The \emph{target} is the desired document as it should
253 % be printed
254 % using the \Lpack{booklet} package.
255 %
256 % \DescribeMacro{\source}
257 % The command |\source{|\meta{mag}|}{|\meta{width}|}{|\meta{height}|}|
258 % specifies the source sheets, where
259 % \meta{width} and \meta{height} are the width and height for the
260 % pages of the orginal document (the document that LaTeX would process
261 % without the \Lpack{booklet} package). The \meta{mag} argument is the
262 % magnification factor.
263 %
264 % The default definition of |\source| is: \\
265 % |\source{\magstep0}{\paperwidth}{\paperheight}| \\
266 % which corresponds to a full size default page.
267 %
268 % \DescribeMacro{\target}
269 % The command |\target{|\meta{mag}|}{|\meta{width}|}{|\meta{height}|}|
270 % specifies the target sheets, where
271 % \meta{width} and \meta{height} are the width and height for the
272 % sheets that will be used for printing with the package. For
273 % example, |\target{...}{11in}{8.5in}| would be typical for a
274 % (portrait letterpaper)
275 % source being put onto a (landscape) letterpaper target.
276 %
277 % \DescribeMacro{\magstepN}
278 % \DescribeMacro{\magstepminusN}
279 % The package puts two pages onto a single sheet. It often happens that
280 % in order to do this the natural size of the text pages has to be changed,
281 % via the \meta{mag} argument noted above. The macro |\magstepminusN|,
282 % where $0 \leq N \leq 5$ is a shrinkage factor; similary, |\magstepN|
283 % specifies a magnification factor. For example, the default |\target|
284 % is specified as: \\
285 % |\target{\magstepminus1}{\paperheight}{\paperwidth}| \\
286 % whereas the target for the \Lopt{largetypeblock} option is: \\
287 % |\target{\magstepminus2}{\paperheight}{\paperwidth}| \\
288 % which shrinks the original pages more than the default |\target| does.
289 %
290 % The \Lpack{booklet} package uses the |\source| and |\target|
291 % specifications to decide on how to scale and position the orginal
292 % full size source pages onto half of a target sheet.
293 %
294 % Normally there is no need to change the default |\source| but it
295 % may be useful sometimes to change the |\target|. For example, if the
296 % text on source letterpages is very wide it could be useful to print
297 % on legal paper instead. In this case |\target| can be defined as: \\
298 % |\target{\magstepminus2}{14in}{8.5in}|
299 %
300 % \DescribeMacro{\pagespersignature}
301 % If none of the signature options are suitable, then
302 % |\pagespersignature{|\meta{num}|}| may be used to specify \meta{num}
303 % pages per signature. For example, if you wanted a \emph{sexto} signature
304 % then use |\pagespersignature{12}|.
305 %
306 % \DescribeMacro{\ifprintoption}
307 % The command |\ifprintoption| is set TRUE if the \Lopt{print} option
308 % is used otherwise it is set FALSE.
309 %
310 % \DescribeMacro{\setdvipstargetpages}
311 % If you are using LaTeX to generate a \file{.dvi} file the
312 % |\setdvipstargetpages| macro sets up the correct target page sizes
313 % in the \file{.dvi} file assuming that subsequent processing will be
314 % via a program that understands \file{dvips} \cs{special} commands.
315 %
316 % \DescribeMacro{\setpdftargetpages}
317 % If you are using pdfLaTeX to generate a \file{.pdf} file the
318 % |\setpdftargetpages| macro sets up the correct target page sizes for
319 % pdfLaTeX.
320 %
321 % \DescribeMacro{\pagesepwidth}
322 % \DescribeMacro{\pageseplength}
323 % \DescribeMacro{\pagesepoffset}
324 % A line may be drawn between the output text pages. The length of
325 % the line is |\pageseplength| (default 6.5in), and line starts a
326 % distance |\pagesepoffset| from the bottom (side) of the printed sheet
327 % (default 1in). The line thickness is specified by the length
328 % |\pagesepwidth|, which is initially defined to be 0pt (i.e., the
329 % line is normally invisible). To see a dividing line use |\setlength|
330 % to change the value of |\pagesepwidth|; in LaTeX ruled lines normally
331 % have a thickness of 0.4pt.
332 %
333 % \DescribeMacro{\twoupclearpage}
334 % \DescribeMacro{\twoupemptypage}
335 % The command |\twoupclearpage| outputs the current target page (like
336 % LaTeX's |\newpage|). The command |\twoupemptypage| inserts a completely
337 % empty page into the target.
338 %
339 % \DescribeMacro{\ifuselandscape}
340 % \DescribeMacro{\ifprintoption}
341 % The command |\ifuselandscape| is set TRUE if the \Lopt{landscape} option
342 % is used otherwise it is set FALSE.
343 %
344 % \DescribeMacro{\checkforlandscape}
345 % The macro |\checkforlandscape| evaluates the value of |\ifprintoption|
346 % and the current value of |\ifuselandscape| and sets |\ifuselandscape|
347 % to TRUE if the document
348 % requires landscape printing (when either both the \Lopt{landscape} and
349 % \Lopt{noprint} options are used, or when just the \Lopt{print}
350 % option is called for),
351 % or to FALSE if the document should be printed in the normal portrait
352 % orientation (when either both the \Lopt{landscape} and \Lopt{print}
353 % options are used, or when just the \Lopt{noprint} option is used without
354 % \Lopt{landscape}).
355 %
356 % Note that as |\checkforlandscape| may change the value of
357 % |\ifuselandscape|, the command is only guaranteed when |\ifuselandscape|
358 % accurately indicates the presence or absence of the \Lopt{landscape}
359 % option.
360 %
361 % In version 0.7 of the package the macro \cs{setdvipstargetpages} was
362 % introduced and the macro \cs{setpdftargetpages} was modified with the
363 % result that \cs{checkforlandscape} was effectively
364 % no longer needed. It is left to maintain upward compatibilty for
365 % older documents.
366 %
367 %
368 % \subsection{Usage} \label{sec:usage}
369 %
370 % You use the \Lpack{booklet} package just like any other package: \\
371 % |\usepackage[<options>]{booklet}| \\
372 % but some other things need taking care of as well.
373 %
374 % If you are making any changes to the values of |\paperwidth| or
375 % |\paperheight|, say through the \Lpack{geometry} package or the
376 % \Lpack{memoir} class, then the \Lpack{booklet} package must be called
377 % \emph{after} those changes have been made. In this case you may have
378 % to specify a different |\source| than usual, but I think that this
379 % is probably unlikely.
380 %
381 %
382 % \DescribeMacro{\special}
383 % Under normal circumstances printing should be done onto landscape
384 % oriented paper instead of the usual portrait orientation. If you are
385 % using the \file{dvips} program for transformation from the \file{.dvi}
386 % to a \file{.ps} file, then you can use the command |\special{landscape}|
387 % in the preamble so that the output is organised for landscape. Other
388 % drivers may support similar commands, or command line options for
389 % accomplishing this.
390 %
391 % For example, it may happen that if you use \file{ghostview} (or
392 % \file{gsview}) to look at \file{dvips} PostScript output of the final
393 % printing that the text appears upside down. Putting: \\
394 % \verb?\special{!TeXDict begin /landplus90{true}store end}? \\
395 % just before the \verb?\begin{document}? may cure this.
396 %
397 % I use a LaserJet printer with a duplex printing capability (i.e.,
398 % printing can be done on both sides of a sheet in one pass). When
399 % printing in duplex mode I also found that it was very convenient
400 % to change the binding from the long to the short side of the paper;
401 % the sheets were then all set for folding. Using \file{dvips} and
402 % the 5SiMx LaserJet I found that the following commands in the
403 % preamble let me change the printer settings from the document.
404 % \begin{verbatim}
405 % \special{!TeXDict begin <</Duplex true>> setpagedevice end} % duplex
406 % \special{!TeXDict begin <</Tumble true>> setpagedevice end} % short binding
407 % \end{verbatim}
408 % How these would fare with another printer or program, I have no idea.
409 % The CTAN subdirectory \texttt{/dviware/dvipsconfig} contains a
410 % set of files for performing the above operations, and more,
411 % as command line options for \file{dvips}.
412 %
413 % If you can only do simplex printing (one side only), then when
414 % photocopying from one-sided to two-sided, alternate printed pages
415 % need to be rotated 180 degrees before being fed into the copier.
416 %
417 % The following physical analogy of how the package works with
418 % portrait pages may help in achieving results that you want.
419 %
420 % \begin{itemize}
421 % \item Write the original text on portrait oriented transparent
422 % material (e.g., viewfoils) which is the same size as that
423 % specified by the |\source| macro. Mark the centre --- the
424 % point where the diagonals intersect --- of each original page.
425 %
426 % \item Take a sheet of paper the same size as that specified by
427 % the |\target| macro and in landscape orientation. Mentally
428 % divide this in half by a vertical line and then mark the centre
429 % points of the two (left and right) halves.
430 % \item Take an even numbered original sheet, portrait orientaion,
431 % and place it on top of the landscape oriented target sheet
432 % with its centre point coincident with the left half centre
433 % point. Do the same with an odd numbered original sheet except
434 % that its centre is coincident with the right half centre point.
435 % \item Take the assembly to a photocopier and make a copy onto a target
436 % sized sheet. This is the final result.
437 % \end{itemize}
438 % The analogy for landscape originals is similar with the obvious changes
439 % in the orientations.
440 %
441 % Not that the analogy does not include any scaling. If the size of
442 % the target is relatively small then the texts on the original sheets
443 % may overlap or extend outside the physical target sheet. If the target
444 % is relatively large then there may be too much white space around the
445 % texts. The \meta{mag} arguments to the |\source| and |\target| macros
446 % are provided to adjust the source/target text sizes. Scaling does
447 % not affect the positions of the texts.
448 %
449 % If you are planning to produce a booklet in the first place, then
450 % design the initial page layout as though it would be printed on half-sized
451 % paper. This will produce a better end result as no scaling will
452 % be necessary. The \Lopt{1to1} option is provided for just this case.
453 %
454 % If the original pages look too crowded after printing, you can specify
455 % another |\target| with a larger shrink factor (e.g., |\magstepminus3|
456 % instead of |\magstepminus2|). Conversely, too much white space can be
457 % countered by decreasing the shrink factor (e.g., |\magstepminus1|
458 % instead of |\magstepminus2|).
459 %
460 % The following are the default settings of |\source| and |\target| (the
461 % source and target sheets are the same size) for the different layout
462 % options.
463 % \begin{itemize}
464 % \item[\Lopt{twouparticle:}] \mbox{} \\
465 % |\source{\magstep0}{\paperwidth}{\paperheight}| \\
466 % |\target{\magstepminus1}{\paperheight}{\paperwidth}| \\
467 % \item[\Lopt{largetypeblock:}] \mbox{} \\
468 % |\source{\magstep0}{\paperwidth}{\paperheight}| \\
469 % |\target{\magstepminus2}{\paperheight}{\paperwidth}| \\
470 % \item[\Lopt{1to1:}] \mbox{} \\
471 % |\source{\magstep0}{\paperwidth}{\paperheight}| \\
472 % |\target{\magstep0}{\paperheight}{\paperwidth}| \\
473 % \end{itemize}
474 %
475 % If the original is not planned to be produced as a booklet, then
476 % obtaining respectable looking full size and booklet results may
477 % require some trial and error in determining good values for
478 % magnifications and/or target paper sizes. The original page margins
479 % may also need changing for the booklet output.
480 %
481 % LaTeX is not very happy if it is forced to save some pages instead
482 % of outputting each one as it is finished. It shows its displeasure
483 % by messing up any internal references in the document, for example
484 % a Table of Contents or an Index. To counter this, run LaTeX on the
485 % document \emph{without} the \Lopt{print} package option
486 % until all references
487 % have stabilised. Then put the command |\nofiles| in the preamble, use
488 % the \Lopt{print} option,
489 % and run LaTeX a final time before printing.
490 % (The |\nofiles| command stops LaTeX from generating new \file{.aux},
491 % \file{.toc} files, etc., but it will still use any old versions).
492 %
493 % The following gives an indication of how the relevant portion of
494 % a preamble may look.
495 % \begin{verbatim}
496 % % possibly change default \paperwidth and/or \paperheight
497 % % \usepackage[noprint,...]{booklet} % use this
498 % % \usepackage[...]{booklet} % or this for initial runs
499 % % \usepackage[print, ...]{booklet} \nofiles % use this for final run
500 % % perhaps change \target
501 % \ifpdf % from the ifpdf package
502 % \pdfoutput = 1 % generate pdf output
503 % \setpdftargetpages % set output page size
504 % \else
505 % \setdvipstargetpages % use this for dvi output
506 % \fi
507 % ...
508 % \end{verbatim}
509 % It is safer to use the package without the \Lopt{print} option for
510 % the initial runs rather than not using the package at all; doing it
511 % this way will stop LaTeX from complaining if you happened to have
512 % used any of the \Lpack{booklet} commands in the document.
513 %
514 % TeX allocates a new box for each page in the first signature and then these
515 % are reused for each subsequent signature. Large
516 % signatures may use up all available boxes in which case
517 % TeX will tell you. It is much more probable, though, that TeX will
518 % run out of memory before this happens.
519 %
520 % Here is a real example of one booklet setup for typesetting a 68 page
521 % book. I used the \Lpack{memoir}
522 % class but afterwards I'll point out how to do the equivalent with the
523 % \Lpack{book} class.
524 % \begin{verbatim}
525 % \documentclass[letterpaper,11pt]{memoir}
526 % % typeblock size of 5.5+ by 4 inches
527 % \settypeblocksize{5.5in}{4in}{*}
528 % \addtolength{\textheight}{\onelineskip}
529 % \setlrmargins{2in}{*}{*}
530 % \setulmargins{2.25in}{*}{*}
531 % \checkandfixthelayout
532 %
533 % % \usepackage[noprint]{booklet}
534 % \usepackage[print,1to1]{booklet} \nofiles
535 % \pagespersignature{16} % 16 pages per signature
536 %
537 % \ifpdf
538 % \setpdftargetpages
539 % \else
540 % \setdvipstargetpages
541 % \fi
542 % \ifprintoption % tweak dvi output only for final printing
543 % \special{!TeXDict begin /landplus90{true}store end}
544 % \special{!TeXDict begin <</Tumble true>> setpagedevice end}
545 % \fi
546 %
547 % \begin{document}
548 % \pagestyle{empty}
549 % % Want a blank sheet before the title page
550 % \hbox{}\cleardoublepage
551 % % half-title page here
552 % \cleardoublepage
553 %
554 % % title page here
555 % \clearpage
556 %
557 % % copyright page here
558 % \cleardoublepage
559 %
560 % \pagestyle{plain}
561 % \pagenumbering{roman}
562 % \tableofcontents*
563 % \cleardoublepage
564 % \pagenumbering{arabic}
565 % \pagestyle{headings}
566 %
567 % \chapter{First}
568 % % and so on
569 %
570 % % want some blank endpapers to get enough pages into
571 % % the last signature for easy binding
572 % \clearpage
573 % \hbox{}\clearpage\hbox{}\cleardoublepage
574 % \end{document}
575 % \end{verbatim}
576 %
577 % Using the \Lpack{book} class just involves changing how the page layout
578 % is specified:
579 % \begin{verbatim}
580 % \documentclass[letterpaper,11pt]{book}
581 % % typeblock size of 5.5 by 4 inches
582 % \setlength{\textheight}{419pt} \setlength{\textwidth}{289pt}
583 % \setlength{\oddsidemargin}{72pt} \setlength{\evensidemargin}{108pt}
584 % \setlength{\topmargin}{55.9pt} \setlength{\footskip}{27.5pt}
585 % \setlength{\headheight}{14.6pt} \setlength{\headsep}{19.9pt}
586 %
587 % % \usepackage[noprint]{booklet}
588 % ...
589 % \end{verbatim}
590 %
591 % If you try and use a non-zero magnification with a document that
592 % has any `true' lengths, for example the \Lpack{amsbook} class,
593 % TeX itself will complain with an error message
594 % of the form: \\
595 % |!Incompatible magnification (833);| \\
596 % |the previous value will be retained|\\
597 % Try forcing LaTeX to continue and check the output because you might
598 % be lucky and it looks alright.
599 %
600 % \changes{v0.7a}{2005/06/01}{Added Gordo's example}
601 % Here is another example from a posting to \texttt{comp.text.tex} by
602 % Gordo in the thread \textit{booklet problem}, 2005/05/26.
603 % \begin{verbatim}
604 % \documentclass[twoside,10pt]{article}
605 % \setlength{\paperwidth}{5.5in}
606 % \setlength{\paperheight}{8.5in}
607 % \setlength{\topmargin}{-0.3in}
608 % \setlength{\textheight}{6.9in}
609 % \setlength{\oddsidemargin}{0.0in}
610 % \setlength{\evensidemargin}{-0.5in}
611 % \setlength{\textwidth}{4.0in}
612 % \usepackage{makeidx}
613 % %\usepackage[noprint,1to1]{booklet} % initial runs for ToC and index
614 % \usepackage[noprint,1to1]{booklet} \nofiles % final printing run
615 % \source{\magstep0}{5.5in}{8.5in}
616 % \target{\magstep0}{11in}{8.5in}
617 % \setpdftargetpages
618 % \pagespersignature{120}
619 % \makeindex
620 % \begin{document}
621 % \pagenumbering{roman}
622 % \begin{titlepage} ... \end{titlepage} % the title
623 % ...
624 % \newpage
625 % \begin{titlepage} \mbox{} \end{titlepage} % back cover
626 % \end{document}
627 % \end{verbatim}
628 %
629 %
630 % \changes{v0.7a}{2005/06/01}{Added example for bookleting the manual}
631 % As yet another example, you can produce this manual as a booklet. Change
632 % the first part of this file to read:
633 % \begin{verbatim}
634 % \documentclass[twoside]{ltxdoc}
635 % \usepackage{url}
636 % \usepackage{ifpdf}
637 % \addtolength{\evensidemargin}{-0.75in}
638 % % \usepackage[noprint]{booklet} % initial runs
639 % \usepackage[print,largetypeblock]{booklet}\nofiles\pagespersignature{48} % final run
640 % %\usepackage[draft=false,
641 % % plainpages=false,
642 % % pdfpagelabels,
643 % % bookmarksnumbered,
644 % % hyperindex=false
645 % % ]{hyperref}
646 % \ifpdf
647 % \setpdftargetpages
648 % \else
649 % \setdvipstargetpages
650 % \fi
651 % \providecommand{\phantomsection}{}
652 % \makeatletter
653 % \@mparswitchfalse
654 % \makeatother
655 % ...
656 % \end{verbatim}
657 % The \Lpack{hyperref} package interferes with the \cs{setpdftargetpages}
658 % macro so it is commented out. The \Lopt{largetypeblock} option is used
659 % otherwise the marginal notes can fall off the edges of the pages in the
660 % final printing; the \cs{evensidemargin} is also altered for the same reason.
661 % The value for \cs{pagespersignature} is to ensure that
662 % only a single signature is produced (you can decrease this if you are
663 % willing to bind multiple signatures).
664 %
665 %
666 % The original source of the \Lpack{2up} package is included at
667 % the end of this manual. It may provide some more insights into how to
668 % use the \Lpack{booklet} package. Be careful, though, as the two packages
669 % differ in some significant details.
670 %
671 %
672 %
673 % \StopEventually{
674 % \bibliographystyle{alpha}
675 % \begin{thebibliography}{GMS94}
676 % \bibitem[GMS94]{GOOSSENS94}
677 % Michel Goossens, Frank Mittelbach, and Alexander Samarin.
678 % \newblock \emph{The LaTeX Companion}.
679 % \newblock Addison-Wesley Publishing Company, 1994.
680 % \bibitem[Zan93]{2UP}
681 % Timothy Van Zandt.
682 % \newblock \emph{Two-up printing for Generic TeX}.
683 % \newblock January 1993.
684 % \newblock (Available from CTAN in \texttt{macros/generic/2up})
685 % \end{thebibliography}
686 % }
687 %
688 %
689 % \section{The package code} \label{sec:code}
690 %
691 % The package code essentially consists of modifications to the \Lpack{2up}
692 % macros, which are given in section~\ref{sec:2upcode}. I could not
693 % have written the \Lpack{booklet} package without Timothy Van Zandt's
694 % \Lpack{2up} macros.
695 %
696 % As much as possible I have tried to keep to the original
697 % \Lpack{2up} macro names. However, the \Lpack{2up} and \Lpack{booklet}
698 % packages cannot be used in the same document.
699 %
700 % The code is actually in two packages, \file{booklet.sty} which
701 % provides the commands that
702 % the user sees, and \file{bkltprnt.sty} which is used by
703 % \file{booklet.sty} to do all the hard work.
704 %
705 % \subsection{Preliminaries}
706 %
707 % Announce the name and version of the packages, which require
708 % \LaTeXe.
709 % \begin{macrocode}
710 %<*usc>
711 \NeedsTeXFormat{LaTeX2e}
712 \ProvidesPackage{booklet}[2009/09/02 v0.7b booklet printing]
713
714 %</usc>
715 %<*prnt>
716 \NeedsTeXFormat{LaTeX2e}
717 \ProvidesPackage{bkltprnt}[2009/09/02 v0.7b support for booklet printing]
718
719 %</prnt>
720 % \end{macrocode}
721 %
722 % \subsection{The main \Lpack{booklet} code}
723 %
724 % The \Lpack{booklet} package provides the user commands. Then, if
725 % the \Lopt{print} option is used it calls the \Lpack{bkltprnt}
726 % package to do the work.
727 %
728 % \begin{macrocode}
729 %<*usc>
730 % \end{macrocode}
731 %
732 % \begin{macro}{\twoup@end}
733 % For the \Lopt{print} and \Lopt{noprint} options.
734 % \begin{macrocode}
735 \newcommand*{\twoup@end}{\endinput}
736
737 % \end{macrocode}
738 % \end{macro}
739 %
740 % \begin{macro}{\pageseplength}
741 % \begin{macro}{\pagesepwidth}
742 % \begin{macro}{\pagesepoffset}
743 % Lengths for the dividing rule.
744 % \begin{macrocode}
745 \newdimen\pageseplength
746 \newdimen\pagesepwidth
747 \newdimen\pagesepoffset
748
749 % \end{macrocode}
750 % \end{macro}
751 % \end{macro}
752 % \end{macro}
753 %
754 % \begin{macro}{\ifsidebyside}
755 % TRUE if pages are to be placed side-by-side on the sheet. I have changed
756 % the original |\if@sidebyside| to |\ifsidebyside| so that a user can
757 % call it easily. I don't
758 % don't implement the |\if@twosided|.
759 % \begin{macrocode}
760 \newif\ifsidebyside
761 \sidebysidetrue
762
763 % \end{macrocode}
764 % \end{macro}
765 %
766 % \begin{macro}{\ifuselandscape}
767 % \begin{macro}{\ifprintoption}
768 % Booleans for some options and for if the final printing should be landscape.
769 % \begin{macrocode}
770 \newif\ifuselandscape
771 \uselandscapefalse
772 \newif\ifprintoption
773 \printoptionfalse
774
775 % \end{macrocode}
776 % \end{macro}
777 % \end{macro}
778 %
779 % \begin{macro}{\c@signature}
780 % \begin{macro}{\c@sigcount}
781 % Counters for signature handling.
782 % \begin{macrocode}
783 \newcounter{signature}
784 \newcounter{sigcount}
785 \setcounter{sigcount}{0}
786 % \end{macrocode}
787 % \end{macro}
788 % \end{macro}
789 %
790 % \begin{macro}{\pagespersignature}
791 % A user-level command for setting the number of pages wanted
792 % in a signature. I initialise these to 32.
793 % \begin{macrocode}
794 \newcommand*{\pagespersignature}[1]{\setcounter{signature}{#1}}
795 \pagespersignature{32}
796
797 % \end{macrocode}
798 % \end{macro}
799 %
800 %
801 % \begin{macro}{\magstepminus}
802 % A useful extension of the |\magstep| macro.
803 % \begin{macrocode}
804 \def\magstepminus#1{%
805 \ifcase#1 \@m\or 833\or 694\or 579\or 482\or 401\fi\relax}
806
807 % \end{macrocode}
808 % \end{macro}
809 %
810 % \begin{macro}{\target}
811 % \begin{macro}{\source}
812 % \begin{macro}{\setpdftargetpages}
813 % \begin{macro}{\setdvipstargetpages}
814 % Vacuous versions of the user-level macros.
815 % \changes{v0.7}{3005/03/23}{Added \cs{setdvipstargetpages}}
816 % \begin{macrocode}
817 \newcommand*{\target}[3]{}
818 \newcommand*{\source}[3]{}
819 \newcommand*{\setpdftargetpages}{}
820 \newcommand*{\setdvipstargetpages}{}
821
822 % \end{macrocode}
823 % \end{macro}
824 % \end{macro}
825 % \end{macro}
826 % \end{macro}
827 %
828 % \begin{macro}{\targettopbottom}
829 % Vacuous version of the user command.
830 % \begin{macrocode}
831 \newcommand*{\targettopbottom}{}
832
833 % \end{macrocode}
834 % \end{macro}
835 %
836 % \begin{macro}{\twoupemptypage}
837 % \begin{macro}{\twoupclearpage}
838 % vacuous versions of the user commands.
839 % \begin{macrocode}
840 \newcommand*{\twoupemptypage}{}
841 \newcommand*{\twoupclearpage}{}
842
843 % \end{macrocode}
844 % \end{macro}
845 % \end{macro}
846 %
847 % \begin{macro}{\checkforlandscape}
848 % Sets the value of |\ifuselandscape| to
849 % (|\ifuselandscape| XOR |\ifprintoption|).
850 % \begin{macrocode}
851 \newcommand*{\checkforlandscape}{%
852 \ifx\ifuselandscape\ifprintoption
853 \uselandscapefalse\else\uselandscapetrue\fi}
854
855 % \end{macrocode}
856 % \end{macro}
857 %
858 % Now declare the \Lopt{print}, \Lopt{noprint} and \Lopt{landscape}
859 % options,
860 % prepare to pass any other
861 % options to \Lpack{bkltprnt}, and execute the options.
862 % \begin{macrocode}
863 \DeclareOption{print}{\printoptiontrue\def\twoup@end{}}
864 \DeclareOption{noprint}{\printoptionfalse\def\twoup@end{\endinput}}
865 \DeclareOption{landscape}{\uselandscapetrue}
866 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{bkltprnt}}
867 \ProcessOptions\relax
868 \ifuselandscape
869 \PassOptionsToPackage{landscape}{bkltprnt}
870 \fi
871
872 % \end{macrocode}
873 %
874 % Now call |\twoup@end|, which is either |\endinput| or vacuous, after
875 % which the \Lpack{bkltprnt} package is called (if |\twoup@end| was vacuous).
876 % \begin{macrocode}
877 \twoup@end
878
879 \RequirePackage{bkltprnt}
880
881 % \end{macrocode}
882 %
883 %
884 % The end of this package.
885 %
886 % \begin{macrocode}
887 %</usc>
888 % \end{macrocode}
889 %
890 % \subsection{The main \Lpack{bkltprnt} code}
891 %
892 % \begin{macrocode}
893 %<*prnt>
894 % \end{macrocode}
895 %
896 % \begin{macro}{\@targetwidth}
897 % \begin{macro}{\@targetheight}
898 % \begin{macro}{\@sourcewidth}
899 % \begin{macro}{\@sourceheight}
900 % Parameter registers.
901 % \begin{macrocode}
902 \newdimen\@targetwidth
903 \newdimen\@targetheight
904 \newdimen\@sourcewidth
905 \newdimen\@sourceheight
906
907 % \end{macrocode}
908 % \end{macro}
909 % \end{macro}
910 % \end{macro}
911 % \end{macro}
912 %
913 % \begin{macro}{\if@leftpage}
914 % \begin{macro}{\@leftpage}
915 % \begin{macro}{\@rightpage}
916 % \begin{macro}{\@physicalpage}
917 % Registers used by output routine.
918 % \begin{macrocode}
919 \newif\if@leftpage
920 \@leftpagetrue
921 \newbox\@leftpage
922 \newbox\@rightpage
923 \newcount\@physicalpage
924
925 % \end{macrocode}
926 % \end{macro}
927 % \end{macro}
928 % \end{macro}
929 % \end{macro}
930 %
931 %
932 % Since pages are both stored and shipped out half as often:
933 % \begin{macrocode}
934 \multiply\maxdeadcycles by 40\relax
935
936 % \end{macrocode}
937 %
938 % \begin{macro}{\bookletpage}
939 % \begin{macro}{\leftpagenumber}
940 % \begin{macro}{\rightpagenumber}
941 % Registers used only for booklet layout. These are specified directly
942 % as this is the only layout.
943 % \begin{macrocode}
944 \newcount\bookletpage
945 \bookletpage=0
946 \newcount\leftpagenumber
947 \newcount\rightpagenumber
948
949 % \end{macrocode}
950 % \end{macro}
951 % \end{macro}
952 % \end{macro}
953 %
954 % \begin{macro}{\twoupp@geboxes}
955 % I have added this macro so that only the boxes required for a signature
956 % are created. The original \Lpack{2up} code creates a new box for each output page.
957 % \changes{v0.6}{2001/08/26}{Added \cs{twoupp@geboxes}}
958 % \begin{macrocode}
959 \newcommand*{\twoupp@geboxes}{%
960 \advance\bookletpage\@ne
961 \expandafter\newbox\csname bookletbox\the\bookletpage\endcsname
962 \ifnum \bookletpage < \c@signature
963 \twoupp@geboxes
964 \fi}
965 \AtBeginDocument{\twoupp@geboxes\bookletpage=\z@}
966
967 % \end{macrocode}
968 % \end{macro}
969 %
970 %
971 % \begin{macro}{\target}
972 % \begin{macro}{\inv@targetmag}
973 % |\@targetwidth| and |\@targetheight| are set to the \emph{unmagnified}
974 % dimensions
975 % of the target page. |\inv@targetmag| is the inverse of the target
976 % magnification.
977 % \begin{macrocode}
978 {\catcode`\p=12\catcode`\t=12\gdef\@@inv@@mag#1pt#2{\def#2{#1}}}
979 \def\target#1#2#3{%
980 \mag #1\relax
981 \@targetwidth=1000pt
982 \divide\@targetwidth by #1\relax
983 \expandafter\@@inv@@mag\the\@targetwidth\inv@targetmag
984 \@targetwidth=#2\relax
985 \@targetwidth=\inv@targetmag\@targetwidth
986 \@targetheight=#3\relax
987 \@targetheight=\inv@targetmag\@targetheight}
988
989 % \end{macrocode}
990 % \end{macro}
991 % \end{macro}
992 %
993 % \begin{macro}{\source}
994 % Like |\target|, but for the source:
995 % \begin{macrocode}
996 \def\source#1#2#3{%
997 \@sourcewidth=1000pt
998 \divide\@sourcewidth by #1\relax
999 \expandafter\@@inv@@mag\the\@sourcewidth\inv@sourcemag
1000 \@sourcewidth=#2\relax
1001 \@sourcewidth=\inv@sourcemag\@sourcewidth
1002 \@sourceheight=#3\relax
1003 \@sourceheight=\inv@sourcemag\@sourceheight}
1004
1005 % \end{macrocode}
1006 % \end{macro}
1007 %
1008 % \begin{macro}{\setpdftargetpages}
1009 % This macro specifies the size of the target page for pdfLaTeX.
1010 % It ensures that \Lpack{memoir}'s version (\cs{fixpdflayout}) does nothing.
1011 % \changes{v0.7}{2005/03/23}{Modified \cs{setpdftargetpages} to cater for memoir}
1012 % \begin{macrocode}
1013 \renewcommand*{\setpdftargetpages}{%
1014 \ifprintoption
1015 \setlength{\pdfpageheight}{\@targetheight}%
1016 \setlength{\pdfpagewidth}{\@targetwidth}%
1017 \let\fixpdflayout\relax
1018 \fi}
1019 % \end{macrocode}
1020 % \end{macro}
1021 %
1022 % \begin{macro}{\setdvipstargetpages}
1023 % This macro specifies the size of the target page fow when dvips is
1024 % used. It ensures that \Lpack{memoir}'s version (\cs{fixdvipslayout})
1025 % does nothing.
1026 % \changes{v0.7}{2005/03/23}{Implemented \cs{setdvipstargetpages}}
1027 % \begin{macrocode}
1028 \renewcommand*{\setdvipstargetpages}{%
1029 \ifprintoption
1030 \AtBeginDvi{\special{papersize=\the\@targetwidth,\the\@targetheight}}%
1031 \let\fixdvipslayout\relax
1032 \fi}
1033
1034 % \end{macrocode}
1035 % \end{macro}
1036 %
1037 % \begin{macro}{\targetBooklet}
1038 % \begin{macro}{\ship@@@leftpage}
1039 % \begin{macro}{\ship@@@rightpage}
1040 % I only provide the original \Lpack{2up} Booklet, not booklet. For
1041 % the \Lpack{booklet} package the Booklet code can be processed
1042 % immediately. The code in this chunk is equvalent to the original
1043 % |\target@Booklet|.
1044 % \begin{macrocode}
1045 \def\targetBooklet{%
1046 \def\ship@@@leftpage{\save@booklet\@leftpage}%
1047 \def\ship@@@rightpage{\save@booklet\@rightpage}%
1048 \@leftpagefalse}
1049 \targetBooklet
1050
1051 % \end{macrocode}
1052 % \end{macro}
1053 % \end{macro}
1054 % \end{macro}
1055 %
1056 % \begin{macro}{\targettopbottom}
1057 % \begin{macro}{\make@@halfpage}
1058 % \begin{macro}{\make@fullpage}
1059 % I have renamed the original |\target@topbottom| to |\targettopbottom|
1060 % \begin{macrocode}
1061 \def\targettopbottom{%
1062 \def\make@@halfpage{\make@@halftopbottom}%
1063 \def\make@fullpage{\make@fulltopbottom}%
1064 \sidebysidefalse}
1065
1066 % \end{macrocode}
1067 % \end{macro}
1068 % \end{macro}
1069 % \end{macro}
1070 %
1071 % Specify the options. There are new ones for signature sizes, and some
1072 % of the original \Lpack{2up} source/targets are now treated as options.
1073 % \begin{macrocode}
1074 \DeclareOption{four}{\setcounter{signature}{4}}
1075 \DeclareOption{eight}{\setcounter{signature}{8}}
1076 \DeclareOption{sixteen}{\setcounter{signature}{16}}
1077 \DeclareOption{thirtytwo}{\setcounter{signature}{32}}
1078 \DeclareOption{twouparticle}{\twouparticle}
1079 \DeclareOption{landscape}{\twouplandscape}
1080 \DeclareOption{largetypeblock}{\twoupplain}
1081 \DeclareOption{1to1}{\twouponetoone}
1082
1083 % \end{macrocode}
1084 %
1085 % \begin{macro}{\shipout}
1086 % TeX's |\shipout| primitive is saved as |\&normal@shipout|,
1087 % and then |\shipout|
1088 % is defined to save each page to |\@leftpage| or |\@rightpage|
1089 % and to print out every two. There is no twosided layout in this version.
1090 % \begin{macrocode}
1091 \expandafter\let\csname &normal@shipout\endcsname\shipout
1092 \def\shipout{%
1093 \if@leftpage
1094 \global\@leftpagefalse
1095 \def\next{\afterassignment\ship@leftpage\global\setbox\@leftpage=}%
1096 \else
1097 \global\@leftpagetrue
1098 \def\next{\afterassignment\ship@rightpage\global\setbox\@rightpage=}%
1099 \fi
1100 \next}
1101
1102 % \end{macrocode}
1103 % \end{macro}
1104 %
1105 % \begin{macro}{\ship@leftpage}
1106 % \begin{macro}{\ship@rightpage}
1107 % The job of |\ship@leftpage| and |\ship@rightpage| is to invoke
1108 % |\ship@@leftpage| or |\ship@@rightpage| at the right time.
1109 % |\shipout| is followed either:
1110 % \begin{enumerate}
1111 % \item by an |\hbox|, |\vbox| or |\vtop|, in which case
1112 % |\ship@leftpage| is invoked after the opening |{|;
1113 % |\@leftpage| is void, and |\ship@leftpage| invokes
1114 % |\ship@@leftpage| after the closing |}|: or
1115 %
1116 % \item by a |\box| or |\copy|, in which case |\ship@leftpage| is invoked after
1117 % the full assignment; |\@leftpage| is not void, and |\ship@leftpage| invokes
1118 % |\ship@@leftpage| immediately.
1119 % \end{enumerate}
1120 %
1121 % \begin{macrocode}
1122 \def\ship@leftpage{%
1123 \ifvoid\@leftpage\aftergroup\ship@@leftpage\else\ship@@leftpage\fi}
1124 \def\ship@rightpage{%
1125 \ifvoid\@rightpage\aftergroup\ship@@rightpage\else\ship@@rightpage\fi}
1126
1127 % \end{macrocode}
1128 % \end{macro}
1129 % \end{macro}
1130 %
1131 % \begin{macro}{\ship@@leftpage}
1132 % \begin{macro}{\ship@@rightpage}
1133 % |\ship@@leftpage|/|\ship@@rightpage| take the output box,
1134 % and first make it
1135 % into a fully-size source page (with |\make@halfpage|) and then this is
1136 % centered horizontally and vertically in half of a target page (with
1137 % |\make@@halfpage|). Then they are shipped individually or together.
1138 % \begin{macrocode}
1139 \def\ship@@leftpage{\make@halfpage\@leftpage\ship@@@leftpage}
1140 \def\ship@@rightpage{\make@halfpage\@rightpage\ship@@@rightpage}
1141
1142 % \end{macrocode}
1143 % \end{macro}
1144 % \end{macro}
1145 %
1146 % \begin{macro}{\make@halfpage}
1147 % \begin{macrocode}
1148 \def\make@halfpage#1{%
1149 \dp#1=\z@
1150 \setbox#1=\vbox to\@sourceheight{%
1151 \vskip \inv@sourcemag in
1152 \vskip \voffset
1153 \hbox to\@sourcewidth{\hskip\inv@sourcemag in\hskip\hoffset\box#1\hss}%
1154 \vss}%
1155 \make@@halfpage#1}
1156
1157 % \end{macrocode}
1158 % \end{macro}
1159 %
1160 % \begin{macro}{\make@@halfsidebyside}
1161 % \begin{macro}{\make@@halfpage}
1162 % The definition of |\make@@halfpage| depends on the target layout.
1163 % \begin{macrocode}
1164 \def\make@@halfsidebyside#1{%
1165 \global\setbox#1=\vbox to\@targetheight{\vss
1166 \hbox to.5\@targetwidth{\hss\box#1\hss}\vss}}
1167 \def\make@@halfpage{\make@@halfsidebyside}
1168
1169 % \end{macrocode}
1170 % \end{macro}
1171 % \end{macro}
1172 %
1173 % \begin{macro}{\make@@halftopbottom}
1174 % \begin{macrocode}
1175 \def\make@@halftopbottom#1{%
1176 \global\setbox#1=\vbox to.5\@targetheight{\vss
1177 \hbox to\@targetwidth{\hss\box#1\hss}\vss}}
1178
1179 % \end{macrocode}
1180 % \end{macro}
1181 %
1182 % \begin{macro}{\ship@twoup}
1183 % The pages are generaly shipped in pairs:
1184 % \begin{macrocode}
1185 \def\ship@twoup{%
1186 \begingroup
1187 \voffset=-\inv@targetmag in
1188 \hoffset=\voffset
1189 \global\advance\@physicalpage by 1
1190 \count\z@=\@physicalpage
1191 \csname &normal@shipout\endcsname\make@fullpage
1192 \endgroup}
1193
1194 % \end{macrocode}
1195 % \end{macro}
1196 %
1197 % \begin{macro}{\make@fullsidebyside}
1198 % \begin{macro}{\make@fulltopbottom}
1199 % \begin{macrocode}
1200 \def\make@fullsidebyside{%
1201 \hbox{\box\@leftpage\pagesep@sidebyside\box\@rightpage}}
1202 \def\make@fulltopbottom{%
1203 \vbox{\offinterlineskip\box\@leftpage\pagesep@topbottom\box\@rightpage}}
1204
1205 % \end{macrocode}
1206 % \end{macro}
1207 % \end{macro}
1208 %
1209 % \begin{macro}{\make@fullpage}
1210 % The definition of |\make@fullpage| depends on the layout:
1211 % \begin{macrocode}
1212 \def\make@fullpage{\make@fullsidebyside}
1213
1214 % \end{macrocode}
1215 % \end{macro}
1216 %
1217 % \begin{macro}{\pagesep@sidebyside}
1218 % \begin{macro}{\pagesep@topbottom}
1219 % A vertical or horizontal rule can be inserted. These can be redefined
1220 % for other tricks:
1221 % \begin{macrocode}
1222 \def\pagesep@sidebyside{%
1223 \begingroup
1224 \advance\pageseplength by \pagesepoffset
1225 \pagesepwidth=\inv@targetmag\pagesepwidth
1226 \kern -.5\pagesepwidth
1227 \vrule height \inv@targetmag\pageseplength
1228 depth -\inv@targetmag\pagesepoffset
1229 width \pagesepwidth
1230 \kern -.5\pagesepwidth
1231 \endgroup}
1232 \def\pagesep@topbottom{%
1233 \begingroup
1234 \pagesepwidth=\inv@targetmag\pagesepwidth
1235 \vskip -.5\pagesepwidth
1236 \moveright\inv@targetmag\pagesepoffset\hbox{%
1237 \vrule height\pagesepwidth width\inv@targetmag\pageseplength}%
1238 \vskip -.5\pagesepwidth
1239 \endgroup}
1240
1241 % \end{macrocode}
1242 % \end{macro}
1243 % \end{macro}
1244 %
1245 % \changes{v0.7a}{2005/06/01}{Added sewing example}
1246 % For example it may be helpful to mark the positions of sewing holes
1247 % along the spine of your booklet. For \Lopt{landscape} this can be done
1248 % by redefining \cs{pagesep@topbottom} and for the more typical portrait
1249 % style booklet by changing \cs{pagesep@sidebyside}. The general technique
1250 % is to use a zero-sized picture which \LaTeX{} will think takes up no space.
1251 % For instance, for letterpaper (11in by 8.5in) you can do something
1252 % like this in your preamble:
1253 % \begin{verbatim}
1254 % \makeatletter
1255 % \renewcommand*{\pagesep@sidebyside}{%
1256 % \begingroup
1257 % \setlength{\unitlength}{1in}% measurements in inches
1258 % \begin{picture}(0,0)(0,-8.5)% zero-sized picture, origin at page top
1259 % \put(0,-1){\makebox(0,0){.}}% mark 1in down from top
1260 % \put(0,-4.25){\makebox(0,0){.}}% mark at page center
1261 % \put(0,-7.5){\makebox(0,0){.}}% mark 1in up from bottom
1262 % \end{picture}%
1263 % \endgroup}
1264 % \makeatother
1265 % \end{verbatim}
1266 %
1267 % \begin{macro}{\save@booklet}
1268 % With the Booklet layout, the pages are saved rather than
1269 % shipped. I have added the signature code to the original macro. This
1270 % outputs all the pages making up a signature even if there are still more
1271 % to come. The page boxes used in |\save@booklet| are assigned initially
1272 % by |\twoupp@geboxes|.
1273 % \changes{v0.6}{2001/08/26}{Modified \cs{save@booklet}}
1274 % \begin{macrocode}
1275 \begingroup
1276 \let\newbox\relax
1277 \gdef\save@booklet#1{%
1278 \begingroup
1279 \globaldefs=1
1280 \ifnum\c@sigcount=\z@\bookletpage=0\fi
1281 \advance\bookletpage by 1
1282 \addtocounter{sigcount}{1}
1283 %%%% \expandafter\newbox\csname bookletbox\the\bookletpage\endcsname
1284 \expandafter\setbox\csname bookletbox\the\bookletpage\endcsname\box#1%
1285 \endgroup
1286 \ifnum\c@sigcount=\c@signature %%% PW
1287 \twoup@eject%
1288 \setcounter{sigcount}{0}%
1289 \fi}
1290 \endgroup
1291
1292 % \end{macrocode}
1293 % \end{macro}
1294 %
1295 % \begin{macro}{\make@bookletpage}
1296 % \begin{macro}{\booklet@loop}
1297 % \begin{macro}{\Booklet@@loop}
1298 % The pages are then printed at the end with the following macros:
1299 % \begin{macrocode}
1300 \def\make@bookletpage#1{%
1301 \setbox\ifodd#1\@rightpage\else\@leftpage\fi=%
1302 \expandafter\box\csname bookletbox\the#1\endcsname}
1303
1304 \def\booklet@loop{%
1305 \count\z@\rightpagenumber
1306 \make@bookletpage\leftpagenumber
1307 \make@bookletpage\rightpagenumber
1308 \ship@twoup
1309 \Booklet@@loop
1310 }
1311
1312 \def\Booklet@@loop{%
1313 \advance\rightpagenumber by 1
1314 \advance\leftpagenumber by -1
1315 \ifnum\leftpagenumber<\rightpagenumber\else\expandafter\booklet@loop\fi}
1316
1317 % \end{macrocode}
1318 % \end{macro}
1319 % \end{macro}
1320 % \end{macro}
1321 %
1322 % \begin{macro}{\twoupemptypage}
1323 % This one is easy:
1324 % \begin{macrocode}
1325 \def\twoupemptypage{\shipout\hbox{}}
1326
1327 % \end{macrocode}
1328 % \end{macro}
1329 %
1330 %
1331 % \begin{macro}{\twoup@eject}
1332 % This clears a whole target page if there is a saved left page. Note that
1333 % this does not invoke the output routine; i.e., it is not like |\clearpage|
1334 % or |\supereject|. See |\twoupclearpage| below. (The \Lpack{booklet}
1335 % package doesn't need |\twoupeject| which is for non-LaTeX systems).
1336 %
1337 % This is the definition of |\twoup@eject| with the Booklet layout.
1338 % \begin{macrocode}
1339 \def\twoup@eject{
1340 \leftpagenumber\bookletpage
1341 \advance\leftpagenumber by 3
1342 \divide\leftpagenumber by 4
1343 \multiply\leftpagenumber by 4
1344 \rightpagenumber=1
1345 \ifnum\leftpagenumber>\bookletpage
1346 \setbox\@leftpage\hbox{}%
1347 \make@@halfpage\@leftpage
1348 \loop
1349 \setbox\@rightpage\copy\@leftpage
1350 \save@booklet\@rightpage
1351 \ifnum\leftpagenumber>\bookletpage
1352 \repeat
1353 \fi
1354 \booklet@loop}
1355
1356 % \end{macrocode}
1357 % \end{macro}
1358 %
1359 % \begin{macro}{\twoupclearpage}
1360 % This modification is needed for LaTeX in order to get the last page
1361 % printed out if the final page is a left page (the catcode business is
1362 % because |\enddocument| is |\let| to |\bye| in amstex):
1363 % \begin{macrocode}
1364 \begingroup
1365 \catcode`\>=9\relax
1366 >>\gdef\twoupclearpage{\clearpage\twoup@eject}
1367 >>\expandafter\@temptokena\expandafter{\enddocument}
1368 >>\xdef\enddocument{\noexpand\twoupclearpage\the\@temptokena}
1369 \endgroup
1370
1371 % \end{macrocode}
1372 % \end{macro}
1373 %
1374 %
1375 % \begin{macro}{\TwoupWrites}
1376 % This is one workaround for the page cross-references problem
1377 % \begin{macrocode}
1378 \def\TwoupWrites{%
1379 \let\TwoupSaved@write\write
1380 \let\TwoupSaved@read\read
1381 \let\TwoupSaved@openout\openout
1382 \let\TwoupSaved@closeout\closeout
1383 \def\write{\TwoupSaved@write-1{}\immediate\TwoupSaved@write}%
1384 \def\read{\TwoupSaved@write-1{}\immediate\TwoupSaved@read}%
1385 \def\openout{\TwoupSaved@write-1{}\immediate\TwoupSaved@openout}%
1386 \def\closeout{\TwoupSaved@write-1{}\immediate\TwoupSaved@closeout}%
1387 \let\TwoupWrites\relax}
1388
1389 % \end{macrocode}
1390 % \end{macro}
1391 %
1392 % \begin{macro}{\twouparticle}
1393 % \begin{macro}{\twoupplain}
1394 % \begin{macro}{\twouplandscape}
1395 % \begin{macro}{\twouponetoone}
1396 % The pre-defined layouts. I have taken advantage of LaTeX2e's
1397 % paper size lengths to generalise.
1398 % \begin{macrocode}
1399 \def\twouparticle{\target{\magstepminus1}{\paperheight}{\paperwidth}}
1400 \def\twoupplain{\target{\magstepminus2}{\paperheight}{\paperwidth}}
1401 \def\twouplandscape{\target{\magstepminus2}{\paperwidth}{\paperheight}%
1402 \targettopbottom}
1403 \def\twouponetoone{\target{\magstep0}{\paperheight}{\paperwidth}}
1404
1405 % \end{macrocode}
1406 % \end{macro}
1407 % \end{macro}
1408 % \end{macro}
1409 % \end{macro}
1410 %
1411 % Set the default for the source.
1412 % \begin{macrocode}
1413 \source{\magstep0}{\paperwidth}{\paperheight}
1414 % \end{macrocode}
1415 %
1416 % Set the defaults for the rule.
1417 % \begin{macrocode}
1418 \pagesepwidth 0pt
1419 \pageseplength 6.5in
1420 \pagesepoffset 1in
1421 % \end{macrocode}
1422 %
1423 % I also found that |\TwoupWrites| was really not optional.
1424 % \begin{macrocode}
1425 \TwoupWrites
1426
1427 % \end{macrocode}
1428 %
1429 % The default options are \Lopt{twouparticle} and \Lopt{thirtytwo} pages
1430 % per signature.
1431 % \begin{macrocode}
1432 \ExecuteOptions{twouparticle,thirtytwo}
1433 \ProcessOptions
1434
1435 % \end{macrocode}
1436 %
1437 %
1438 % The end of this package.
1439 % \begin{macrocode}
1440 %</prnt>
1441 % \end{macrocode}
1442 %
1443 %
1444 % \appendix
1445 %
1446 % \section{The code for 2up} \label{sec:2upcode}
1447 %
1448 % Following is a verbatim copy of Timothy Van Zandt's \Lpack{2up} code.
1449 % I hope that by including this I have partly met his COPYING conditions.
1450 %
1451 % \begin{verbatim}
1452 %
1453 % %% BEGIN 2up.tex/2up.sty
1454 % %%
1455 % \def\fileversion{1.2}
1456 % \def\filedate{93/01/28}
1457 % %%
1458 % %% COPYRIGHT 1992, 1993 by Timothy Van Zandt, [email protected]
1459 % %%
1460 % %% DESCRIPTION:
1461 % %% 2up.tex/2up.sty provides two-up printing for Generic TeX (e.g.,
1462 % %% Plain, LaTeX, AmSTeX and AmS-LaTeX). It produces a standard dvi file,
1463 % %% and does not involve an additional dvi or PostScript filter. It has a
1464 % %% flexible interface for specifying paper size and layout.
1465 % %%
1466 % %% INSTALLATION:
1467 % %% Put this file where your TeX looks for inputs, under the name 2up.tex.
1468 % %% Name a copy 2up.sty to use as a LaTeX style option, or create a file
1469 % %% 2up.sty with the lines:
1470 % %% \input 2up.tex
1471 % %% \endinput
1472 % %%
1473 % %% DOCUMENTATION:
1474 % %% Input 2up.tex, or include 2up as a LaTeX style option. There is a
1475 % %% good chance you will get the desired layout. (But you will probably
1476 % %% need to generate new font bitmaps to get high quality output.) See
1477 % %% 2up.doc, which might be appended to this file, for detailed
1478 % %% documentation.
1479 % %%
1480 % %% COPYING:
1481 % %% Copying of part or all of this file is allowed under the following
1482 % %% conditions only:
1483 % %% (1) You may freely distribute unchanged copies of the file. Please
1484 % %% include the documentation when you do so.
1485 % %% (2) You may modify a renamed copy of the file, but only for personal
1486 % %% use or use within an organization.
1487 % %% (3) You may copy fragments from the file, for personal use or for use
1488 % %% in a macro package for distribution, as long as credit is given
1489 % %% where credit is due.
1490 % %%
1491 % %% You are NOT ALLOWED to take money for the distribution or use of
1492 % %% this file or modified versions or fragments thereof, except for
1493 % %% a nominal charge for copying etc.
1494 % %%
1495 % %% CODE:
1496 % %
1497 % \csname TwoUpLoaded\endcsname
1498 % \let\TwoUpLoaded\endinput
1499 % %
1500 % \edef\TheAtCode{\the\catcode`\@}
1501 % \catcode`\@=11\relax
1502 % \message{\space\space v\fileversion\space\space \filedate\space\space <tvz>}
1503 % %
1504 % % Parameter registers:
1505 % \newdimen\@targetwidth
1506 % \newdimen\@targetheight
1507 % \newdimen\@sourcewidth
1508 % \newdimen\@sourceheight
1509 % \newdimen\pageseplength
1510 % \newdimen\pagesepwidth
1511 % \newdimen\pagesepoffset
1512 % \newif\if@sidebyside
1513 % \@sidebysidetrue
1514 % \newif\if@twosided
1515 % %
1516 % % Registers used by output routine.
1517 % \newif\if@leftpage
1518 % \@leftpagetrue
1519 % \newbox\@leftpage
1520 % \newbox\@rightpage
1521 % \newcount\@physicalpage
1522 % %
1523 % % Since pages are shipped out half as often:
1524 % \multiply\maxdeadcycles by 2
1525 % %
1526 % % Registers used only for booklet layout:
1527 % \begingroup
1528 % \let\newcount\relax
1529 % \gdef\booklet@registers{%
1530 % \newcount\bookletpage
1531 % \bookletpage=0
1532 % \newcount\leftpagenumber
1533 % \newcount\rightpagenumber
1534 % \multiply\maxdeadcycles by 20}
1535 % \endgroup
1536 % %
1537 % % A useful extension of the \magstep macro.
1538 % \def\magstepminus#1{%
1539 % \ifcase#1 \@m\or 833\or 694\or 579\or 482\or 401\fi\relax}
1540 % %
1541 % % \@targetwidth and \@targetheight are set to the *unmagnified* dimensions
1542 % % of the target page. \inv@targetmag is the inverse of the target
1543 % % magnification.
1544 % {\catcode`\p=12\catcode`\t=12\gdef\@@inv@@mag#1pt#2{\def#2{#1}}}
1545 % \def\target#1#2#3{%
1546 % \mag #1\relax
1547 % \@targetwidth=1000pt
1548 % \divide\@targetwidth by #1\relax
1549 % \expandafter\@@inv@@mag\the\@targetwidth\inv@targetmag
1550 % \@targetwidth=#2\relax
1551 % \@targetwidth=\inv@targetmag\@targetwidth
1552 % \@targetheight=#3\relax
1553 % \@targetheight=\inv@targetmag\@targetheight}
1554 % %
1555 % % Like \target, but for the source:
1556 % \def\source#1#2#3{%
1557 % \@sourcewidth=1000pt
1558 % \divide\@sourcewidth by #1\relax
1559 % \expandafter\@@inv@@mag\the\@sourcewidth\inv@sourcemag
1560 % \@sourcewidth=#2\relax
1561 % \@sourcewidth=\inv@sourcemag\@sourcewidth
1562 % \@sourceheight=#3\relax
1563 % \@sourceheight=\inv@sourcemag\@sourceheight}
1564 % %
1565 % % \targetlayout does a loop that reads the comma separated arguments.
1566 % % There can be no extraneous spaces.
1567 % \def\targetlayout#1{\process@targetlayout#1,stop,}
1568 % \def\process@targetlayout#1,{%
1569 % \expandafter\let\expandafter\next\csname target@#1\endcsname
1570 % \ifx\next\relax
1571 % \begingroup
1572 % \errhelp{Valid target layouts are "topbottom", "twosided",
1573 % "booklet", "Booklet" and "dvidvi".}%
1574 % \errmessage{`#1' is invalid 2up target layout - ignored.}%
1575 % \endgroup
1576 % \expandafter\process@targetlayout
1577 % \else
1578 % \next
1579 % \fi}
1580 % \def\target@stop{}
1581 % \def\target@booklet{%
1582 % \booklet@registers
1583 % \def\ship@@@leftpage{\save@booklet\@leftpage}%
1584 % \def\ship@@@rightpage{\save@booklet\@rightpage}%
1585 % \@leftpagefalse
1586 % \def\twoup@eject{\twoup@eject@booklet}%
1587 % \expandafter\process@targetlayout}
1588 % \def\target@Booklet{%
1589 % \def\booklet@@loop{\Booklet@@loop}%
1590 % \target@booklet}
1591 % \def\target@twosided{%
1592 % \@twosidedtrue
1593 % \expandafter\process@targetlayout}
1594 % \def\target@topbottom{%
1595 % \def\make@@halfpage{\make@@halftopbottom}%
1596 % \def\make@fullpage{\make@fulltopbottom}%
1597 % \@sidebysidefalse
1598 % \expandafter\process@targetlayout}
1599 % \def\target@dvidvi{%
1600 % \def\ship@@@leftpage{\ship@dvidvi\@leftpage}%
1601 % \def\ship@@@rightpage{\ship@dvidvi\@rightpage}%
1602 % \expandafter\process@targetlayout}
1603 % %
1604 % % TeX's \shipout primitive is saved as \&normal@shipout, and then \shipout
1605 % % is defined to save each page to \@leftpage or \@rightpage and to print out
1606 % % every two. With the twosided layout, filler pages are added when needed.
1607 % \expandafter\let\csname &normal@shipout\endcsname\shipout
1608 % \def\shipout{%
1609 % \if@leftpage
1610 % \global\@leftpagefalse
1611 % \def\next{\afterassignment\ship@leftpage\global\setbox\@leftpage=}%
1612 % \if@twosided
1613 % \ifodd\count\z@
1614 % \global\setbox\@leftpage=\hbox{}%
1615 % \make@@halfpage\@leftpage\ship@@@leftpage
1616 % \def\next{\shipout}%
1617 % \fi
1618 % \fi
1619 % \else
1620 % \global\@leftpagetrue
1621 % \def\next{\afterassignment\ship@rightpage\global\setbox\@rightpage=}%
1622 % \if@twosided
1623 % \ifodd\count\z@
1624 % \else
1625 % \global\setbox\@rightpage=\hbox{}%
1626 % \make@@halfpage\@rightpage\ship@@@rightpage
1627 % \def\next{\shipout}%
1628 % \fi
1629 % \fi
1630 % \fi
1631 % \next}
1632 % %
1633 % % The job of \ship@leftpage and \ship@rightpage is to invoke \ship@@leftpage
1634 % % or \ship@@rightpage at the right time. \shipout is followed either
1635 % % (i) by an \hbox, \vbox or \vtop, in which case \ship@leftpage is invoked
1636 % % after the opening {. \@leftpage is void, and \ship@leftpage invokes
1637 % % \ship@@leftpage after the closing }, or
1638 % % (ii) by a \box or \copy, in which case \ship@leftpage is invoked after
1639 % % the full assignment. \@leftpage is not voide, and \ship@leftpage invokes
1640 % % \ship@@leftpage immediately.
1641 % \def\ship@leftpage{%
1642 % \ifvoid\@leftpage\aftergroup\ship@@leftpage\else\ship@@leftpage\fi}
1643 % \def\ship@rightpage{%
1644 % \ifvoid\@rightpage\aftergroup\ship@@rightpage\else\ship@@rightpage\fi}
1645 % %
1646 % % \ship@@leftpage/\ship@@rightpage take the output box, and first make it
1647 % % into a fully-size source page (with \make@halfpage) and then this is
1648 % % centered horizontally and vertically in half of a target page (with
1649 % % \make@@halfpage). Then they are shipped individually or together.
1650 % \def\ship@@leftpage{\make@halfpage\@leftpage\ship@@@leftpage}
1651 % \def\ship@@rightpage{\make@halfpage\@rightpage\ship@@@rightpage}
1652 % \def\make@halfpage#1{%
1653 % \dp#1=\z@
1654 % \setbox#1=\vbox to\@sourceheight{%
1655 % \vskip \inv@sourcemag in
1656 % \vskip \voffset
1657 % \hbox to\@sourcewidth{\hskip\inv@sourcemag in\hskip\hoffset\box#1\hss}%
1658 % \vss}%
1659 % \make@@halfpage#1}
1660 % %
1661 % % The definition of \make@@halfpage depends on the target layout.
1662 % \def\make@@halfsidebyside#1{%
1663 % \global\setbox#1=\vbox to\@targetheight{\vss
1664 % \hbox to.5\@targetwidth{\hss\box#1\hss}\vss}}
1665 % \def\make@@halftopbottom#1{%
1666 % \global\setbox#1=\vbox to.5\@targetheight{\vss
1667 % \hbox to\@targetwidth{\hss\box#1\hss}\vss}}
1668 % \def\make@@halfpage{\make@@halfsidebyside}
1669 % %
1670 % % The pages are generaly shipped in pairs:
1671 % \def\ship@twoup{%
1672 % \begingroup
1673 % \voffset=-\inv@targetmag in
1674 % \hoffset=\voffset
1675 % \global\advance\@physicalpage by 1
1676 % \count\z@=\@physicalpage
1677 % \csname &normal@shipout\endcsname\make@fullpage
1678 % \endgroup}
1679 % \let\ship@@@leftpage\relax
1680 % \def\ship@@@rightpage{\ship@twoup}
1681 % %
1682 % % The definition of \make@fullpage depends on the layout:
1683 % \def\make@fullsidebyside{%
1684 % \hbox{\box\@leftpage\pagesep@sidebyside\box\@rightpage}}
1685 % \def\make@fulltopbottom{%
1686 % \vbox{\offinterlineskip\box\@leftpage\pagesep@topbottom\box\@rightpage}}
1687 % \def\make@fullpage{\make@fullsidebyside}
1688 % %
1689 % % A vertical or horizontal rule can be inserted. These can be redefined
1690 % % for other tricks:
1691 % \def\pagesep@sidebyside{%
1692 % \begingroup
1693 % \advance\pageseplength by \pagesepoffset
1694 % \pagesepwidth=\inv@targetmag\pagesepwidth
1695 % \kern -.5\pagesepwidth
1696 % \vrule height \inv@targetmag\pageseplength
1697 % depth -\inv@targetmag\pagesepoffset
1698 % width \pagesepwidth
1699 % \kern -.5\pagesepwidth
1700 % \endgroup}
1701 % \def\pagesep@topbottom{%
1702 % \begingroup
1703 % \pagesepwidth=\inv@targetmag\pagesepwidth
1704 % \vskip -.5\pagesepwidth
1705 % \moveright\inv@targetmag\pagesepoffset\hbox{%
1706 % \vrule height\pagesepwidth width\inv@targetmag\pageseplength}%
1707 % \vskip -.5\pagesepwidth
1708 % \endgroup}
1709 % %
1710 % % With the dvidvi layout, the pages are shipped individually:
1711 % \def\ship@dvidvi#1{%
1712 % \begingroup
1713 % \voffset=-\inv@targetmag in
1714 % \hoffset=\voffset
1715 % \csname &normal@shipout\endcsname\box#1%
1716 % \endgroup}
1717 % %
1718 % % With the booklet or Booklet layout, the pages are saved rather than
1719 % % shipped.
1720 % \begingroup
1721 % \let\newbox\relax
1722 % \gdef\save@booklet#1{%
1723 % \begingroup
1724 % \globaldefs=1
1725 % \advance\bookletpage by 1
1726 % \expandafter\newbox\csname bookletbox\the\bookletpage\endcsname
1727 % \expandafter\setbox\csname bookletbox\the\bookletpage\endcsname\box#1%
1728 % \endgroup}
1729 % \endgroup
1730 % %
1731 % % The pages are then printed at the end with the following macros:
1732 % \def\make@bookletpage#1{%
1733 % \setbox\ifodd#1\@rightpage\else\@leftpage\fi=%
1734 % \expandafter\box\csname bookletbox\the#1\endcsname}
1735 % \def\booklet@loop{%
1736 % \count\z@\rightpagenumber
1737 % \make@bookletpage\leftpagenumber
1738 % \make@bookletpage\rightpagenumber
1739 % \ship@twoup
1740 % \booklet@@loop}
1741 % \def\booklet@@loop{%
1742 % \advance\rightpagenumber by 2
1743 % \advance\leftpagenumber by -2
1744 % \ifnum\leftpagenumber<1\else\expandafter\booklet@loop\fi}
1745 % \def\Booklet@@loop{%
1746 % \advance\rightpagenumber by 1
1747 % \advance\leftpagenumber by -1
1748 % \ifnum\leftpagenumber<\rightpagenumber\else\expandafter\booklet@loop\fi}
1749 % %
1750 % % This one is easy:
1751 % \def\twoupemptypage{\shipout\hbox{}}
1752 % %
1753 % % This clears a whole target page if there is a saved left page. Note that
1754 % % this does not invoke the output routine; i.e., it is not like \clearpage
1755 % % or \supereject. See \twoupclearpage and \twoupeject below.
1756 % \def\twoup@eject{%
1757 % \if@leftpage\else
1758 % \global\setbox\@rightpage\hbox{}%
1759 % \make@@halfpage\@rightpage\ship@@@rightpage
1760 % \global\@leftpagetrue
1761 % \fi}
1762 % %
1763 % % This is the definition of \twoup@eject with the booklet option:
1764 % \def\twoup@eject@booklet{%
1765 % \leftpagenumber\bookletpage
1766 % \advance\leftpagenumber by 3
1767 % \divide\leftpagenumber by 4
1768 % \multiply\leftpagenumber by 4
1769 % \rightpagenumber=1
1770 % \ifnum\leftpagenumber>\bookletpage
1771 % \setbox\@leftpage\hbox{}%
1772 % \make@@halfpage\@leftpage
1773 % \loop
1774 % \setbox\@rightpage\copy\@leftpage
1775 % \save@booklet\@rightpage
1776 % \ifnum\leftpagenumber>\bookletpage
1777 % \repeat
1778 % \fi
1779 % \booklet@loop}
1780 % %
1781 % % This modification is needed for \LaTeX in order to get the last page
1782 % % printed out if the final page is a left page (the catcode business is
1783 % % because \enddocument is \let to \bye in amstex):
1784 % \begingroup
1785 % \expandafter\ifx\csname @latexerr\endcsname\relax
1786 % \catcode`\>=14\else\catcode`\>=9\fi\relax
1787 % >>\gdef\twoupclearpage{\clearpage\twoup@eject}
1788 % >>\expandafter\@temptokena\expandafter{\enddocument}
1789 % >>\xdef\enddocument{\noexpand\twoupclearpage\the\@temptokena}
1790 % \endgroup
1791 % %
1792 % % For most other macro packages we could just leave be and all pages would
1793 % % always be printed because of the way the \end primitive works (except that
1794 % % TeX will go bonkers with the booklet layout). However,
1795 % % sometimes a blank filler page would be printed *with* headings. We prefer
1796 % % the filler page to be truly blank. To achieve this, we hack the definition
1797 % % of \end. This may cause problems with some macros.
1798 % \expandafter\ifx\csname @latexerr\endcsname\relax
1799 % \let\twoup@@@end\end
1800 % \def\end{\twoup@eject\twoup@@@end}
1801 % \def\twoupeject{\par\vfil\supereject\twoup@eject}
1802 % \fi
1803 % %
1804 % % This is one workaround for the page cross-references problem
1805 % \def\TwoupWrites{%
1806 % \let\TwoupSaved@write\write
1807 % \let\TwoupSaved@read\read
1808 % \let\TwoupSaved@openout\openout
1809 % \let\TwoupSaved@closeout\closeout
1810 % \def\write{\TwoupSaved@write-1{}\immediate\TwoupSaved@write}%
1811 % \def\read{\TwoupSaved@write-1{}\immediate\TwoupSaved@read}%
1812 % \def\openout{\TwoupSaved@write-1{}\immediate\TwoupSaved@openout}%
1813 % \def\closeout{\TwoupSaved@write-1{}\immediate\TwoupSaved@closeout}%
1814 % \let\TwoupWrites\relax}
1815 % %
1816 % % Defaults:
1817 % \def\twouparticle{%
1818 % \target{\magstepminus1}{11in}{8.5in}%
1819 % \source{\magstep0}{8.5in}{11in}}
1820 % \def\twoupplain{%
1821 % \target{\magstepminus2}{11in}{8.5in}%
1822 % \source{\magstep0}{8.5in}{11in}}
1823 % \def\twouplegaltarget{%
1824 % \target{\magstepminus1}{14in}{8.5in}%
1825 % \source{\magstep0}{8.5in}{11in}}%
1826 % \def\twouplandscape{%
1827 % \target{\magstepminus2}{8.5in}{11in}%
1828 % \source{\magstep0}{11in}{8.5in}%
1829 % \targetlayout{topbottom}}
1830 % \expandafter\ifx\csname @latexerr\endcsname\relax
1831 % \twoupplain\else\twouparticle\fi
1832 % \pagesepwidth 0pt
1833 % \pageseplength 6.5in
1834 % \pagesepoffset 1in
1835 % %
1836 % \expandafter\catcode`\@=\TheAtCode\relax
1837 % \endinput
1838 % %% END 2up.tex/2up.sty
1839 %
1840 % \end{verbatim}
1841 %
1842 %
1843 % \section{The documentation for 2up} \label{sec:2updoc}
1844 %
1845 % Following is an almost verbatim copy of the documentation for Timothy
1846 % Van Zandt's \Lpack{2up}. I hope that by including this I have
1847 % now completely met his COPYING conditions. The only change that
1848 % I have made to the original is replacing every occurrence of `|{verbatim}|'
1849 % by `|{verbtm}|', so LaTeX does not get confused when processing the
1850 % current document.
1851 %
1852 % \begin{verbatim}
1853 %
1854 % %% BEGIN 2up.doc
1855 % %%
1856 % %% Documentation for 2up.tex/2up.sty.
1857 % %% Run through LaTeX, with or without the NFSS.
1858 % %%
1859 % %% See below if you want to try out two-up printing.
1860 % %%
1861 % %% LaTeX version of this documentation courtesy of
1862 % %% H. David Todd <[email protected]>
1863 % %%
1864 % %%
1865 % \documentstyle[12pt,twoside]{article}
1866 %
1867 % \def\FileDate{January 28, 1993}
1868 % \def\FileVersion{1.2}
1869 %
1870 % %% INSTRUCTIONS FOR TWO-UP PRINTING.
1871 % %% 1. Change \iffalse below to \iftrue.
1872 % %% 2. Uncomment \special{landscape} if using Rokicki's dvips, or otherwise
1873 % %% remember to print the document out in landscape mode.
1874 % %% 3. Uncomment one of the booklet options, if desired.
1875 % %%
1876 % \iffalse
1877 % \input 2up.tex
1878 % \targetlayout{twosided}
1879 % \TwoupWrites
1880 % % \special{landscape} %% This works with Rokicki's dvips
1881 % % \targetlayout{Booklet} %% Booklet printing with 2-sided printer/copier.
1882 % % \targetlayout{booklet} %% Booklet printing with 1-sided printer/copier.
1883 % \fi
1884 %
1885 % \makeatletter
1886 %
1887 % %% PAGE NUMBERING:
1888 % %% Adjust page numbering if using booklet layout option.
1889 % \setcounter{page}{0}
1890 % \def\next{\if@leftpage\else\stepcounter{page}\fi}
1891 % \@ifundefined{target@stop}{}{\next}
1892 %
1893 % %% CONTENTS:
1894 % \def\tableofcontents{%
1895 % \par\begin{center}
1896 % \large\bf Contents
1897 % \end{center}
1898 % \begin{quote}\@starttoc{toc}\end{quote}}
1899 %
1900 % %% PAGE PARAMETERS:
1901 % \setlength{\parindent}{0pt} % paragraph indent
1902 % \setlength{\parskip}{4pt plus 1pt minus 1pt}
1903 % \setlength{\topmargin}{0pt}
1904 % \setlength{\headheight}{12pt} % height of running head
1905 % \setlength{\headsep}{30pt} % distance between header and text
1906 % \setlength{\textheight}{8.2in} % height of text on page
1907 %
1908 % %% DATES, VERSIONS AND TITLES:
1909 % \def\@maketitle{%
1910 % \begin{center}
1911 % {\Large\bf \@title \par}
1912 % \vskip 1.2em {\lineskip .5em
1913 % \begin{tabular}[t]{c}\@author\end{tabular}\par}
1914 % \vskip .8em {\@date}%
1915 % \end{center}
1916 % \par
1917 % \vskip .5em}
1918 %
1919 % %% Page Style:
1920 % \pagestyle{myheadings}
1921 % \markboth{Two-Up Style Guide}{Version \FileVersion, \FileDate}
1922 %
1923 % %% Special list:
1924 % \newcommand{\namelistlabel}[1]{\mbox{\bf #1}\hfil}
1925 % \newenvironment{namelist}[1]%
1926 % {\begin{list}{}%
1927 % {\let\makelabel\namelistlabel
1928 % \settowidth{\labelwidth}{#1}
1929 % \setlength{\leftmargin}{1.1\labelwidth}}}%
1930 % {\end{list}}
1931 %
1932 % %% VERBATIM:
1933 % %%
1934 % \begingroup
1935 % \catcode`\{=12 \catcode`\}=12
1936 % \catcode`\(=1 \catcode`\)=2
1937 % \catcode`\+=0 \catcode`\\=12
1938 % +gdef+|(\) % \| = character \
1939 % +gdef+{({) % \{ = character {
1940 % +gdef+}(}) % \} = character }
1941 % +endgroup
1942 % \def\Backslash{\protect\|}
1943 % %%
1944 % %% Define some functional font commands:
1945 % %%
1946 % \def\MainFont{\tt} % For macro definitions.
1947 % \def\UsageFont{\tt} % For in-line macro names.
1948 % \def\InlineFont{\tt} % For other in-line snipets of code.
1949 % \def\MetaFont{\rm\it} % For meta arguments.
1950 % %%
1951 % %% Short-cuts for font commands:
1952 % %%
1953 % \def\s#1{\string#1}
1954 % \def\t#1{{\InlineFont\string#1}} % For other in-line code.
1955 % \def\m#1{{\MetaFont #1\/}} % For just putting things in italics
1956 % \def\M#1{{\InlineFont\{\m{#1}\}}} % Arg is in italic, enclosed in tt braces.
1957 % \let\N\t % For in-line macro names.
1958 % \catcode`\<=13 \def<#1>{\m{#1}} % <meta>
1959 % \catcode`\"=13\def"{\verb"} % Short verb
1960 % %%
1961 % %% This is for listing macro definitions in a quote-like environment.
1962 % %%
1963 % \begingroup
1964 % \catcode`\[=1 \catcode`\]=2
1965 % \catcode`\{=13 \catcode`\}=12
1966 % \gdef\@MD[%
1967 % \catcode`\{=13 \catcode`\}=12
1968 % \def{##1}[\{[\MetaFont ##1]\}]]
1969 % \endgroup
1970 % \def\MD{%
1971 % \quote
1972 % \begingroup
1973 % \@MD
1974 % \def\end{\endgroup\end}%
1975 % \def\\{\@centercr\s}%
1976 % \MainFont
1977 % \s}
1978 % \def\endMD{\endquote}
1979 % %%
1980 %
1981 % %% End preamble.
1982 % \catcode`\@=12
1983 %
1984 % \begin{document}
1985 %
1986 % \title{Documentation for 2up.tex:\\
1987 % Two-up printing for Generic TeX}
1988 % \author{Timothy Van Zandt\thanks{The documentation was put into
1989 % \LaTeX\ format by David Todd.}\\ [email protected]}
1990 % \date{Version \FileVersion\\[3pt] \FileDate}
1991 %
1992 % \maketitle
1993 % \thispagestyle{empty}
1994 %
1995 % "2up.tex"/"2up.sty" allows one to print a document two-up, with
1996 % considerable flexibility as to paper size and layout. It produces a standard
1997 % dvi file, and does not involve an additional dvi or PostScript filter. It
1998 % should work with most \TeX\ macro packages.
1999 %
2000 % {\bf Usage:} Input "2up.tex", or include "2up" as a LaTeX style option.
2001 % There is a good chance you will get the desired layout. (But you will probably
2002 % need to generate new font bitmaps to get high quality output.) See the rest of
2003 % this documentation for detailed information on controlling 2up.tex.
2004 %
2005 % \begingroup
2006 % \def\baselinestretch{.8}\large\normalsize
2007 % \tableofcontents
2008 % \endgroup
2009 % \clearpage
2010 %
2011 % \section{Comparison with other methods}
2012 %
2013 % There are other tools for two-up printing:
2014 % \begin{description}
2015 % \item[PostScript filters]
2016 % These work well as long as you only use PostScript fonts (as opposed to the
2017 % usual Metafont fonts). Otherwise, the PostScript filter scales bitmapped
2018 % fonts, and the quality is lower than with "2up.tex".
2019 %
2020 % \item[Rokicki's dvidvi]
2021 % "dvidvi" is a versatil tool that does much more than
2022 % 2up printing. However, if only rearranges the pages, and does not adjust the
2023 % magnification to ensure that the pages fit properly in a two-up format. It
2024 % also adds one more step to the \TeX-dvi-printer cycle. "2up.tex", on the other
2025 % hand, combines the changes to \TeX's magnification and page layout with the
2026 % rearranging of the pages, all with an easy-to-use interface and from within
2027 % your \TeX\ document. (See Section \ref{dvidvi} on using both "2up.tex" and
2028 % "dvidvi" together.)
2029 % \end{description}
2030 %
2031 % \section{A warning about fonts}
2032 %
2033 % Two-up printing generally involves reducing a document, and thus using fonts
2034 % sizes that are not typically found on your system. If you are using bitmapped
2035 % fonts (standard for \TeX\ users), and you do not have and cannot generate the
2036 % extra fonts bitmaps, you will find 2up.sty (and any other method of two-up
2037 % printing) to give very poor quality output.
2038 %
2039 % If you are using a program like Rokicki's "dvips" that can generate extra font
2040 % bitmaps as needed, you will find that it takes a long time to print your 2up
2041 % document the first few times, as "dvips" is busy making the extra fonts. This
2042 % problem will go away. Be thankful you have such an easy way to get extra font
2043 % bitmaps.
2044 %
2045 % \section{Usage}
2046 %
2047 % Input "2up.tex". \LaTeX\ users can include "2up" as a style option.
2048 %
2049 % Then set the target and source layout:
2050 % \begin{MD}
2051 % \source{mag}{width}{height}\\
2052 % \target{mag}{width}{height}
2053 % \end{MD}
2054 %
2055 % \begin{itemize}
2056 % \item The ``source'' layout is the layout of your document
2057 % the way it is usually printed. The ``target'' layout is the layout when it
2058 % is printed two-up.
2059 %
2060 % \item <width> and <height> are the true width and height of the paper,
2061 % when looking at the output right-side-up.
2062 %
2063 % \item <mag> refers to the source and target magnification. It should be an
2064 % integer, equal to 1000 times the magnification factor. There are also some
2065 % magic magnification numbers:
2066 % \begin{description}
2067 % \item[$\setminus$magstep<n>] for a magnification of 1.2$^n$ (n=0,...,5), or
2068 %
2069 % \item[$\setminus$magstepminus<n>] for a magnification of 1.2$^{-n}$
2070 % (n=0,...,5).
2071 % \end{description}
2072 % Using these magnification values will make best use of the available fonts on
2073 % your system.
2074 % \end{itemize}
2075 %
2076 % "2up.tex" takes each source page, and centers in half a target page. To get
2077 % the pages to fit, the magnification of the document typically has to be
2078 % reduced. If you find that the pages are too crowded, try reducing the target
2079 % magnification. If they are too lonely, try increasing the target
2080 % magnification.
2081 %
2082 % If you want to adjust the positioning of the scaled pages, try changing the
2083 % values of "\hoffset" or "\voffset" with "\advance" or \LaTeX's "\addtolength".
2084 %
2085 % Don't change the magnification of your document after using the "\target"
2086 % command, as you will override the settings made by 2up.tex.
2087 %
2088 % You can also specify some options:
2089 % \begin{MD}
2090 % \targetlayout{options}
2091 % \end{MD}
2092 % where <options> is a comma separated list with no spaces. Valid
2093 % options are:
2094 % \begin{namelist}{topbottomxxx}
2095 %
2096 % \item [topbottom] The two source pages are printed one on top of the other.
2097 % \item [twosided] Odd pages are always printed on the right or the bottom.
2098 % \item [booklet] Pages are printed like a booklet. See Section \ref{booklet}.
2099 % \item [Booklet] Like "booklet", but for two-sided printers/copiers.
2100 % \item [dvidvi] For arranging in two-up layout with "dvidvi". See Section
2101 % \ref{dvidvi}.
2102 %
2103 % \end{namelist}
2104 %
2105 % The only other changes you might want to make to your document are the
2106 % following:
2107 % \begin{itemize}
2108 % \item You have to see to it that the target output is printed with the
2109 % correct orientation (landscape or portrait). See the documentation for your
2110 % dvi driver for details.
2111 %
2112 % \item "2up.tex" will inserts a line between pages if you change the following
2113 % dimensions:
2114 % \begin{namelist}{pagesepwidthxxx}
2115 % \item [$\setminus$pagesepwidth] Thickness of line. (Default 0pt)
2116 % \item [$\setminus$pageseplength] Length of line. (Default 6.5in)
2117 % \item [$\setminus$pagesepoffset] Distance from bottom of page to bottom of
2118 % line, or (with "topbottom" layout) from side of page to beginning of line.
2119 % (Default 1in)
2120 % \end{namelist}
2121 %
2122 % \item You can, but do not need to, use the following commands:
2123 % \begin{namelist}{twoupemptypagexxx}
2124 %
2125 % \item [$\setminus$twoupemptypage] inserts a completely blank half page
2126 % in the target.
2127 %
2128 % \item [$\setminus$twoupclearpage] \LaTeX\ users: ejects a complete target
2129 % page.
2130 %
2131 % \item [$\setminus$twoupeject] Plain \TeX users: ejects a complete target
2132 % page.
2133 %
2134 % \end{namelist}
2135 % \end{itemize}
2136 %
2137 % \section{Defaults}
2138 %
2139 % The following commands set the parameters for some common sources and
2140 % targets. The definitions of these commands are also useful examples.
2141 %
2142 % For A4 paper, just replace "8.5in" and "11in" in the definitions below by
2143 % the width and height of A4 paper.
2144 %
2145 % \begin{description}
2146 %
2147 % \item [$\setminus$twouparticle]
2148 %
2149 % This is the default for \LaTeX.
2150 % \begin{namelist}{Sourcexx}
2151 %
2152 % \item [Source:] A portrait document on 8.5x11 inch paper with wide margins as
2153 % used in \LaTeX's article style, and without marginal notes.
2154 %
2155 % \item [Target:] A landscape document on the same size paper, with the source
2156 % pages printed side by side.
2157 %
2158 % \item [Definition:]\hspace{1pt}
2159 % \begin{verbtm}
2160 % \target{\magstepminus1}{11in}{8.5in}
2161 % \source{\magstep0}{8.5in}{11in}}
2162 % \end{verbtm}
2163 % \end{namelist}
2164 %
2165 % If you use narrower side margins, or if you use marginal notes, then you
2166 % will need to use "\twoupplain" or \\ "\twouplegaltarget", defined below.
2167 %
2168 % \item [$\setminus$twoupplain]
2169 %
2170 % This is the default for non-\LaTeX.
2171 %
2172 % It is the same as "\twouparticle", but for source documents with narrower
2173 % margins.
2174 % \begin{namelist}{Sourcexxx}
2175 %
2176 % \item [Definition:]\hspace{1pt}
2177 % \begin{verbtm}
2178 % \target{\magstepminus2}{11in}{8.5in}
2179 % \source{\magstep0}{8.5in}{11in}
2180 % \end{verbtm}
2181 % \end{namelist}
2182 %
2183 % \item [$\setminus$twouplegaltarget]
2184 %
2185 % \begin{namelist}{Sourcexxx}
2186 % \item [Source:] A portrait document on 8.5x11 inch paper with just about any
2187 % margins and perhaps with marginal notes.
2188 %
2189 % \item [Target:] A landscape document on legal size paper (8.5x14 inches),
2190 % with the source pages printed side by side.
2191 %
2192 % \item [Definition:]\hspace{1pt}
2193 % \begin{verbtm}
2194 % \target{\magstepminus1}{14in}{8.5in}
2195 % \source{\magstep0}{8.5in}{11in}\
2196 % end{verbtm}
2197 % \end{namelist}
2198 %
2199 % \item [$\setminus$twouplandscape]\hspace{1pt}
2200 % \begin{namelist}{Sourcexxx}
2201 %
2202 % \item [Source:] A landscape document on 8.5x11 inch paper with just about any
2203 % margins.
2204 %
2205 % \item [Target:] A portrait document on the same size paper, with the
2206 % source pages stacked vertically.
2207 %
2208 % \item [Definition:]\hspace{1pt}
2209 % \begin{verbtm}
2210 % \target{\magstepminus2}{8.5in}{11in}
2211 % \source{\magstep0}{11in}{8.5in}
2212 % \targetlayout{topbottom}
2213 % \end{verbtm}
2214 % \end{namelist}
2215 %
2216 % \end{description}
2217 %
2218 %
2219 % \section{True Dimensions}
2220 %
2221 % \TeX\ lets you use `true' dimensions, as in
2222 % \begin{verbtm}
2223 % \topmargin 1truein
2224 % \setlength{\topmargin}{1truein}
2225 % \end{verbtm}
2226 % This sets the length to 1 inch
2227 % as it appears on the page, no matter what the magnification.
2228 %
2229 % Once you use `true' dimensions, it is impossible to change the
2230 % magnification of your document, and hence it is almost impossible
2231 % to use 2up.tex. You will get an error like:
2232 % \begin{verbtm}
2233 % ! Incompatible magnification (833);
2234 % the previous value will be retained (2000).
2235 % \end{verbtm}%
2236 %
2237 % The use of `true' dimensions might be hiding in macros or style files
2238 % you are using. For example, Plain \TeX's "\magnification" command uses
2239 % true dimensions; use "\mag" instead, and then set "\hsize" and
2240 % "\vsize" appropriately scaled. If you can't find the culprit `true'
2241 % dimension in your document or input files, try putting this on the
2242 % (very) first line of your document:
2243 % \begin{verbtm}
2244 % \mag 143 \voffset 1truein \mag 1000
2245 % \end{verbtm}
2246 %
2247 % You will get the error listed above wherever true dimensions are used
2248 % (and in some other places as well).
2249 %
2250 %
2251 % \section{Page Cross-References}
2252 %
2253 % Page cross-references (e.g., in an index or table of contents) will not be
2254 % accurate with "2up.tex", because finished pages are not immediately shipped
2255 % out. This can also cause problems with some special \LaTeX\ styles that have
2256 % multiple ".aux" files (e.g., for each chapter).
2257 %
2258 % To get better, but not perfect, page cross-references, try putting the
2259 % command
2260 % \begin{verbtm}
2261 % \TwoupWrites
2262 % \end{verbtm}
2263 % at the beginning of your document, after inputting "2up.tex". This is good for
2264 % drafts, and may fix problems with \LaTeX\ styles that have multiple ".aux"
2265 % files. "\TwoupWrites" makes "\write" and "\read" "\immediate", if you know
2266 % what that means. It might cause problems of its own, but try it and see.
2267 %
2268 % To get accurate page cross-references:
2269 % \begin{enumerate}
2270 % \item Run the job without "2up.tex", until all cross-references
2271 % are properly resolved. Run any index utility at this point.
2272 %
2273 % \item Run the job ONE MORE TIME with "2up.tex"; it will use the
2274 % correct cross-references from the previous runs. (In \LaTeX\ documents,
2275 % it is useful at this point to include the "\nofiles" command, so that
2276 % the correct cross-references are preserved.)
2277 % \end{enumerate}
2278 %
2279 % \section{Booklets\label{booklet}}
2280 %
2281 % Here are some special considerations for making booklets:
2282 %
2283 % \begin{itemize}
2284 %
2285 % \item Use the "booklet" target layout if your printer or copier cannot print
2286 % two
2287 % sides directly. "2up.tex" prints out the ``tops'' of the pages, and then the
2288 % ``bottoms'', so that you can copy or print on both sides by doing one side,
2289 % flipping the output over, and doing the other side.
2290 %
2291 % \item Use "Booklet" if your printer or copier can print directly on two sides.
2292 %
2293 % \item You must have enough memory and box registers to hold all the pages in
2294 % the document. A Big\TeX\ should be able to handle at least a 32-page booklet.
2295 %
2296 % \item Sometimes booklet printing is part of the design of a document, rather
2297 % than an afterthought. In this case, you should set up the margins for the
2298 % target half-page rather than using "2up.tex" to scale the document. For
2299 % example, if using \LaTeX, 8.5x11 inch paper, \LaTeX's twoside style option,
2300 % and headings, try the following page parameter changes:
2301 % \begin{verbtm}
2302 % \setlength{\oddsidemargin}{-0.2in}
2303 % \setlength{\evensidemargin}{-0.5in}
2304 % \setlength{\textwidth}{4.2in}
2305 % \setlength{\textheight}{6.5in}
2306 % \setlength{\topmargin}{-.4in}
2307 % \end{verbtm}
2308 % If you do this, "2up.tex" isn't adjusting margins or scaling the
2309 % document. You coould therefore get by without "2up.tex" by using "dvidvi".
2310 % \end{itemize}
2311 %
2312 % \section{Using dvidvi\label{dvidvi}}
2313 %
2314 % With the "dvidvi" layout option, "2up.tex" takes care of adjusting the
2315 % margins, and you then use "dvidvi" to arrange the pages in a two-up
2316 % format. The advantage is that cross referencing comes out right.
2317 % The disadvantage is that it involves one more step.
2318 %
2319 % Start by \TeX ing your document with "2up.tex" and the "dvidvi" layout option.
2320 % Then run the dvi file through "dvidvi". Specify the offsets for "dvidvi" at
2321 % the middle of the page. E.g., for
2322 % a side-by-side layout on 8.5x11in paper, use
2323 % \begin{verbtm}
2324 % dvidvi '2:0,1(5.5in,0in)' foo bar
2325 % \end{verbtm}
2326 % For other paper sizes, replace "5.5in" by half the target paper width. For the
2327 % "topbottom" layout, reverse the dimensions, e.g.,
2328 % (0in,5.5in). For booklet printing, see the
2329 % the documentation for "dvidvi".
2330 %
2331 %
2332 % \section{Compatibility\label{compatibility}}
2333 %
2334 % These macros should work with most \TeX\ macro packages, except for
2335 % the following possible but unlikely compatibility problems:
2336 %
2337 % \begin{itemize}
2338 %
2339 % \item If you use a macro package other than \LaTeX\ that does unusual things
2340 % to end a document and/or that modifies the definition of "\end", you may
2341 % find that the last page is nor printed or that an extra page with headings
2342 % is inserted at the end of the document. This is fixable on a case-by-case
2343 % basis. See the redefinition of "\end" in "2up.tex".
2344 %
2345 % \item "2up.tex" might not work if you meddle with \TeX's "\shipout" primitive
2346 % after loading "2up.tex".
2347 %
2348 % \item If the first page of the source document is not on the first two-up
2349 % target
2350 % page (possible, for example, with two-sided printing and the "booklet"
2351 % option, but generally unlikely), "\special"'s that come at the beginning
2352 % of the document also do not get onto the first page of output. This can mess
2353 % up "\special"'s for landscape printing or
2354 % including a PostScript header file. In this case, you have to specify
2355 % these things as command line options when using your dvi driver.
2356 %
2357 % \end{itemize}
2358 %
2359 %
2360 % \section{Changes}
2361 % \begin{namelist}{V0.9xxx}
2362 % \raggedright
2363 %
2364 % \item [V0.9a] Everything redone. Too many differences to point out.
2365 %
2366 % \item [V0.9b] Interface redone again. "booklet" option added.
2367 %
2368 % \item [V0.9c] Pages ship out a little earlier. A few bugs fixed.
2369 %
2370 % Parameters "\pageseplength" and "\pagesepthickness" added.
2371 %
2372 % \item [V0.9d] Fixed bug with "\twoupclearpage" and "\twoupeject".
2373 %
2374 % \item [V0.9e] Made pages be counted (from dvi driver's viewpoint) by the
2375 % physical page number.
2376 %
2377 % \item [V0.9f] Parameter "\pagesepoffset" added, and "\pagesepthickness"
2378 % changed to "\pagesepwidth".
2379 %
2380 % \item [V1.0] None. Just seemed seemed like it was time to call it 1.0
2381 %
2382 % \item [V1.1] Added "Booklet" and "dvidvi" target layouts.
2383 %
2384 % "\hoffset" and "\voffset" in source document now have expected effect.
2385 %
2386 % \item[V1.2] Fixed incompatibility problem with AmS-\TeX/AmS-\LaTeX.
2387 %
2388 % Added "\TwoupWrites" command.
2389 %
2390 % \end{namelist}
2391 % \end{document}
2392 % % END 2up.doc
2393 %
2394 % \end{verbatim}
2395 %
2396 % I used a slightly modified version of \file{2up.doc} as one of the
2397 % test documents for the \Lpack{booklet} package. First, to get a baseline,
2398 % I followed the instructions in \file{2up.doc} and edited and printed
2399 % it using \Lpack{2up} to get a booklet.
2400 %
2401 % I then copied \file{2up.doc} to \file{2updoc.tex} and then edited
2402 % the new file so that the first part of the preamble became:
2403 % \begin{verbatim}
2404 % %% BEGIN 2updoc.tex
2405 % %% ....
2406 % \documentclass[12pt,twoside]{article}
2407 % \usepackage[print,four]{booklet} % change options to suit
2408 % \usepackage{ifpdf} % from CTAN
2409 %
2410 % \ifpdf
2411 % \pdfoutput=1
2412 % \setpdftargetpages
2413 % \else
2414 % \checkforlandscape
2415 % \ifuselandscape
2416 % \special{dvips}
2417 % \ifprintoption
2418 % \special{!TeXDict begin <</Duplex true /Tumble true>> setpagedevice end}
2419 % \fi
2420 % \fi
2421 % \fi
2422 %
2423 % \def\FileDate....
2424 % ...
2425 % \iffalse
2426 % \input 2up.tex
2427 % ...
2428 % % \fi and \makeatletter were here
2429 % %% PAGE NUMBERING:
2430 % ...
2431 % \@ifundefined{target@stop}...
2432 % \fi % this \fi and \makeatletter moved down from before NUMBERING
2433 % \makeatletter
2434 %
2435 % %% CONTENTS % no changes after this
2436 % ...
2437 % \end{verbatim}
2438 %
2439 % Processing, printing and folding this to make a booklet enabled me to
2440 % determine if the package effectively produced the same final result
2441 % as \Lpack{2up}.
2442 %
2443 %
2444 % \Finale
2445 % \PrintIndex
2446 %
2447 \endinput
2448
2449 %% \CharacterTable
2450 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
2451 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
2452 %% Digits \0\1\2\3\4\5\6\7\8\9
2453 %% Exclamation \! Double quote \" Hash (number) \#
2454 %% Dollar \$ Percent \% Ampersand \&
2455 %% Acute accent \' Left paren \( Right paren \)
2456 %% Asterisk \* Plus \+ Comma \,
2457 %% Minus \- Point \. Solidus \/
2458 %% Colon \: Semicolon \; Less than \<
2459 %% Equals \= Greater than \> Question mark \?
2460 %% Commercial at \@ Left bracket \[ Backslash \\
2461 %% Right bracket \] Circumflex \^ Underscore \_
2462 %% Grave accent \` Left brace \{ Vertical bar \|
2463 %% Right brace \} Tilde \~}
2464
2465