Debian Codegraph @

texmf-dist/tex/latex/pgf/utilities/pgfpages.sty

raw
1 % Copyright 2019 by Till Tantau
2 %
3 % This file may be distributed and/or modified
4 %
5 % 1. under the LaTeX Project Public License and/or
6 % 2. under the GNU Public License.
7 %
8 % See the file doc/generic/pgf/licenses/LICENSE for more details.
9
10 \ProvidesPackage{pgfpages}[2011/01/05 ver 0.02]
11
12 \RequirePackage{pgfcore,calc}
13
14 \newcount\pgf@logicalpages
15 \newcount\pgf@firstshipout
16 \newcount\pgf@lastshipout
17 \newcount\pgf@currentshipout
18 \newcount\pgf@cpn
19 \newcount\pgf@shipoutnextto
20 \newdimen\pgfphysicalheight
21 \newdimen\pgfphysicalwidth
22
23 \pgf@shipoutnextto=0\relax
24 \pgf@logicalpages=0\relax
25 \pgf@firstshipout=1\relax
26 \pgf@lastshipout=1\relax
27 \pgf@currentshipout=1\relax
28 \pgfphysicalheight=\paperheight
29 \pgfphysicalwidth=\paperwidth
30
31 \newif\ifpgfphysicalpageempty
32 \newif\ifpgf@holdingphysicalpage
33
34 \pgfphysicalpageemptytrue
35 \pgf@holdingphysicalpagefalse
36
37
38 % Define a layout
39 %
40 % #1 = layout name
41 % #2 = code before options have been set
42 % #2 = code after options have been set
43 %
44 % Example:
45 %
46 % \pgfpagesdeclarelayout{resize to}{
47 % \pgfpagesphysicalpageoptions{logical pages=1,physical height=\pgfpageoptionheight,physical width=\pgfpageoptionwidth}
48 % \pgfpageslogicalpageoptions{1}{resized width=\pgfphysicalwidth,%
49 % resized height=\pgfphysicalheight,center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}}}
50
51 \newcommand\pgfpagesdeclarelayout[3]{
52 \expandafter\newcommand\csname pgfpages@layoutbefore@#1\endcsname{#2}
53 \expandafter\newcommand\csname pgfpages@layout@#1\endcsname{#3}}
54
55
56 % Use a layout
57 %
58 % #1 = layout name
59 % #2 = options
60 %
61 % Example:
62 %
63 % \pgfpagesuselayout{resize to}[a4paper]
64
65 \def\pgfpagesuselayout#1{\pgfutil@ifnextchar[{\pgf@pagelayout{#1}}{\pgf@pagelayout{#1}[]}}
66 \def\pgf@pagelayout#1[#2]{
67 \csname pgfpages@layoutbefore@#1\endcsname
68 \setkeys{pgfpagesuselayoutoption}{#2}
69 \pgfutil@ifundefined{pgfpages@layout@#1}{
70 \PackageError{pgfpages}{Page layout `#1' undefined.}{}
71 }
72 {
73 \csname pgfpages@layout@#1\endcsname
74 }
75 }
76
77
78 % Predefined options
79
80 \define@key{pgfpagesuselayoutoption}{physical paper width}%
81 {\def\pgfpageoptionwidth{#1}}
82
83 \define@key{pgfpagesuselayoutoption}{physical paper height}%
84 {\def\pgfpageoptionheight{#1}}
85
86 \define@key{pgfpagesuselayoutoption}{a0paper}[]%
87 {\def\pgfpageoptionheight{1189mm} \def\pgfpageoptionwidth{841mm}}
88
89 \define@key{pgfpagesuselayoutoption}{a1paper}[]%
90 {\def\pgfpageoptionheight{841mm} \def\pgfpageoptionwidth{594mm}}
91
92 \define@key{pgfpagesuselayoutoption}{a2paper}[]%
93 {\def\pgfpageoptionheight{594mm} \def\pgfpageoptionwidth{420mm}}
94
95 \define@key{pgfpagesuselayoutoption}{a3paper}[]%
96 {\def\pgfpageoptionheight{420mm} \def\pgfpageoptionwidth{297mm}}
97
98 \define@key{pgfpagesuselayoutoption}{a4paper}[]%
99 {\def\pgfpageoptionheight{297mm} \def\pgfpageoptionwidth{210mm}}
100
101 \define@key{pgfpagesuselayoutoption}{a5paper}[]%
102 {\def\pgfpageoptionheight{210mm} \def\pgfpageoptionwidth{148mm}}
103
104 \define@key{pgfpagesuselayoutoption}{a6paper}[]%
105 {\def\pgfpageoptionheight{148mm} \def\pgfpageoptionwidth{105mm}}
106
107 \define@key{pgfpagesuselayoutoption}{letterpaper}[]%
108 {\def\pgfpageoptionheight{11in} \def\pgfpageoptionwidth{8.5in}}
109
110 \define@key{pgfpagesuselayoutoption}{legalpaper}[]%
111 {\def\pgfpageoptionheight{14in} \def\pgfpageoptionwidth{8.5in}}
112
113 \define@key{pgfpagesuselayoutoption}{executivepaper}[]%
114 {\def\pgfpageoptionheight{10.5in}\def\pgfpageoptionwidth{7.25in}}
115
116 \define@key{pgfpagesuselayoutoption}{landscape}[]%
117 {
118 \let\pgf@temp=\pgfpageoptionwidth
119 \let\pgfpageoptionwidth=\pgfpageoptionheight
120 \let\pgfpageoptionheight=\pgf@temp
121 }
122
123 \define@key{pgfpagesuselayoutoption}{border shrink}%
124 {\def\pgfpageoptionborder{#1}}
125
126 \define@key{pgfpagesuselayoutoption}{corner width}%
127 {\def\pgfpageoptioncornerwidth{#1}}
128
129 \define@key{pgfpagesuselayoutoption}{odd numbered pages right}[]%
130 {\def\pgfpageoptionfirstshipout{2}}
131
132 \define@key{pgfpagesuselayoutoption}{second right}[]%
133 {%
134 \def\pgfpageoptionfirstcenter{\pgfpoint{.5\paperwidth}{.5\paperheight}}%
135 \def\pgfpageoptionsecondcenter{\pgfpoint{1.5\paperwidth}{.5\paperheight}}%
136 \def\pgfpageoptiontwoheight{\paperheight}%
137 \def\pgfpageoptiontwowidth{2\paperwidth}%
138 }
139
140 \define@key{pgfpagesuselayoutoption}{second left}[]%
141 {%
142 \def\pgfpageoptionfirstcenter{\pgfpoint{1.5\paperwidth}{.5\paperheight}}%
143 \def\pgfpageoptionsecondcenter{\pgfpoint{.5\paperwidth}{.5\paperheight}}%
144 \def\pgfpageoptiontwoheight{\paperheight}%
145 \def\pgfpageoptiontwowidth{2\paperwidth}%
146 }
147
148 \define@key{pgfpagesuselayoutoption}{second top}[]%
149 {%
150 \def\pgfpageoptionfirstcenter{\pgfpoint{.5\paperwidth}{.5\paperheight}}%
151 \def\pgfpageoptionsecondcenter{\pgfpoint{.5\paperwidth}{1.5\paperheight}}%
152 \def\pgfpageoptiontwoheight{2\paperheight}%
153 \def\pgfpageoptiontwowidth{\paperwidth}%
154 }
155
156 \define@key{pgfpagesuselayoutoption}{second bottom}[]%
157 {%
158 \def\pgfpageoptionfirstcenter{\pgfpoint{.5\paperwidth}{1.5\paperheight}}%
159 \def\pgfpageoptionsecondcenter{\pgfpoint{.5\paperwidth}{.5\paperheight}}%
160 \def\pgfpageoptiontwoheight{2\paperheight}%
161 \def\pgfpageoptiontwowidth{\paperwidth}%
162 }
163
164
165
166 % Predefined layouts
167
168 \pgfpagesdeclarelayout{rounded corners}
169 {
170 \def\pgfpageoptioncornerwidth{10pt}
171 }
172 {
173 \pgfpagesphysicalpageoptions
174 {%
175 logical pages=1
176 }
177 \pgfpageslogicalpageoptions{1}
178 {%
179 center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight},%
180 corner width=\pgfpageoptioncornerwidth%
181 }%
182 }
183
184 \pgfpagesdeclarelayout{resize to}
185 {
186 \def\pgfpageoptionborder{0pt}
187 }
188 {
189 \pgfpagesphysicalpageoptions
190 {%
191 logical pages=1,%
192 physical height=\pgfpageoptionheight,%
193 physical width=\pgfpageoptionwidth%
194 }
195 \pgfpageslogicalpageoptions{1}
196 {%
197 resized width=\pgfphysicalwidth,%
198 resized height=\pgfphysicalheight,%
199 border shrink=\pgfpageoptionborder,%
200 center=\pgfpoint{.5\pgfphysicalwidth}{.5\pgfphysicalheight}%
201 }%
202 }
203
204 \pgfpagesdeclarelayout{two screens with lagging second}
205 {}
206 {
207 \pgfpagesphysicalpageoptions
208 {%
209 logical pages=2,%
210 physical height=\pgfpageoptiontwoheight,%
211 physical width=\pgfpageoptiontwowidth,%
212 last logical shipout=1,%
213 }
214 \pgfpageslogicalpageoptions{1}
215 {%
216 center=\pgfpageoptionfirstcenter,%
217 }%
218 \pgfpageslogicalpageoptions{2}
219 {%
220 center=\pgfpageoptionsecondcenter,%
221 copy from=1%
222 }%
223 }
224
225 \pgfpagesdeclarelayout{two screens with optional second}
226 {}
227 {
228 \pgfpagesphysicalpageoptions
229 {%
230 logical pages=2,%
231 physical height=\pgfpageoptiontwoheight,%
232 physical width=\pgfpageoptiontwowidth,%
233 last logical shipout=1%
234 }
235 \pgfpageslogicalpageoptions{1}
236 {%
237 center=\pgfpageoptionfirstcenter,%
238 }%
239 \pgfpageslogicalpageoptions{2}
240 {%
241 center=\pgfpageoptionsecondcenter,%
242 copy from=2%
243 }%
244 }
245
246 \pgfpagesdeclarelayout{2 on 1}
247 {
248 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
249 \edef\pgfpageoptionwidth{\the\paperheight}
250 \def\pgfpageoptionborder{0pt}
251 \def\pgfpageoptionfirstshipout{1}
252 }
253 {
254 \pgfpagesphysicalpageoptions
255 {%
256 logical pages=2,%
257 physical height=\pgfpageoptionheight,%
258 physical width=\pgfpageoptionwidth,%
259 current logical shipout=\pgfpageoptionfirstshipout%
260 }
261 \ifdim\paperheight>\paperwidth\relax
262 % put side-by-side
263 \pgfpageslogicalpageoptions{1}
264 {%
265 border shrink=\pgfpageoptionborder,%
266 resized width=.5\pgfphysicalwidth,%
267 resized height=\pgfphysicalheight,%
268 center=\pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
269 }%
270 \pgfpageslogicalpageoptions{2}
271 {%
272 border shrink=\pgfpageoptionborder,%
273 resized width=.5\pgfphysicalwidth,%
274 resized height=\pgfphysicalheight,%
275 center=\pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
276 }%
277 \else
278 % stack on top of one another
279 \pgfpageslogicalpageoptions{1}
280 {%
281 border shrink=\pgfpageoptionborder,%
282 resized width=\pgfphysicalwidth,%
283 resized height=.5\pgfphysicalheight,%
284 center=\pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
285 }%
286 \pgfpageslogicalpageoptions{2}
287 {%
288 border shrink=\pgfpageoptionborder,%
289 resized width=\pgfphysicalwidth,%
290 resized height=.5\pgfphysicalheight,%
291 center=\pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
292 }%
293 \fi
294 }
295
296
297 \pgfpagesdeclarelayout{4 on 1}
298 {
299 \edef\pgfpageoptionheight{\the\paperheight}
300 \edef\pgfpageoptionwidth{\the\paperwidth}
301 \edef\pgfpageoptionborder{0pt}
302 }
303 {
304 \pgfpagesphysicalpageoptions
305 {%
306 logical pages=4,%
307 physical height=\pgfpageoptionheight,%
308 physical width=\pgfpageoptionwidth%
309 }
310 \pgfpageslogicalpageoptions{1}
311 {%
312 border shrink=\pgfpageoptionborder,%
313 resized width=.5\pgfphysicalwidth,%
314 resized height=.5\pgfphysicalheight,%
315 center=\pgfpoint{.25\pgfphysicalwidth}{.75\pgfphysicalheight}%
316 }%
317 \pgfpageslogicalpageoptions{2}
318 {%
319 border shrink=\pgfpageoptionborder,%
320 resized width=.5\pgfphysicalwidth,%
321 resized height=.5\pgfphysicalheight,%
322 center=\pgfpoint{.75\pgfphysicalwidth}{.75\pgfphysicalheight}%
323 }%
324 \pgfpageslogicalpageoptions{3}
325 {%
326 border shrink=\pgfpageoptionborder,%
327 resized width=.5\pgfphysicalwidth,%
328 resized height=.5\pgfphysicalheight,%
329 center=\pgfpoint{.25\pgfphysicalwidth}{.25\pgfphysicalheight}%
330 }%
331 \pgfpageslogicalpageoptions{4}
332 {%
333 border shrink=\pgfpageoptionborder,%
334 resized width=.5\pgfphysicalwidth,%
335 resized height=.5\pgfphysicalheight,%
336 center=\pgfpoint{.75\pgfphysicalwidth}{.25\pgfphysicalheight}%
337 }%
338 }
339
340
341 \pgfpagesdeclarelayout{6 on 1}
342 {
343 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
344 \edef\pgfpageoptionwidth{\the\paperheight}
345 \def\pgfpageoptionborder{0pt}
346 }
347 {
348 \pgfpagesphysicalpageoptions
349 {%
350 logical pages=6,%
351 physical height=\pgfpageoptionheight,%
352 physical width=\pgfpageoptionwidth%
353 }
354 \ifdim\paperheight>\paperwidth\relax
355 % put side-by-side
356 \pgfpageslogicalpageoptions{1}
357 {%
358 border shrink=\pgfpageoptionborder,%
359 resized width=.25\pgfphysicalwidth,%
360 resized height=.5\pgfphysicalheight,%
361 center=\pgfpoint{.167\pgfphysicalwidth}{.75\pgfphysicalheight}%
362 }%
363 \pgfpageslogicalpageoptions{2}
364 {%
365 border shrink=\pgfpageoptionborder,%
366 resized width=.25\pgfphysicalwidth,%
367 resized height=.5\pgfphysicalheight,%
368 center=\pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
369 }%
370 \pgfpageslogicalpageoptions{3}
371 {%
372 border shrink=\pgfpageoptionborder,%
373 resized width=.25\pgfphysicalwidth,%
374 resized height=.5\pgfphysicalheight,%
375 center=\pgfpoint{.833\pgfphysicalwidth}{.75\pgfphysicalheight}%
376 }%
377 \pgfpageslogicalpageoptions{4}
378 {%
379 border shrink=\pgfpageoptionborder,%
380 resized width=.25\pgfphysicalwidth,%
381 resized height=.5\pgfphysicalheight,%
382 center=\pgfpoint{.167\pgfphysicalwidth}{.25\pgfphysicalheight}%
383 }%
384 \pgfpageslogicalpageoptions{5}
385 {%
386 border shrink=\pgfpageoptionborder,%
387 resized width=.25\pgfphysicalwidth,%
388 resized height=.5\pgfphysicalheight,%
389 center=\pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
390 }%
391 \pgfpageslogicalpageoptions{6}
392 {%
393 border shrink=\pgfpageoptionborder,%
394 resized width=.25\pgfphysicalwidth,%
395 resized height=.5\pgfphysicalheight,%
396 center=\pgfpoint{.833\pgfphysicalwidth}{.25\pgfphysicalheight}%
397 }%
398 \else
399 % stack on top of one another
400 \pgfpageslogicalpageoptions{1}
401 {%
402 border shrink=\pgfpageoptionborder,%
403 resized width=.5\pgfphysicalwidth,%
404 resized height=.25\pgfphysicalheight,%
405 center=\pgfpoint{.25\pgfphysicalwidth}{.833\pgfphysicalheight}%
406 }%
407 \pgfpageslogicalpageoptions{2}
408 {%
409 border shrink=\pgfpageoptionborder,%
410 resized width=.5\pgfphysicalwidth,%
411 resized height=.25\pgfphysicalheight,%
412 center=\pgfpoint{.75\pgfphysicalwidth}{.833\pgfphysicalheight}%
413 }%
414 \pgfpageslogicalpageoptions{3}
415 {%
416 border shrink=\pgfpageoptionborder,%
417 resized width=.5\pgfphysicalwidth,%
418 resized height=.25\pgfphysicalheight,%
419 center=\pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
420 }%
421 \pgfpageslogicalpageoptions{4}
422 {%
423 border shrink=\pgfpageoptionborder,%
424 resized width=.5\pgfphysicalwidth,%
425 resized height=.25\pgfphysicalheight,%
426 center=\pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
427 }%
428 \pgfpageslogicalpageoptions{5}
429 {%
430 border shrink=\pgfpageoptionborder,%
431 resized width=.5\pgfphysicalwidth,%
432 resized height=.25\pgfphysicalheight,%
433 center=\pgfpoint{.25\pgfphysicalwidth}{.167\pgfphysicalheight}%
434 }%
435 \pgfpageslogicalpageoptions{6}
436 {%
437 border shrink=\pgfpageoptionborder,%
438 resized width=.5\pgfphysicalwidth,%
439 resized height=.25\pgfphysicalheight,%
440 center=\pgfpoint{.75\pgfphysicalwidth}{.167\pgfphysicalheight}%
441 }%
442 \fi
443 }
444
445
446 \pgfpagesdeclarelayout{8 on 1}
447 {
448 \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
449 \edef\pgfpageoptionwidth{\the\paperheight}
450 \def\pgfpageoptionborder{0pt}
451 }
452 {
453 \pgfpagesphysicalpageoptions
454 {%
455 logical pages=8,%
456 physical height=\pgfpageoptionheight,%
457 physical width=\pgfpageoptionwidth%
458 }
459 \ifdim\paperheight>\paperwidth\relax
460 % put side-by-side
461 \pgfpageslogicalpageoptions{1}
462 {%
463 border shrink=\pgfpageoptionborder,%
464 resized width=.25\pgfphysicalwidth,%
465 resized height=.5\pgfphysicalheight,%
466 center=\pgfpoint{.125\pgfphysicalwidth}{.75\pgfphysicalheight}%
467 }%
468 \pgfpageslogicalpageoptions{2}
469 {%
470 border shrink=\pgfpageoptionborder,%
471 resized width=.25\pgfphysicalwidth,%
472 resized height=.5\pgfphysicalheight,%
473 center=\pgfpoint{.375\pgfphysicalwidth}{.75\pgfphysicalheight}%
474 }%
475 \pgfpageslogicalpageoptions{3}
476 {%
477 border shrink=\pgfpageoptionborder,%
478 resized width=.25\pgfphysicalwidth,%
479 resized height=.5\pgfphysicalheight,%
480 center=\pgfpoint{.625\pgfphysicalwidth}{.75\pgfphysicalheight}%
481 }%
482 \pgfpageslogicalpageoptions{4}
483 {%
484 border shrink=\pgfpageoptionborder,%
485 resized width=.25\pgfphysicalwidth,%
486 resized height=.5\pgfphysicalheight,%
487 center=\pgfpoint{.875\pgfphysicalwidth}{.75\pgfphysicalheight}%
488 }%
489 \pgfpageslogicalpageoptions{5}
490 {%
491 border shrink=\pgfpageoptionborder,%
492 resized width=.25\pgfphysicalwidth,%
493 resized height=.5\pgfphysicalheight,%
494 center=\pgfpoint{.125\pgfphysicalwidth}{.25\pgfphysicalheight}%
495 }%
496 \pgfpageslogicalpageoptions{6}
497 {%
498 border shrink=\pgfpageoptionborder,%
499 resized width=.25\pgfphysicalwidth,%
500 resized height=.5\pgfphysicalheight,%
501 center=\pgfpoint{.375\pgfphysicalwidth}{.25\pgfphysicalheight}%
502 }%
503 \pgfpageslogicalpageoptions{7}
504 {%
505 border shrink=\pgfpageoptionborder,%
506 resized width=.25\pgfphysicalwidth,%
507 resized height=.5\pgfphysicalheight,%
508 center=\pgfpoint{.625\pgfphysicalwidth}{.25\pgfphysicalheight}%
509 }%
510 \pgfpageslogicalpageoptions{8}
511 {%
512 border shrink=\pgfpageoptionborder,%
513 resized width=.25\pgfphysicalwidth,%
514 resized height=.5\pgfphysicalheight,%
515 center=\pgfpoint{.875\pgfphysicalwidth}{.25\pgfphysicalheight}%
516 }%
517 \else
518 % stack on top of one another
519 \pgfpageslogicalpageoptions{1}
520 {%
521 border shrink=\pgfpageoptionborder,%
522 resized width=.5\pgfphysicalwidth,%
523 resized height=.25\pgfphysicalheight,%
524 center=\pgfpoint{.25\pgfphysicalwidth}{.875\pgfphysicalheight}%
525 }%
526 \pgfpageslogicalpageoptions{2}
527 {%
528 border shrink=\pgfpageoptionborder,%
529 resized width=.5\pgfphysicalwidth,%
530 resized height=.25\pgfphysicalheight,%
531 center=\pgfpoint{.75\pgfphysicalwidth}{.875\pgfphysicalheight}%
532 }%
533 \pgfpageslogicalpageoptions{3}
534 {%
535 border shrink=\pgfpageoptionborder,%
536 resized width=.5\pgfphysicalwidth,%
537 resized height=.25\pgfphysicalheight,%
538 center=\pgfpoint{.25\pgfphysicalwidth}{.625\pgfphysicalheight}%
539 }%
540 \pgfpageslogicalpageoptions{4}
541 {%
542 border shrink=\pgfpageoptionborder,%
543 resized width=.5\pgfphysicalwidth,%
544 resized height=.25\pgfphysicalheight,%
545 center=\pgfpoint{.75\pgfphysicalwidth}{.625\pgfphysicalheight}%
546 }%
547 \pgfpageslogicalpageoptions{5}
548 {%
549 border shrink=\pgfpageoptionborder,%
550 resized width=.5\pgfphysicalwidth,%
551 resized height=.25\pgfphysicalheight,%
552 center=\pgfpoint{.25\pgfphysicalwidth}{.375\pgfphysicalheight}%
553 }%
554 \pgfpageslogicalpageoptions{6}
555 {%
556 border shrink=\pgfpageoptionborder,%
557 resized width=.5\pgfphysicalwidth,%
558 resized height=.25\pgfphysicalheight,%
559 center=\pgfpoint{.75\pgfphysicalwidth}{.375\pgfphysicalheight}%
560 }%
561 \pgfpageslogicalpageoptions{7}
562 {%
563 border shrink=\pgfpageoptionborder,%
564 resized width=.5\pgfphysicalwidth,%
565 resized height=.25\pgfphysicalheight,%
566 center=\pgfpoint{.25\pgfphysicalwidth}{.125\pgfphysicalheight}%
567 }%
568 \pgfpageslogicalpageoptions{8}
569 {%
570 border shrink=\pgfpageoptionborder,%
571 resized width=.5\pgfphysicalwidth,%
572 resized height=.25\pgfphysicalheight,%
573 center=\pgfpoint{.75\pgfphysicalwidth}{.125\pgfphysicalheight}%
574 }%
575 \fi
576 }
577
578
579 \pgfpagesdeclarelayout{16 on 1}
580 {
581 \edef\pgfpageoptionheight{\the\paperheight}
582 \edef\pgfpageoptionwidth{\the\paperwidth}
583 \edef\pgfpageoptionborder{0pt}
584 }
585 {
586 \pgfpagesphysicalpageoptions
587 {%
588 logical pages=16,%
589 physical height=\pgfpageoptionheight,%
590 physical width=\pgfpageoptionwidth%
591 }
592 \pgfpageslogicalpageoptions{1}
593 {%
594 border shrink=\pgfpageoptionborder,%
595 resized width=.25\pgfphysicalwidth,%
596 resized height=.25\pgfphysicalheight,%
597 center=\pgfpoint{.125\pgfphysicalwidth}{.875\pgfphysicalheight}%
598 }%
599 \pgfpageslogicalpageoptions{2}
600 {%
601 border shrink=\pgfpageoptionborder,%
602 resized width=.25\pgfphysicalwidth,%
603 resized height=.25\pgfphysicalheight,%
604 center=\pgfpoint{.375\pgfphysicalwidth}{.875\pgfphysicalheight}%
605 }%
606 \pgfpageslogicalpageoptions{3}
607 {%
608 border shrink=\pgfpageoptionborder,%
609 resized width=.25\pgfphysicalwidth,%
610 resized height=.25\pgfphysicalheight,%
611 center=\pgfpoint{.625\pgfphysicalwidth}{.875\pgfphysicalheight}%
612 }%
613 \pgfpageslogicalpageoptions{4}
614 {%
615 border shrink=\pgfpageoptionborder,%
616 resized width=.25\pgfphysicalwidth,%
617 resized height=.25\pgfphysicalheight,%
618 center=\pgfpoint{.875\pgfphysicalwidth}{.875\pgfphysicalheight}%
619 }%
620 \pgfpageslogicalpageoptions{5}
621 {%
622 border shrink=\pgfpageoptionborder,%
623 resized width=.25\pgfphysicalwidth,%
624 resized height=.25\pgfphysicalheight,%
625 center=\pgfpoint{.125\pgfphysicalwidth}{.625\pgfphysicalheight}%
626 }%
627 \pgfpageslogicalpageoptions{6}
628 {%
629 border shrink=\pgfpageoptionborder,%
630 resized width=.25\pgfphysicalwidth,%
631 resized height=.25\pgfphysicalheight,%
632 center=\pgfpoint{.375\pgfphysicalwidth}{.625\pgfphysicalheight}%
633 }%
634 \pgfpageslogicalpageoptions{7}
635 {%
636 border shrink=\pgfpageoptionborder,%
637 resized width=.25\pgfphysicalwidth,%
638 resized height=.25\pgfphysicalheight,%
639 center=\pgfpoint{.625\pgfphysicalwidth}{.625\pgfphysicalheight}%
640 }%
641 \pgfpageslogicalpageoptions{8}
642 {%
643 border shrink=\pgfpageoptionborder,%
644 resized width=.25\pgfphysicalwidth,%
645 resized height=.25\pgfphysicalheight,%
646 center=\pgfpoint{.875\pgfphysicalwidth}{.625\pgfphysicalheight}%
647 }%
648 \pgfpageslogicalpageoptions{9}
649 {%
650 border shrink=\pgfpageoptionborder,%
651 resized width=.25\pgfphysicalwidth,%
652 resized height=.25\pgfphysicalheight,%
653 center=\pgfpoint{.125\pgfphysicalwidth}{.375\pgfphysicalheight}%
654 }%
655 \pgfpageslogicalpageoptions{10}
656 {%
657 border shrink=\pgfpageoptionborder,%
658 resized width=.25\pgfphysicalwidth,%
659 resized height=.25\pgfphysicalheight,%
660 center=\pgfpoint{.375\pgfphysicalwidth}{.375\pgfphysicalheight}%
661 }%
662 \pgfpageslogicalpageoptions{11}
663 {%
664 border shrink=\pgfpageoptionborder,%
665 resized width=.25\pgfphysicalwidth,%
666 resized height=.25\pgfphysicalheight,%
667 center=\pgfpoint{.625\pgfphysicalwidth}{.375\pgfphysicalheight}%
668 }%
669 \pgfpageslogicalpageoptions{12}
670 {%
671 border shrink=\pgfpageoptionborder,%
672 resized width=.25\pgfphysicalwidth,%
673 resized height=.25\pgfphysicalheight,%
674 center=\pgfpoint{.875\pgfphysicalwidth}{.375\pgfphysicalheight}%
675 }%
676 \pgfpageslogicalpageoptions{13}
677 {%
678 border shrink=\pgfpageoptionborder,%
679 resized width=.25\pgfphysicalwidth,%
680 resized height=.25\pgfphysicalheight,%
681 center=\pgfpoint{.125\pgfphysicalwidth}{.125\pgfphysicalheight}%
682 }%
683 \pgfpageslogicalpageoptions{14}
684 {%
685 border shrink=\pgfpageoptionborder,%
686 resized width=.25\pgfphysicalwidth,%
687 resized height=.25\pgfphysicalheight,%
688 center=\pgfpoint{.375\pgfphysicalwidth}{.125\pgfphysicalheight}%
689 }%
690 \pgfpageslogicalpageoptions{15}
691 {%
692 border shrink=\pgfpageoptionborder,%
693 resized width=.25\pgfphysicalwidth,%
694 resized height=.25\pgfphysicalheight,%
695 center=\pgfpoint{.625\pgfphysicalwidth}{.125\pgfphysicalheight}%
696 }%
697 \pgfpageslogicalpageoptions{16}
698 {%
699 border shrink=\pgfpageoptionborder,%
700 resized width=.25\pgfphysicalwidth,%
701 resized height=.25\pgfphysicalheight,%
702 center=\pgfpoint{.875\pgfphysicalwidth}{.125\pgfphysicalheight}%
703 }%
704 }
705
706
707 % Change/set main option
708 %
709 % #1 = options
710 %
711 % Options:
712 %
713 % logical pages = number of logical pages per physical page
714 % logical shipouts = number of shipouts needed to fill a physical page
715 % (may be less than the number of logical pages,
716 % if some logical pages are calculated
717 % automatically)
718 % current logical shipout = number of logical shipout that will come
719 % next.
720 %
721 % Example:
722 %
723 % \pgfpagesphysicalpageoptions{logical pages=2,logical shipouts=1}
724
725 \newcommand\pgfpagesphysicalpageoptions[1]{%
726 \pgf@lastshipout=0\relax%
727 \pgf@currentshipout=0\relax%
728 \setkeys{pgfpages@main}{#1}%
729 \ifnum\pgf@lastshipout=0\relax%not set
730 \pgf@lastshipout=\pgf@logicalpages%
731 \fi%
732 \ifnum\pgf@currentshipout=0\relax%not set
733 \pgf@currentshipout=\pgf@firstshipout%
734 \fi%
735 }
736
737
738 \define@key{pgfpages@main}{logical pages}{\pgf@logicalpages=#1\relax}
739 \define@key{pgfpages@main}{first logical shipout}{\pgf@firstshipout=#1\relax}
740 \define@key{pgfpages@main}{last logical shipout}{\pgf@lastshipout=#1\relax}
741 \define@key{pgfpages@main}{current logical shipout}{\pgf@currentshipout=#1\relax}
742 \define@key{pgfpages@main}{physical height}{\pgfphysicalheight=#1\relax}
743 \define@key{pgfpages@main}{physical width}{\pgfphysicalwidth=#1\relax}
744
745
746
747 % Setup/change parameters of a logical page. You must call this
748 % macro for each logical page.
749 %
750 % #1 = logical page number
751 % #2 = options
752 %
753 % Options:
754 %
755 % original height = height of the logical page (\paperheight at point of
756 % first invocation by default)
757 % original width = width of the logical page (\paperwidth by default)
758 % resized height = height of the logical page after resizing
759 % resized width = width of the logical page after resizing
760 % border shrink = length that is subtracted from resized height and
761 % resized width
762 % border code = pgf commands to be used for drawing a border (a
763 % path with the border set will already have been
764 % set)
765 % rounded corners = clip the frame against a rectangle of the size of
766 % the frame with corners of the given radius
767 % scale = factor by which the page is enlarged/shrunk
768 % center = center of the logical page in the physical page
769 % rotation = degree by which the page is rotated around its center
770 % xscale = scale only x-axis (use -1 to flip along y-axis)
771 % yscale = scale only y-axis (use -1 to flip along x-axis)
772 % copy from = copy the contents from this logical page of the
773 % previous physical page, if no contents is specified
774 %
775 % If more than one of the three options ``resized height'', ``resized
776 % width'' and ``scale'' are given, the smallest resulting scaling
777 % wins.
778 %
779 % Example:
780 %
781 % \pgfpageslogicalpageoptions{1}{scale=0.5,center=\pgfpoint{0cm}{2cm}}
782
783 \newcommand\pgfpageslogicalpageoptions[2]{%
784 \pgf@cpn=#1\relax%
785 \expandafter\ifx\csname pgfpages@box@#1\endcsname\relax%
786 \expandafter\newbox\csname pgfpages@box@#1\endcsname%
787 \edef\pgf@temp{%
788 \noexpand\pgf@psetcurrent{height}{\the\paperheight}%
789 \noexpand\pgf@psetcurrent{width}{\the\paperwidth}%
790 }%
791 \pgf@temp%
792 \fi%
793 \setkeys{pgfpages@page}{#2}%
794 \pgf@calculateresizes{height}%
795 \pgf@calculateresizes{width}%
796 \pgfsetupphysicalpagesizes%
797 }
798
799 \def\pgf@epset#1#2#3{\expandafter\edef\csname pgfpages@p@#1@#2\endcsname{#3}}
800 \def\pgf@epsetcurrent#1#2{\pgf@pset{\the\pgf@cpn}{#1}{#2}}
801 \def\pgf@pset#1#2#3{\expandafter\def\csname pgfpages@p@#1@#2\endcsname{#3}}
802 \def\pgf@pget#1#2{\csname pgfpages@p@#1@#2\endcsname}
803 \def\pgf@psetcurrent#1#2{\pgf@pset{\the\pgf@cpn}{#1}{#2}}
804 \def\pgf@pgetcurrent#1{\pgf@pget{\the\pgf@cpn}}
805
806 \define@key{pgfpages@page}{scale}{\pgf@epsetcurrent{scale}{#1}}
807 \define@key{pgfpages@page}{xscale}{\pgf@epsetcurrent{xscale}{#1}}
808 \define@key{pgfpages@page}{yscale}{\pgf@epsetcurrent{yscale}{#1}}
809 \define@key{pgfpages@page}{original height}{\pgf@epsetcurrent{height}{#1}}
810 \define@key{pgfpages@page}{original width}{\pgf@epsetcurrent{width}{#1}}
811 \define@key{pgfpages@page}{resized height}{\pgf@epsetcurrent{reheight}{#1}}
812 \define@key{pgfpages@page}{resized width}{\pgf@epsetcurrent{rewidth}{#1}}
813 \define@key{pgfpages@page}{center}{\pgf@psetcurrent{center}{#1}}
814 \define@key{pgfpages@page}{rotation}{\pgf@epsetcurrent{rotation}{#1}}
815 \define@key{pgfpages@page}{copy from}{\pgf@epsetcurrent{copy}{#1}}
816 \define@key{pgfpages@page}{border shrink}{\pgf@epsetcurrent{border}{#1}}
817 \define@key{pgfpages@page}{border code}{\pgf@psetcurrent{bordercode}{#1}}
818 \define@key{pgfpages@page}{corner width}{\pgf@psetcurrent{cornerwidth}{#1}}
819
820 \def\pgf@calculateresizes#1{%
821 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @re#1\endcsname\relax%
822 \else%
823 \expandafter\pgfutil@tempdima\csname pgfpages@p@\the\pgf@cpn @re#1\endcsname\relax%
824 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @border\endcsname\relax%
825 \else%
826 \expandafter\pgfutil@tempdimb\csname pgfpages@p@\the\pgf@cpn @border\endcsname\relax%
827 \advance\pgfutil@tempdima by-2\pgfutil@tempdimb\relax%
828 \fi%
829 \expandafter\pgfutil@tempdimb\csname pgfpages@p@\the\pgf@cpn @#1\endcsname\relax%
830 \pgfutil@tempcnta=\pgfutil@tempdimb%
831 \divide\pgfutil@tempcnta by 65536\relax%
832 \ifnum\pgfutil@tempcnta=0\relax%
833 \pgfutil@tempcnta=1\relax%
834 \fi%
835 \divide\pgfutil@tempdima by\pgfutil@tempcnta\relax%
836 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @scale\endcsname\relax%
837 \pgfutil@tempdimb=10000pt%
838 \else%
839 \expandafter\pgfutil@tempdimb\expandafter=\csname pgfpages@p@\the\pgf@cpn @scale\endcsname pt\relax%
840 \fi%
841 \ifdim\pgfutil@tempdima<\pgfutil@tempdimb%
842 \edef\pgf@temp{{scale}{\expandafter\Pgf@geT\the\pgfutil@tempdima}}%
843 \expandafter\pgf@psetcurrent\pgf@temp%
844 \fi%
845 \fi%
846 }
847
848
849
850 % Shipout a physical page immediately
851 %
852 % Example:
853 %
854 % \pgfshipoutphysicalpage
855
856 \newcommand\pgfshipoutphysicalpage{%
857 \ifnum\pgf@logicalpages>0\relax%
858 \pgfpages@buildshipoutbox%
859 \pgfpages@shipoutshipoutbox%
860 \pgfpages@performcopying%
861 \global\pgfphysicalpageemptytrue%
862 \global\pgf@holdingphysicalpagefalse%
863 \fi%
864 }
865
866 \newbox\pgfpages@shipoutbox
867
868 \def\pgfpages@buildshipoutbox{%
869 \setbox\pgfpages@shipoutbox=\vbox{{%
870 \set@typeset@protect%
871 \offinterlineskip%
872 \pgfsys@beginpicture%
873 \pgf@cpn=1\relax%
874 \loop%
875 \setbox0=\hbox to \csname pgfpages@p@\the\pgf@cpn @width\endcsname{%
876 \hskip1in%
877 \vbox to \csname pgfpages@p@\the\pgf@cpn @height\endcsname%
878 {\vskip1in\offinterlineskip\expandafter\copy\csname
879 pgfpages@box@\the\pgf@cpn\endcsname\vss}\hss}%
880 \pgfsys@beginscope%
881 % Translate lower left corner
882 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @center\endcsname\relax%
883 \else%
884 \pgflowlevel{\pgftransformshift{\csname pgfpages@p@\the\pgf@cpn @center\endcsname}}%
885 \fi%
886 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @scale\endcsname\relax%
887 \else%
888 \pgflowlevel{\pgftransformscale{\csname pgfpages@p@\the\pgf@cpn @scale\endcsname}}%
889 \fi%
890 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @xscale\endcsname\relax%
891 \else%
892 \pgflowlevel{\pgftransformxscale{\csname pgfpages@p@\the\pgf@cpn @xscale\endcsname}{1}}%
893 \fi%
894 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @yscale\endcsname\relax%
895 \else%
896 \pgflowlevel{\pgftransformyscale{\csname pgfpages@p@\the\pgf@cpn @yscale\endcsname}}%
897 \fi%
898 \pgfscope%
899 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @rotation\endcsname\relax%
900 \else%
901 \pgflowlevel{\pgftransformrotate{\csname
902 pgfpages@p@\the\pgf@cpn @rotation\endcsname}}%
903 \fi%
904 \pgfutil@tempdima=\csname pgfpages@p@\the\pgf@cpn @width\endcsname\relax%
905 \pgfutil@tempdimb=\csname pgfpages@p@\the\pgf@cpn @height\endcsname\relax%
906 \pgflowlevel{\pgftransformshift{\pgfpoint{-.5\pgfutil@tempdima}{-.5\pgfutil@tempdimb}}}%
907 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @bordercode\endcsname\relax%
908 \else%
909 \pgfpathmoveto{\pgfpointorigin}%
910 \pgfpathlineto{\pgfpoint{\wd0}{0pt}}%
911 \pgfpathlineto{\pgfpoint{\wd0}{\ht0}}%
912 \pgfpathlineto{\pgfpoint{0pt}{\ht0}}%
913 \pgfpathclose%
914 {\csname pgfpages@p@\the\pgf@cpn @bordercode\endcsname}%
915 \fi%
916 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @cornerwidth\endcsname\relax%
917 \else%
918 {
919 \expandafter\pgfutil@tempdima\csname pgfpages@p@\the\pgf@cpn @cornerwidth\endcsname\relax%
920 \color{black}
921 \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdima}}%
922 \pgfpathrectangle{\pgfpoint{0pt}{\ht0-\pgfutil@tempdima}}{\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdima}}%
923 \pgfpathrectangle{\pgfpoint{\wd0-\pgfutil@tempdima}{0pt}}{\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdima}}%
924 \pgfpathrectangle{\pgfpoint{\wd0-\pgfutil@tempdima}{\ht0-\pgfutil@tempdima}}{\pgfpoint{\pgfutil@tempdima}{\pgfutil@tempdima}}%
925 \pgfusepath{fill}%
926 \pgfpathmoveto{\pgfpoint{0pt}{\pgfutil@tempdima}}
927 \pgfpathcurveto{\pgfpoint{0pt}{0.555\pgfutil@tempdima}}{\pgfpoint{.555\pgfutil@tempdima}{0pt}}{\pgfpoint{\pgfutil@tempdima}{0pt}}
928 \pgfpathlineto{\pgfpoint{\wd0-\pgfutil@tempdima}{0pt}}
929 \pgfpathcurveto{\pgfpoint{\wd0-.555\pgfutil@tempdima}{0pt}}{\pgfpoint{\wd0}{.555\pgfutil@tempdima}}{\pgfpoint{\wd0}{\pgfutil@tempdima}}
930 \pgfpathlineto{\pgfpoint{\wd0}{\ht0-\pgfutil@tempdima}}
931 \pgfpathcurveto{\pgfpoint{\wd0}{\ht0-.555\pgfutil@tempdima}}{\pgfpoint{\wd0-.555\pgfutil@tempdima}{\ht0}}{\pgfpoint{\wd0-\pgfutil@tempdima}{\ht0}}
932 \pgfpathlineto{\pgfpoint{\pgfutil@tempdima}{\ht0}}
933 \pgfpathcurveto{\pgfpoint{.555\pgfutil@tempdima}{\ht0}}{\pgfpoint{0pt}{\ht0-.555\pgfutil@tempdima}}{\pgfpoint{0pt}{\ht0-\pgfutil@tempdima}}
934 \pgfpathclose
935 \pgfusepath{clip}
936 \color{white}
937 \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\wd0}{\ht0}}
938 \pgfusepath{fill}
939 }
940 \fi%
941 \ht0=0pt%
942 \wd0=0pt%
943 \dp0=0pt%
944 \pgfsys@hbox0%
945 \endpgfscope%
946 \pgfsys@endscope%
947 \ifnum\pgf@cpn<\pgf@logicalpages%
948 \advance \pgf@cpn by 1\relax%
949 \repeat%
950 \pgfsys@endpicture%
951 }}%
952 }
953
954
955 \def\pgfpages@shipoutshipoutbox{%
956 \begingroup
957 \let \protect \noexpand
958 \@resetactivechars
959 \global\let\@@if@newlist\if@newlist
960 \global\@newlistfalse
961 \@parboxrestore%
962 \pgfpages@originalshipout%
963 \vbox{\hbox{%
964 \pgfsetupphysicalpagesizes%
965 \hskip-1in%
966 \vbox to \pgfphysicalheight{%
967 \vss\box\pgfpages@shipoutbox%
968 \vskip1in%
969 }}%
970 \pgfsetupphysicalpagesizes%
971 }%
972 \endgroup%
973 }
974
975 \def\pgfpages@performcopying{
976 \pgf@cpn=1\relax% copy first
977 \loop%
978 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @copy\endcsname\relax
979 \else%
980 \edef\pgf@temp{\noexpand\global\noexpand\setbox\csname pgfpages@box@%
981 \the\pgf@cpn\endcsname=\noexpand\copy\csname pgfpages@box@\csname
982 pgfpages@p@\the\pgf@cpn @copy\endcsname\endcsname}%
983 \pgf@temp%
984 \fi%
985 \ifnum\pgf@cpn<\pgf@logicalpages%
986 \advance \pgf@cpn by 1\relax%
987 \repeat%
988 \pgf@cpn=1\relax% then void
989 \loop%
990 \expandafter\ifx\csname pgfpages@p@\the\pgf@cpn @copy\endcsname\relax
991 \expandafter\global\expandafter\setbox\csname pgfpages@box@\the\pgf@cpn\endcsname=\box\voidb@x%
992 \else%
993 \fi%
994 \ifnum\pgf@cpn<\pgf@logicalpages%
995 \advance \pgf@cpn by 1\relax%
996 \repeat%
997 }
998
999
1000
1001 % Save original shipout commands
1002 %
1003 % Example:
1004 %
1005 % \pgfhookintoshipout
1006
1007 \newcommand\pgfhookintoshipout{
1008 \ifx\CROP@shipout\undefined
1009 \let\pgfpages@originalshipout=\shipout
1010 \let\shipout=\pgfpages@interceptshipout
1011 \else
1012 \let\pgfpages@originalshipout=\CROP@shipout
1013 \let\CROP@shipout=\pgfpages@interceptshipout
1014 \fi
1015 }
1016
1017 \def\pgfpages@interceptshipout{%
1018 \ifnum\pgf@shipoutnextto>0\relax
1019 \def\pgf@next{%
1020 \expandafter\global\expandafter\setbox\csname pgfpages@box@\the\pgf@shipoutnextto\endcsname=\box\voidb@x%
1021 \afterassignment\pgfpages@shipouttestnext%
1022 \pgfpagesshipoutlogicalpage{\the\pgf@shipoutnextto}%
1023 }%
1024 \else%
1025 \ifpgf@holdingphysicalpage% shipout physical page now
1026 {\pgfshipoutphysicalpage}%
1027 \fi%
1028 \ifnum\pgf@logicalpages=0\relax
1029 \def\pgf@next{\pgfpages@originalshipout}%
1030 \else%
1031 \def\pgf@next{%
1032 \expandafter\global\expandafter\setbox\csname pgfpages@box@\the\pgf@currentshipout\endcsname=\box\voidb@x%
1033 \afterassignment\pgfpages@shipouttest%
1034 \pgfpagesshipoutlogicalpage{\the\pgf@currentshipout}%
1035 }%
1036 \fi%
1037 \fi%
1038 \pgf@next%
1039 }
1040
1041 \def\pgfpages@shipouttest{%
1042 \ifvoid\csname pgfpages@box@\the\pgf@currentshipout\endcsname\relax%
1043 \aftergroup\pgfpages@preparenextshipout%
1044 \else%
1045 \pgfpages@preparenextshipout%
1046 \fi%
1047 }
1048
1049 \def\pgfpages@shipouttestnext{%
1050 \ifvoid\csname pgfpages@box@\the\pgf@shipoutnextto\endcsname\relax%
1051 \aftergroup\pgfpages@preparenextshipout%
1052 \else%
1053 \pgfpages@preparenextshipout%
1054 \fi%
1055 }
1056
1057 \def\pgfpages@preparenextshipout{%
1058 \ifnum\pgf@shipoutnextto=0\relax%
1059 \global\advance\pgf@currentshipout by 1\relax%
1060 \else%
1061 \global\pgf@shipoutnextto=0\relax%
1062 \fi%
1063 \ifnum\pgf@currentshipout>\pgf@lastshipout\relax%
1064 \global\pgf@currentshipout=\pgf@firstshipout\relax%
1065 \global\pgf@holdingphysicalpagetrue%
1066 \fi%
1067 }
1068
1069
1070
1071 % Shipout a logical page
1072 %
1073 % #1 = logical page number
1074 %
1075 % The command should be followed by a box. This box will become the
1076 % contents of the logical page.
1077 %
1078 % Example:
1079 %
1080 % \pgfpagesshipoutlogicalpage{0}\vbox{Hi!}
1081
1082 \newcommand\pgfpagesshipoutlogicalpage[1]{%
1083 \global\pgfphysicalpageemptyfalse%
1084 \expandafter\global\expandafter\setbox\csname pgfpages@box@#1\endcsname=}
1085
1086
1087
1088 % Finish current page and shipout next page to a specific logical page.
1089 %
1090 % #1 = logical page number
1091 %
1092 % When the current page has been typset, it will be become the given
1093 % logical page. This command ``interrupts'' the normal order of
1094 % logical pages.
1095 %
1096 % Example:
1097 %
1098 % \pgfpagesuselayout{two screens with optional second}
1099 %
1100 % Text for main page.\clearpage
1101 %
1102 % \pgfpagescurrentpagewillbelogicalpage{2}
1103 %
1104 % Text that goes to second page
1105 %
1106 % \clearpage
1107 %
1108 % Text for main page.
1109
1110 \newcommand\pgfpagescurrentpagewillbelogicalpage[1]{%
1111 \global\pgf@shipoutnextto=#1\relax%
1112 }
1113
1114
1115 % Setup the physical page sizes
1116 %
1117 % Example:
1118 %
1119 % \pgfsetupphysicalpagesizes
1120
1121 \newcommand\pgfsetupphysicalpagesizes{%
1122 \pgfsys@global@papersize{\the\pgfphysicalwidth}{\the\pgfphysicalheight}%
1123 }
1124
1125
1126 %
1127 % Start/End setup
1128 %
1129 \pgfhookintoshipout
1130
1131 \AtEndDocument
1132 {
1133 \clearpage
1134 \ifpgfphysicalpageempty
1135 \else
1136 \pgfshipoutphysicalpage
1137 \fi
1138 }
1139