Debian Codegraph @

texmf-dist/doc/otherformats/lollipop/manual/out.tex

raw
1 % out.tex copyright 1992/3 Victor Eijkhout
2 % copyright 2014--2016 Vafa Khalighi
3 %
4 %
5 % This program is free software: you can redistribute it and/or modify
6 % it under the terms of the GNU General Public License as published by
7 % the Free Software Foundation, either version 3 of the License, or
8 % (at your option) any later version.
9 %
10 % This program is distributed in the hope that it will be useful,
11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 % GNU General Public License for more details.
14 %
15 % You should have received a copy of the GNU General Public License
16 % along with this program. If not, see <http://www.gnu.org/licenses/>.
17 %
18 %
19 \Chapter[chap:output] Output
20
21 Every page is formatted according to a `page grid' consisting of
22 three elements:
23
24 \Enumerate \item the page head, this is everything that's over the
25 running text;
26 \item the page foot, this is everything that is below the running
27 text;
28 \item the running text. \TeX\ acts as if text is on a long scroll,
29 and the running text part of a page is simply a portion cut off from
30 this scroll.\>
31 Either or both of the head and foot of the page can be empty, but
32 usually one of the two contains a page number.
33
34 \OutExample
35 \OptionsMacro:ManPageSize=raggedbottom:10pt topskip:12pt
36 height:page=5cm width:page=6cm Stop
37 \DefinePageGrid:TestPage macro:ManPageSize
38 pagerule textband:start text textband:stop
39 pagerule band:start PageCounter band:stop Stop
40 \TestPage
41 This page does not contain much special.\EjectPage
42 This page is hardly better.
43 \OutExampleStop
44
45 This example illustrates how you first define a page grid by
46 \refcs{DefinePageGrid}, and then activate it by calling its name. That
47 last action is in fact not necessary: each definition of a page grid
48 automatically installs that grid as the current one.
49
50 \Section Page dimensions
51
52 Most of the time it is easiest to specify the total height of a page,
53 that is, including head and bottom, but sometimes it is more
54 convenient to specify the height of the text, and let the head and
55 foot simply go over and under that.
56
57 In the first case you can give the command \refcs{Height} with
58 two parameters:
59 \Ver>\Height:Page=23.5cm<Rev or inside a page grid definition the
60 option \refopt{height}\n{:page=...}.
61
62 In the second case you can give the command
63 \Ver>\Height:Text=19.55cm<Rev or inside a page grid definition the
64 option \opt{height:text=...}.
65
66 In page grid definitions there is the additional option
67 \opt{height:lines=23}.
68
69 The \cs{Height} command cannot be used in a page grid definition.
70
71 \Section Positioning the page on the paper
72
73 If your printer driver is up to specs (and you have not done any
74 creative macro writing) it should have the upper left corner of the
75 text landing at $2.54$cm from the top and left side of the paper.
76 If the result is not to your liking, you can shift the page by
77 \Ver>\Distance:hoffset= ...
78 \Distance:voffset= ...<Rev
79 These offset parameters are zero ordinarily, and they indicate the
80 extra shift added to the customary $2.54$cm in horizontal and
81 vertical direction.
82
83 \Section Page head, foot, text
84
85 Somewhere in the page grid the option \refopt{text} has to appear. This
86 option has to be inside a \refopt{textband}:
87 \Ver> textband:start text textband:stop<Rev
88 This is not a case of overspecification, because inside a textband
89 the text option can appear more than once. In this manner a multicolumn
90 page grid can be specified.
91
92 \def\sometext{Just a bit of words, words. }
93 \edef\sometext{\sometext\sometext\sometext}
94 \edef\sometext{\sometext\sometext\sometext\sometext}
95 \OutExample
96 \DefinePageGrid:TestPage macro:ManPageSize
97 pagerule textband:start text hwhite:10pt text textband:stop
98 pagerule band:start PageCounter band:stop Stop
99 \FlushRight:no \sometext
100 \OutExampleStop
101
102 Next to the option \opt{textband} there is \refopt{band}.
103 Both are ways of
104 creating a page wide band. The option \opt{band} is used for all
105 material that is not a text column, for instance footers, as in the
106 above examples.
107
108 The option \opt{band} can have one unusual parameter: \n{invisible}.
109 This makes the band act as if it has zero height or width, depending
110 on whether it is below or above the text, respectively.
111
112 \OutExample
113 \DefinePageGrid:TestPage macro:ManPageSize
114 pagerule textband:start text hwhite:10pt text textband:stop
115 pagerule
116 band:invisible block:start Style:bold PageCounter Spaces:2
117 stickout:left band:stop Stop
118 \FlushRight:no \sometext
119 \OutExampleStop
120
121 \SubSection More about text bands
122
123 The text band is that part of the page that has the text in it. You can
124 also put other material in it, such as rules or white space.
125
126 \OutExample
127 \DefinePageGrid:TestPage macro:ManPageSize pagerule
128 textband:start vrule white:3pt text white:3pt vrule textband:stop
129 pagerule band:start white:fillup PageCounter band:stop Stop
130 \TestPage This page contains some text, a bit more text,
131 and even more than that. In all still just a few lines.\EjectPage
132 This page contains more text, still more text, and still more.
133 \OutExampleStop
134
135 In the previous example the width of the page was specified.
136 If we only give the width of the text, the page width is calculated
137 dynamically.
138
139 \OutExample
140 \DefinePageGrid:TestPage macro:ManPageSize
141 textband:start vrule white:3pt text white:3pt vrule textband:stop
142 pagerule band:start white:fillup PageCounter band:stop Stop
143 \noindent This page contains some text, a bit more text,
144 and even more than that. In all still just a few lines.\EjectPage
145 This page contains more text, still more text, and still more.
146 \OutExampleStop
147
148 Note how the \refopt{pagerule} and \opt{band} objects stretch
149 with the page.
150
151
152 \SubSection Topskip
153
154 In between the page head and the text is some white space, the
155 topskip, with special properties. The topskip is defined from the
156 bottom of the head to the bottom of the first line of the text. If
157 the height of this first line varies from page to page the topskip
158 acts as a buffer, keeping the bottom-to-bottom distance constant.
159
160 Topskip is set by the option \refopt{topskip}, for example
161 \Ver> topskip:25pt<Rev
162 but if this option is left out, the page grid uses the value of
163 \cs{topskip} that was current at the time of the definition.
164 Unfortunately there is no way to change this value after the definition.
165
166 \Section[sec:page-counter] The page number
167
168 The page number behaves as if it had been defined by
169 \Ver>\NewCounter:Page
170 \CounterRepresentation:Page=1<Rev
171 Thus you can use any command from section~\ref[sec:counters] on it.
172 For instance, you can have page numbers in roman numerals by
173 specifying
174 \Ver>\CounterRepresentation:Page=I<Rev
175
176 The page number is typically used as the option \refopt{PageCounter},
177 but for some applications the corresponding command \refcs{PageCounter}
178 can be used.
179
180 If you process a \Lollipop\ document you see that everytime a page is
181 generated, an item such as \ver>[8,7]> is written on the log file or the
182 screen. Most of the time the two numbers will be the same, as in
183 \ver>[8,8]>, but they will differ if you have tinkered with the page
184 number. The first number is the `sheet counter': it counts how many
185 pages you have produced so far. The second number is the value of
186 \cs{PageCounter} for the page that was written out. Take a look at the
187 log file for this manual for an example.
188
189 \Section[sec:page:tests] Page tests
190
191 The page grid definition can set/query several properties of the
192 page. The following tests have been provided (see
193 section~\ref[sec:tests] for tests):
194 \Ver>\DefineTest:IsRightPage
195 \DefineTest:IsLeftPage
196 \DefineTest:FirstPage
197 \DefineTest:LastPage
198 \DefineTest:FlushBottom<Rev
199 \Itemize\item The tests for left/right pages are done by
200 testing whether the page number of odd or even.
201 \item The first/last page tests can be used either for the whole
202 document, or for a file that's loaded as an \cs{InputFile}.
203 \item The first page test doesn't work at present.
204 \>
205
206 \OutExample
207 \DefinePageGrid:TestPage macro:ManPageSize
208 pagerule textband:start text textband:stop pagerule
209 band:start ifIsLeftPage else hwhite:fillup fi PageCounter
210 band:stop Stop \SetCounter:Page=12
211 This is a left hand page. \EjectPage
212 This page is on the right side of a spread.
213 \OutExampleStop
214
215 \Section[sec:head/foot] Running heads / footers
216
217 Above it was explained how pages can be given a head and foot part.
218 Quite often you want changing information in such parts, for instance
219 the head of a left page often contains the number or title of section
220 that was current when that page started; the head of a right page
221 often contains the number or title of the section that was current
222 when that page ended.
223
224 In \Lollipop\ all constructs that have a title or a counter can have
225 that information referenced in page grids.
226 \Description\item \refcs{FirstPlaced}:SectionTitle
227 Take the title of the first section that started on this page, or
228 the last one that started before this page if no section started on
229 this page.\item \refcs{LastPlaced}:SubSectionCounter
230 Take the title of the last subsection that started on this page, or
231 the last one that started before this page if no subsection started
232 on this pgae.\item \refcs{PreviousPlaced}:SectionCounter
233 Take the counter value of the last section that started before this
234 page.\>
235
236 \OutExample
237 \DefinePageGrid:TestPage macro:ManPageSize
238 pagerule textband:start text textband:stop pagerule
239 band:start Style:italic FirstPlaced:HeadTitle
240 white:fillup PageCounter band:stop Stop
241 \DefineHeading:TestHeading Style:bold
242 line:start TestHeadingCounter Spaces:2 title line:stop Stop
243 \TestHeading A first section\par And some text.\EjectPage
244 This page contains text. \TestHeading A second Section\par
245 And more text.
246 \OutExampleStop
247
248 The commands \cs{FirstPlaced} and \cs{PreviousPlaced} are typically
249 used on left pages; \cs{LastPlaced} is more common on right pages.
250 You can test on what sort of page you are; see
251 section~\ref[sec:page:tests].
252
253 \OutExample
254 \DefinePageGrid:TestPage macro:ManPageSize
255 pagerule textband:start text textband:stop pagerule
256 band:start Style:italic
257 ifIsLeftPage FirstPlaced:HeadTitle white:fillup fi
258 PageCounter
259 ifIsRightPage white:fillup LastPlaced:HeadTitle fi
260 band:stop Stop \SetCounter:Page=10
261 \DefineHeading:TestHeading Style:bold
262 line:start TestHeadingCounter Spaces:2 title line:stop Stop
263 \TestHeading A first section\par And some text.
264 \TestHeading Second section\par More text.\EjectPage
265 \TestHeading Third section\par Is on the right page.
266 \TestHeading Fourth section\par Concludes this page.
267 \OutExampleStop
268
269
270 \Section Alternating page grids
271
272 In \Lollipop\ it is very easy to switch page grids with the option
273 \refopt{NextPageGrid}: you simply specify
274 \Ver> NextPageGrid:otherpage<Rev as one of the options
275 in the definition. If no next grid is indicated, the same page grid keeps
276 being used continuously until another page grid is activated
277 explicitly.
278
279 \OutExample
280 \DefinePageGrid:LTestPage macro:ManPageSize
281 pagerule textband:start text textband:stop pagerule
282 band:start Style:italic
283 PageCounter white:fillup FirstPlaced:HeadTitle
284 band:stop NextPageGrid:RTestPage Stop
285 \DefinePageGrid:RTestPage macro:ManPageSize
286 pagerule textband:start text textband:stop pagerule
287 band:start Style:italic
288 LastPlaced:HeadTitle white:fillup PageCounter
289 band:stop NextPageGrid:LTestPage Stop
290 \SetCounter:Page=42
291 \DefineHeading:TestHeading Style:bold
292 line:start TestHeadingCounter Spaces:2 title line:stop Stop
293 \LTestPage
294 \TestHeading A first section\par And some text.
295 \TestHeading Second section\par More text.\EjectPage
296 \TestHeading Third section\par Is on the right page.
297 \TestHeading Fourth section\par Concludes this page.
298 \OutExampleStop
299
300 Another very useful application of this mechanism is to have a
301 special definition for the opening page of a chapter. This manual uses a
302 one-shot page grid \cs{EmptyPage} to remove the header and footer on the
303 title page. It installs \cs{LeftPage} as the next grid.
304
305 \Section Additional User Control
306
307 \SubSection Elementary manipulation
308
309 There are a few commands for simple page manipulation:
310 \Description\item \refcs{EjectPage}
311 The current page is filled up with white space, and
312 a new page is started.\item \refcs{ToRecto}
313 As \cs{EjectPage} but if the next page is a left page (meaning
314 that the page number is even) then the page number is increased by
315 one, so that the next page is a right hand page.\item \refcs{ToVerso}
316 As \cs{ToRecto}, except that the next page is a left page.
317 \>
318
319 Additionally, \refcs{NoPages} lets
320 all formatting and updating of values be performed, but
321 no pages are written to the dvi file;
322 \refcs{PagesOut}
323 reverts the effect of previous command. Note that \cs{NoPages} does not
324 incur any savings in time: full processing of the document is performed.
325
326 When a page is finished it rests in box \refcs{WholePage}. Then a call is
327 made to \refcs{CurrentShipout}, which is by default
328 \ver>\shipout\box\WholePage>. However, you are free to define it
329 otherwise. If your \cs{CurrentShipout} does not actually ship out pages,
330 you may want to set \refcs{CountSheetsno} to prevent the effective page
331 counter from being updated.
332
333 Redefining \cs{CurrentShipout} usually goes together with
334 \refcs{SuspendOutput} and \refcs{ResumeOutput}. These commands
335 temporarily save the page number and the current state of the page,
336 including the current definition of \cs{CurrentOutput}. (This is necessary
337 because a number of parameters concerned are changed by global
338 assignments.) See the definition of \cs{OutputExample} in the appendix of
339 this manual for an elaborate example.
340
341 If you want to see te output routines in action, specify
342 \Ver>\Trace:out<Rev In addition \Ver>\Trace:mark<Rev tells you what
343 information is being saved for running head and foot lines.
344
345 \endinput
346
347 % 2014/04/12 Made `output' capitalized.
348 % 92/11/20 Left right output examples
349 % 93/01/17 New description of \CurrentShipout