Debian Codegraph @

texmf-dist/doc/generic/midnight/quire.doc

raw
1 % quire.doc --- version 1.0 (19 January 1991)
2 % This is the documentation for quire.tex.
3 % To read this file, process it with (plain) TeX: tex quire.doc
4 % (To do that, you need manmac.tex, which has
5 % the macros for typesetting the TeXbook, as explained in appendix E.
6 % It comes free with the standard distribution of TeX.)
7 %
8 % NOTE: Processing this file with TeX will create empty files
9 % index.tex and answers.tex in your directory. And if you
10 % have a file pages.tex in your directory, TeX will probably
11 % get very confused.
12 % The manmac format will try to load a font called cmman; if
13 % TeX complains that it cannot find that font you can savely
14 % ignore that, since the font is not actually used.
15 %
16 % This file: copyright (c) 1991 Marcel van der Goot.
17 % You may redistribute this file and printed versions of it.
18 %
19 % original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex
20 % (use anonymous ftp). Also in various archives.
21 %
22 % Marcel van der Goot
23 % [email protected]
24 % Caltech 256--80
25 % Pasadena, CA 91125
26 % (818) 356--4603
27
28 % Doc history:
29 % 10 Sep 1991: Added note about using \nofiles in LaTeX.
30 % 10 Jan 1991: First public version
31
32 % ------ definitions for manual pages:
33 % The documentation is typeset using Knuth's ``manmac'' macros, with a
34 % few additional things defined here. You are free to use or adapt these
35 % extra definitions.
36
37 \input manmac % the macros used for typesetting The TeXbook (appendix E)
38 \catcode`^=7 % manmac makes ^ active for creating an index
39 % we don't make an index, and we need ^ to be non-active
40
41 {\catcode`\^^M=12 \endlinechar=-1 % 12 = other
42 \long\gdef\manpagehead#1^^M#2^^M#3^^M^^M% tex-file, description, version
43 {\egroup % matches \bgroup in \manpage
44 \par\vfill\eject
45 \edef\rhead{\manualname: #1\unskip}%
46 \setbox1=\hbox{\titlefont #1\quad}%
47 \setbox3=\vtop{\advance\hsize by-\wd1 \parindent=0pt \raggedright
48 #2\par
49 #3\par
50 \cnotice
51 }%
52 \line{\box1\box3}%
53 \bigskip\bigskip\bigskip\noindent
54 }%
55 } % restore \catcode`\^^M
56
57 \outer\def\manpage
58 {\bgroup\catcode`\^^M=12
59 \manpagehead
60 }
61
62 \hsize=6.5in\vsize=8.9in % default plain TeX values
63 \pagewidth=\hsize \pageheight=\vsize
64
65 \def\cnotice{Copyright \copyright\ 1991 Marcel R. van der Goot}
66 \def\manualname{Midnight Macros}
67
68 % LaTeX logo, from latex.tex (except for the capital `A': manmac
69 % doesn't have a real smallcaps font)
70 \def\LaTeX{{\rm L\kern-.36em\raise.3ex\hbox{\sc A}\kern-.15em
71 T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
72
73 \tenpoint
74
75 % (end of extra definitions)
76
77 % -------------------- quire.doc:
78
79
80 \def\picpage#1% single white page with page number
81 {\vbox to 2.7cm{\vskip 0pt plus 5fil
82 \hbox to 2.2cm{\hss #1\hss}%
83 \vskip 0pt plus 1fil
84 }%
85 }
86
87 \def\fold
88 {\hbox to 0pt{\hss
89 \vbox to 2.7cm{\vss
90 \hrule height3mm depth0pt width0.5pt
91 \vss\vss
92 \hrule height3mm depth0pt width0.5pt
93 \vss
94 }%
95 \hss
96 }}
97
98 \def\picdblpage#1#2% two pages with outlines and fold
99 {\vbox{\hrule
100 \hbox{\vrule
101 \picpage{#1}\fold\picpage{#2}%
102 \vrule
103 }%
104 \hrule
105 }%
106 }
107
108 \pageno=1 % first set of the ``Midnight Macros''
109
110 \manpage quire.tex
111 Macros for making booklets, printing double pages, and printing outlines %
112 and crop marks.
113 Version: 1.0 (19 January 1990) (doc: 10 Sep 1991)
114
115 A quire is a ``set of folded sheets (as of a book)
116 fitting one within another'' [Webster's].
117 Such a set of sheets forms a little booklet. Larger books usually consist
118 of a number of quires, with 20 to 40 pages each. The macros
119 in quire.tex help you to turn your own texts into such booklets. (The
120 macros can also be used for some other things, such as printing crop
121 marks.) Quire.tex is designed to minimize the interference with other
122 macro packages, so that, for instance, it can be used with plain \TeX\
123 as well as with \LaTeX. You do not need any special programs or special
124 equipment to print quires, but it is convenient if you can print pages
125 in ``landscape mode.'' Whether you can print in landscape mode depends
126 on your device driver and printer (most printers support this), it is
127 outside the control of \TeX. The reason for using landscape mode is that,
128 because sheets are folded, two pages have to be printed next to each other
129 on the same sheet. In ``portrait mode'' this allows only very narrow pages.
130 Making quires is
131 easier if you have a large version of \TeX\ (i.e., one with lots of memory).
132
133 Before we explain what the macros do, let us emphasize what they do not do.
134 Quire.tex does {\sl not} change the layout of your pages, look at page numbers,
135 print odd and even pages differently, or print small pages. These are all
136 things that you have to take care of with other macros or style files.
137 What quire.tex does is to take your pages, reorder them, print two per
138 sheet, and draw outlines around them. As an example, assume we want
139 to make a booklet consisting of five sheets folded together. With two
140 pages next to each other, and with double sided printing, this gives
141 us a booklet consisting of 20 pages. The first page of the five folded
142 sheets is page 1. When we open the booklet we get page 2,
143 printed on the back of the same sheet as page 1. Page 2 occupies the
144 left-hand side of that sheet. The page on the right-hand side is
145 not page 3, which is printed on the next sheet, but page 19. This reordering
146 of pages is the main task of quire.tex. For this example, the following
147 figure depicts two of the sheets generated by quire.tex (these
148 are the last two sheets that are generated).
149
150 \goodbreak\midinsert
151 \line{\hss\picdblpage{20}{1}\hss\picdblpage{2}{19}\hss}%
152 \endinsert
153
154 Once again, quire.tex does not look at the page numbers you print.
155 What we call here ``page 1'' is simply what the first page of output
156 would be if you were not using quire.tex. To make a booklet, the two double
157 pages in the figure should be printed on the opposite sides of the same sheet
158 of paper. There are two ways of doing that. One is to print all the
159 sheets and then use a photocopier to make double sided prints. The second
160 is to print all even sheets, walk to your printer and reinsert the
161 stack of printed sheets upside down, then print all the odd sheets.
162 Many device drivers can be instructed to print only even or odd sheets.
163 But in case your installation does not support this, you can say
164 |\shonly1| at the beginning of your file to instruct quire.tex to only
165 generate odd sheets; |\shonly2| generates only even sheets; and |\shonly0|,
166 which is the default, generates both.
167
168 Before you can use any of the macros, you have to
169 |\input quire|\footnote*{Although quire.tex can be used with \LaTeX,
170 we have made no attempts to \LaTeX ify the macros. So yes, in \LaTeX\ you
171 use the macros exactly as described here.}. Then
172 you give values to some of the parameters (which are discussed later),
173 and you can call, for instance, |\quire|. All of this should be done
174 preceding the actual text of your file; in \LaTeX\ all of this should
175 be put in the preamble. If you are using \LaTeX, you must say
176 |\latexquire| somewhere in the preamble, regardless of
177 what other macros you are using.
178 The macro |\quire| is used to start typesetting
179 of a quire. It takes one argument, the number of pages in the quire.
180 Hence you have to \TeX\ your document at least once before you use
181 |\quire|, to determine the number of pages. That also helps to separate
182 errors in your input from problems caused by quire.tex. Say your document
183 consists of 19 pages, numbered 1\dots19. When you say
184 \begintt
185 \quire{19}
186 \endtt
187 \TeX\ will produce 10 sheets. The first one is sheet 10 with pages 10 and 11,
188 the second is sheet 9 with pages 12 and 9, etc. The last sheet has pages
189 20 and 1, where page 20 is blank.
190
191 This example illustrates that if there are not enough pages for a complete
192 quire, \TeX\ will insert empty pages at the end of your text.
193 If, on the other hand, there are more pages than fit in a quire,
194 \TeX\ will just generate more than one quire. For instance,
195 a 250-page book can be printed in 13 quires with |\quire{20}|.
196 The mechanism through which \TeX\ supplies extra blank pages at the end
197 of your text is called \TeX's ``endgame.'' These extra pages
198 are passed to \TeX's output routine, which usually means
199 that they will have headlines and footlines. You can bypass the output routine
200 by saying |\endquire| at the end of your text, in which case the blank
201 pages will really be blank pages (you can say |\endquire| even if you are
202 not using |\quire|). In \LaTeX\ you should {\sl not} use
203 |\endquire|, it is implied by the |\end{document}| that terminates your file.
204 Sometimes you may want to start your text with an empty page. Here are
205 two simple ways of generating an empty starting page (in plain \TeX).
206 \begintt
207 \line{}\vfill\eject % or:
208 \shipout\vbox{}
209 \endtt
210 The method with |\shipout| bypasses the output routine.
211
212 Let us turn to the parameters that determine the output of quire.tex.
213 You have to take care that you indeed generate small pages.
214 The page size is normally determined by |\hsize| and |\vsize|, but
215 depending on the macro package you are using, other parameters may
216 also be important. However, quire.tex does not look at the values of these
217 parameters, they only serve to determine the size of the text area (i.e.,
218 the printed part of the page). In the following, ``page'' refers to
219 the small pages you print, ``sheet'' refers to the actual sheets of
220 paper. We start with the parameters related to pages, which are all
221 dimen parameters.
222 First there are |\htotal| and |\vtotal|, which should be
223 equal to the horizontal and vertical size of the small pages you want.
224 For instance, a pocket book has
225 $|\htotal| \approx$ 10.5 cm, $|\vtotal| \approx$ 17 cm. Then there are
226 |\horigin| and |\vorigin| which describe the ``natural'' offset of the
227 text area from the top left corner of the page. These offsets are added
228 to the \TeX\ offsets |\hoffset| and |\voffset|. You may wonder why
229 there are four parameters to describe the offsets, \TeX\ itself only
230 has the latter two. The reason is that, unfortunately, \TeX\ has built in
231 extra offsets of 1 inch. That may be right for American ``letter'' size
232 paper, but on smaller pages it is generally too
233 much. To make scaling of these offsets possible we had to introduce
234 two extra parameters for them.
235
236 The names of parameters related to sheets all start with \hbox{``|sh|''};
237 all but one are dimen parameters.
238 Quire.tex draws a number of lines to denote where the actual pages
239 are on the sheet. As in the previous figure, lines are drawn around
240 pairs of pages. The width is |\shoutline|, so you can make them disappear
241 with |\shoutline=0pt|. The two pages are separated by two ``staples,''
242 with width |\shstaplewidth| and length |\shstaplelength|. You can make
243 them disappear by making the width |0pt|; setting the length to
244 |0.5\vtotal| will give you a solid line instead of two staples.
245 The outlines are drawn exactly around the pages, the staples on top
246 of the two pages. The widths of these lines does not influence the
247 width of the pages. Finally, quire.tex draws ``crop marks'' of width
248 |\shcrop|. Crop marks are lines that indicate the outlines and center
249 of the pages, without actually touching the pages. When you are cutting
250 the paper, crop marks are sometimes more convenient than outlines.
251 The crop marks are drawn so that, if they were extended, they would
252 just be on the page. So they fall within the outlines that are drawn,
253 which is easily observable if you make the widths excessive, say 1 cm.
254
255 The distance of the top of the sheet to the top of the pages is
256 |\shvoffset| plus 1 inch. The pages are centered horizontally,
257 therefore there is no parameter for horizontal offset.
258 Under the pages, a footline is printed. The footline is determined
259 by token register |\shfootline|. By default the sheet number and the
260 numbers of the two pages are printed (more about page numbers later),
261 as well as the filename.
262 The next paragraph explains the remaining four parameters,
263 but if you are lucky you don't have to
264 set them yourself: They describe the printer you are using, so they
265 need only be determined once. Your local installation may have
266 macros that set these parameters automatically. Local macros are
267 described at the end of this manual section.
268
269 \danger In order to center the pages, |\shhtotal| must be set to the
270 horizontal size of the sheets. The size is usually not a nice number,
271 like 8.5 inch (216 mm), but more likely
272 something like 220.1 mm. It is important to get this size right, since
273 double sided printing requires properly centered pages. You probably
274 have to experiment a bit with double sided pages to get this right,
275 because often the printer introduces small inaccuracies.
276 If a photocopier is used to turn single sided print into double sided print,
277 you may need the parameters |\shhcorrection| and |\shvcorrection|.
278 These denote extra offsets which are applied to odd numbered sheets only,
279 to compensate for shifts introduced by ``smart'' copiers.
280 |\shhcorrection| can sometimes be used to compensate for a wrong value
281 of |\shhtotal|, but the author recommends that |\shhtotal| is set
282 properly for the printer, and that the correction offsets are only used
283 for copiers. If you take a stack of sheets and fold them, the
284 outer sheets will have a longer way to go around the bend than the
285 inner ones. In an attempt to compensate for that, the pages on each
286 sheet are shifted
287 outwards with respect to the pages on the next inner sheet, by an
288 amount equal to |\shthickness|. Naturally, this parameter should have a
289 rather small value.
290
291 Consider printing a quire of 20 pages. The first sheet that can be
292 printed is sheet number 10 with pages 10 and 11. That means that
293 \TeX\ has to store 10 complete pages in memory. If your \TeX\ version
294 is small, there may not be enough memory for this, resulting in
295 an error message
296 \begintt
297 TeX capacity exceeded, sorry.
298 \endtt
299 Luckily, there are some ways to reduce the number of pages that have to
300 be stored. We already mentioned the use of |\shonly| to restrict
301 output to odd or even sheets only. Doing that halves the number of
302 pages that have to be stored. If that is not enough, you
303 can use the macro |\makequire| instead of |\quire|. |\makequire|
304 takes three arguments. The first argument is the same as for |\quire|,
305 namely the number of pages per quire. Let $s$ and $r$ be the second
306 and third arguments, respectively. Let $n$ be the number of a sheet
307 in the first quire. Then that sheet is only printed if
308 $s \leq n < s+r$ (and similarly for following quires).
309 This means that at most $r$ pages need to be stored
310 (or about half that if you also use |\shonly|). As an example, our
311 20 page quire can be printed in three runs with, respectively,
312 \begintt
313 \makequire{20}{1}{4}
314 \makequire{20}{5}{4}
315 \makequire{20}{9}{4}
316 \endtt
317 The runs result in sheets 4\dots 1, 8\dots 5, and 10\dots 9. In the
318 last run, the range $r$ is larger than the actual number of sheets,
319 but that causes no problems. Also, sheet $s$ need not exist. In fact,
320 |\quire{20}| is just an abbreviation for |\makequire{20}{0}{1000}|.
321
322 For previewing it is often inconvenient to use |\quire|, because of
323 the reordering of pages. But you may still want to see how your
324 text fits on the smaller pages. There are two macros which you
325 can use instead of |\quire|. |\qtwopages| prints two pages per sheet,
326 just like quire, but does not reorder the pages. All parameters mentioned
327 before remain valid, except for |\shthickness|. Of course, you can also
328 use this if you are not previewing a quire.
329 For instance, if you have appropriately scaled
330 fonts and you print in landscape mode, the following preamble
331 will print your file two pages per sheet.
332 \begintt
333 \input quire
334 \mag=500 % works in LaTeX too
335 \qtwopages
336 \endtt
337 Finally, there is |\qonepage|, which prints just one page per
338 sheet as usual. It does however draw outlines (no staples) and crop marks,
339 and |\shonly| can also be used.
340
341 We claimed that quire.tex would work together with most other
342 macro packages. But there is one type of macro that doesn't go well
343 with quires, and usually you will have to switch them off when you
344 are typesetting a quire. \TeX's primitives for file handling, such
345 as |\write|, are only performed when a page is actually shipped out.
346 That is often used for the creation of an index or a contents page,
347 in order to get the page numbers right. But quire.tex prints two pages
348 per sheet, and a sheet has only one ``page number,'' so that such
349 methods will most likely get all the page numbers wrong. Worse,
350 the pages are shipped out in an unusual order, so that for instance
351 a |\write| may take place before the file has been opened. Therefore,
352 you should avoid generation of an index or contents page when you are using
353 |\quire|. In \LaTeX\ this is done by inserting |\nofiles| in the preamble.
354 (For all but the final run you can use |\qonepage|, which
355 does not change the page numbers.) Of course, if you want your booklet
356 to start with a contents page, then that page has to be generated before
357 the final \TeX\ run, since you cannot just rearrange the printed pages.
358
359 In |\shfootline|, |\pageno| refers to the sheet number (if you are
360 using plain \TeX's definitions); |\firstpageno| is the number
361 of the first of the two pages (i.e., the page that was finished first,
362 that can be either the left-hand or the right-hand page), and |\secondpageno|
363 is the number of the other page. These three numbers are also shipped
364 to the |dvi| file, as |\count0|, |\count1|, and |\count2|, respectively.
365 When a page is finished but not yet printed on a sheet, the page number
366 is displayed on your terminal between parentheses, as in |[(1)]|.
367 When sheet number 7 with pages 11 and 14 is finished, |[7.11.14]| is
368 displayed.
369
370 \ddanger Quire.tex does its job by redefining |\shipout|. Since |\shipout|
371 is a \TeX\ primitive, such redefinition is not recommended; normally one
372 would redefine the output routine instead. However,
373 important parts of the typesetting of a text are often done in the
374 output routine, which may well be different for different pages of
375 a book. Since quire.tex is supposed to handle the whole book, and since
376 it only handles complete pages without changing
377 their layout, it seemed that in this particular case redefinition of
378 |\shipout| was justified. The new |\shipout| can be used in the same
379 way as the original one, except that you should not try to ship out a
380 void box (which is a pretty meaningless thing to do anyway).
381 Doing that will most likely result in a, seemingly unrelated,
382 error message somewhere later in the text. The dangers of using
383 |\openout|, |\closeout| and |\write|, without |\immediate|, were
384 already explained. Like these file operations, |\special| works
385 with ``whatsits'' which are handled when the page is shipped out.
386 But as the argument of |\special|
387 is expanded immediately, rather than when the page is shipped out, this
388 is less likely to cause problems.
389
390 \ddanger Quire.tex uses mostly \TeX's primitives, but also a few
391 macros defined in plain.tex. The latter are |\newbox|, |\newcount|,
392 |\newdimen|, |\newif|, |\newtoks|, |\nointerlineskip|, and
393 |\offinterlineskip|, none of which are likely to be redefined by
394 other macros. As mentioned before, quire.tex relies on \TeX's endgame
395 to generate complete quires. Although the endgame is built in,
396 a really devious macro package may disable it.
397 This is in fact exactly what happens in \LaTeX's |\end| command,
398 which is why we need |\latexquire| (which inserts an implicit
399 |\endquire| at the end of the text).
400
401 % Note: The next subsection serves as example only. Do NOT change it, even
402 % if you have different local definitions. Change the local definitions
403 % in the file quire.tex, and see below.
404 \subsection Printer definitions. It is convenient if the parameters
405 that depend (only) on the
406 printer are predefined. As an example, here are some of the
407 local definitions for the author's installation. When someone
408 wants to use the printer called ``maser,'' all he or she has to
409 do to set up those parameters is to say |\Pmaser| or
410 |\Pmaserlandscape|. Note that this does not put any information in the
411 |dvi| file, the user is still responsible for printing on the correct
412 output device. There are similar definitions for other available printers.
413 The next subsection lists the local definitions for your installation,
414 if any.
415
416 \beginlines
417 |\def\Pmaser|
418 | {\shhtotal=220.02true mm|
419 | \shthickness=0.21true mm|
420 \goodbreak
421 | \message{maser: flip paper so that short sides remain in place, %|
422 | align closest right-hand corner in tray.}%|
423 | }|
424 \medskip
425 |\def\Pmaserlandscape|
426 | {\shhtotal=281true mm|
427 \goodbreak
428 | \shthickness=0.21true mm|
429 | \message{maser landscape: ...}|
430 | }|
431 \endlines
432
433 % Note: If you have your own local definitions, change the following
434 % subsection.
435 \subsection Local Caltech definitions. The following macros will set
436 the appropriate printer parameters: |\Pmaser|, |\Pmaserlandscape|,
437 |\Plaser|, |\Plaserlandscape|, |\Phaser|, |\Phaserlandscape|,
438 |\canon| (for the copier). For double-sided printing on maser, flip
439 the pages so that the short edges remain in place. Align the closest
440 right-hand corner in the tray. But for printing in landscape mode,
441 flip the pages so that the long edges remain in place. On haser, you
442 should rotate the pages 180$^\circ$, but keep the text side up. You
443 have to reorder the pages (or print the second time with |gtex -t|). Haser
444 seems to have problems keeping the paper straight, which makes
445 double-sided printing hard.
446
447
448 \bye