Complete the talk.
[matthijs/master-project/dhugday-talk.git] / atbegshi.sty
1 %%
2 %% This is file `atbegshi.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% atbegshi.dtx  (with options: `package')
8 %% 
9 %% This is a generated file.
10 %% 
11 %% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de>
12 %% 
13 %% This work may be distributed and/or modified under the
14 %% conditions of the LaTeX Project Public License, either
15 %% version 1.3 of this license or (at your option) any later
16 %% version. The latest version of this license is in
17 %%    http://www.latex-project.org/lppl.txt
18 %% and version 1.3 or later is part of all distributions of
19 %% LaTeX version 2005/12/01 or later.
20 %% 
21 %% This work has the LPPL maintenance status "maintained".
22 %% 
23 %% This Current Maintainer of this work is Heiko Oberdiek.
24 %% 
25 %% This work consists of the main source file atbegshi.dtx
26 %% and the derived files
27 %%    atbegshi.sty, atbegshi.pdf, atbegshi.ins, atbegshi.drv,
28 %%    atbegshi-example.tex, atbegshi-test1.tex,
29 %%    atbegshi-test2.tex, atbegshi-test3.tex.
30 %% 
31 \begingroup
32   \catcode44 12 % ,
33   \catcode45 12 % -
34   \catcode46 12 % .
35   \catcode58 12 % :
36   \catcode64 11 % @
37   \expandafter\let\expandafter\x\csname ver@atbegshi.sty\endcsname
38   \ifcase 0%
39     \ifx\x\relax % plain
40     \else
41       \ifx\x\empty % LaTeX
42       \else
43         1%
44       \fi
45     \fi
46   \else
47     \catcode35 6 % #
48     \catcode123 1 % {
49     \catcode125 2 % }
50     \expandafter\ifx\csname PackageInfo\endcsname\relax
51       \def\x#1#2{%
52         \immediate\write-1{Package #1 Info: #2.}%
53       }%
54     \else
55       \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
56     \fi
57     \x{atbegshi}{The package is already loaded}%
58     \endgroup
59     \expandafter\endinput
60   \fi
61 \endgroup
62 \begingroup
63   \catcode35 6 % #
64   \catcode40 12 % (
65   \catcode41 12 % )
66   \catcode44 12 % ,
67   \catcode45 12 % -
68   \catcode46 12 % .
69   \catcode47 12 % /
70   \catcode58 12 % :
71   \catcode64 11 % @
72   \catcode123 1 % {
73   \catcode125 2 % }
74   \expandafter\ifx\csname ProvidesPackage\endcsname\relax
75     \def\x#1#2#3[#4]{\endgroup
76       \immediate\write-1{Package: #3 #4}%
77       \xdef#1{#4}%
78     }%
79   \else
80     \def\x#1#2[#3]{\endgroup
81       #2[{#3}]%
82       \ifx#1\relax
83         \xdef#1{#3}%
84       \fi
85     }%
86   \fi
87 \expandafter\x\csname ver@atbegshi.sty\endcsname
88 \ProvidesPackage{atbegshi}%
89   [2007/09/09 v1.6 At begin shipout hook (HO)]
90 \begingroup
91   \catcode123 1 % {
92   \catcode125 2 % }
93   \def\x{\endgroup
94     \expandafter\edef\csname AtBegShi@AtEnd\endcsname{%
95       \catcode35 \the\catcode35\relax
96       \catcode64 \the\catcode64\relax
97       \catcode123 \the\catcode123\relax
98       \catcode125 \the\catcode125\relax
99     }%
100   }%
101 \x
102 \catcode35 6 % #
103 \catcode64 11 % @
104 \catcode123 1 % {
105 \catcode125 2 % }
106 \def\TMP@EnsureCode#1#2{%
107   \edef\AtBegShi@AtEnd{%
108     \AtBegShi@AtEnd
109     \catcode#1 \the\catcode#1\relax
110   }%
111   \catcode#1 #2\relax
112 }
113 \TMP@EnsureCode{40}{12}% (
114 \TMP@EnsureCode{41}{12}% )
115 \TMP@EnsureCode{44}{12}% ,
116 \TMP@EnsureCode{45}{12}% -
117 \TMP@EnsureCode{47}{12}% /
118 \TMP@EnsureCode{46}{12}% .
119 \TMP@EnsureCode{58}{12}% :
120 \TMP@EnsureCode{61}{12}% =
121 \TMP@EnsureCode{94}{7}% ^(superscript)
122 \TMP@EnsureCode{96}{12}% `
123 \begingroup\expandafter\expandafter\expandafter\endgroup
124 \expandafter\ifx\csname RequirePackage\endcsname\relax
125   \input infwarerr.sty\relax
126 \else
127   \RequirePackage{infwarerr}[2007/09/09]%
128 \fi
129 \begingroup\expandafter\expandafter\expandafter\endgroup
130 \expandafter\ifx\csname @ifdefinable\endcsname\relax
131   \def\AtBegShi@CheckDefinable#1{%
132     \ifcase\ifx#1\relax
133              \@ne
134            \else
135              \ifx#1\@undefined
136                \@ne
137              \else
138                \z@
139              \fi
140            \fi
141       \errmessage{%
142         Package atbegshi: \string#1\space
143         is already defined%
144       }%
145       \endgroup
146     \fi
147   }%
148 \else
149   \def\AtBegShi@CheckDefinable#1{%
150     \@ifdefinable{#1}{}%
151   }%
152 \fi
153 \newif\ifAtBegShi@Discarded
154 \AtBegShi@CheckDefinable\AtBeginShipoutDiscard
155 \def\AtBeginShipoutDiscard{%
156   \deadcycles=\z@
157   \global\AtBegShi@Discardedtrue
158 }
159 \begingroup\expandafter\expandafter\expandafter\endgroup
160 \expandafter\ifx\csname currentgrouplevel\endcsname\relax
161   \catcode`X=9  % ignore
162   \catcode`E=14 % comment
163 \else
164   \catcode`X=14 % comment
165   \catcode`E=9  % ignore
166 \fi
167 \def\AtBegShi@Shipout{%
168 X \begingroup
169 X \setbox\AtBeginShipoutBox=\hbox\bgroup
170 X \kern\p@
171 E \edef\AtBegShi@GroupLevel{\number\currentgrouplevel}%
172   \afterassignment\AtBegShi@Test
173 X \global
174   \setbox\AtBeginShipoutBox=%
175 }
176 \def\AtBegShi@Test{%
177 X \ifdim\lastkern=\z@
178 E \ifnum\AtBegShi@GroupLevel<\currentgrouplevel
179     \expandafter\aftergroup
180   \fi
181   \AtBegShi@Output
182 }
183 \def\AtBegShi@Output{%
184 X \egroup
185 X \endgroup
186   \ifvoid\AtBeginShipoutBox
187     \@PackageWarning{atbegshi}{Ignoring void shipout box}%
188   \else
189     \let\AtBegShi@OrgProtect\protect
190     \csname set@typeset@protect\endcsname
191     \global\AtBegShi@Discardedfalse
192     \AtBegShi@Hook
193     \AtBegShi@HookNext
194     \gdef\AtBegShi@HookNext{}%
195     \ifAtBegShi@Discarded
196       \@PackageInfoNoLine{atbegshi}{Shipout page discarded}%
197       \global\AtBegShi@Discardedfalse
198       \begingroup
199         \setbox\AtBeginShipoutBox\box\AtBeginShipoutBox
200       \endgroup
201       \let\protect\AtBegShi@OrgProtect
202     \else
203       \AtBegShi@First
204       \let\protect\AtBegShi@OrgProtect
205       \AtBegShi@OrgShipout\box\AtBeginShipoutBox
206     \fi
207   \fi
208 }
209 \catcode`\X=11 %
210 \catcode`\E=11 %
211 \def\AtBegShi@First{%
212   \begingroup
213     \def\@empty{}%
214     \ifx\AtBegShi@HookFirst\@empty
215     \else
216       \setbox\z@=\vbox{%
217         \begingroup
218           \AtBegShi@HookFirst
219         \endgroup
220       }%
221       \wd\z@=\z@
222       \ht\z@=\z@
223       \dp\z@=\z@
224       \global\setbox\AtBeginShipoutBox=\vbox{%
225         \baselineskip\z@skip
226         \lineskip\z@skip
227         \lineskiplimit\z@
228         \copy\z@
229         \copy\AtBeginShipoutBox
230       }%
231     \fi
232     \global\let\AtBegShi@First\@empty
233     \global\let\AtBeginShipoutFirst\AtBegShi@FirstDisabled
234   \endgroup
235 }
236 \gdef\AtBegShi@Hook{}
237 \gdef\AtBegShi@HookNext{}
238 \gdef\AtBegShi@HookFirst{}
239 \AtBegShi@CheckDefinable\AtBeginShipout
240 \def\AtBeginShipout{%
241   \AtBegShi@AddHook\AtBegShi@Hook
242 }
243 \AtBegShi@CheckDefinable\AtBeginShipoutNext
244 \def\AtBeginShipoutNext{%
245   \AtBegShi@AddHook\AtBegShi@HookNext
246 }
247 \AtBegShi@CheckDefinable\AtBeginShipoutFirst
248 \def\AtBeginShipoutFirst{%
249   \AtBegShi@AddTo\AtBegShi@HookFirst
250 }
251 \long\def\AtBegShi@FirstDisabled#1{%
252   \@PackageWarning{atbegshi}{%
253     First page is already shipped out, ignoring\MessageBreak
254     \string\AtBeginShipoutFirst
255   }%
256 }
257 \begingroup\expandafter\expandafter\expandafter\endgroup
258 \expandafter\ifx\csname g@addto@macro\endcsname\relax
259   \long\def\AtBegShi@AddTo#1#2{%
260     \begingroup
261       \toks\z@\expandafter{#1#2}%
262       \xdef#1{\the\toks\z@}%
263     \endgroup
264   }%
265 \else
266   \let\AtBegShi@AddTo\g@addto@macro
267 \fi
268 \long\def\AtBegShi@AddHook#1#2{%
269   \AtBegShi@AddTo#1{\AtBegShi@Item{#2}}%
270 }
271 \long\def\AtBegShi@Item#1{%
272   \ifAtBegShi@Discarded
273   \else
274     #1%
275     \ifvoid\AtBeginShipoutBox
276       \@PackageWarning{atbegshi}{%
277         Shipout box was voided by hook,\MessageBreak
278         ignoring shipout box%
279       }%
280       \AtBeginShipoutDiscard
281     \fi
282   \fi
283 }
284 \AtBegShi@CheckDefinable\AtBeginShipoutInit
285 \def\AtBeginShipoutInit{%
286   \csname newbox\endcsname\AtBeginShipoutBox
287   \AtBegShi@CheckDefinable\AtBegShi@OrgShipout
288   \global\let\AtBegShi@OrgShipout\shipout
289   \global\let\shipout\AtBegShi@Shipout
290   \gdef\AtBeginShipoutInit{}%
291 }
292 \begingroup\expandafter\expandafter\expandafter\endgroup
293 \expandafter\ifx\csname AtBeginDocument\endcsname\relax
294   \AtBeginShipoutInit
295 \else
296   \AtBeginDocument{\AtBeginShipoutInit}%
297 \fi
298 \begingroup\expandafter\expandafter\expandafter\endgroup
299 \expandafter\ifx\csname RequirePackage\endcsname\relax
300   \input ifpdf.sty\relax
301 \else
302   \RequirePackage{ifpdf}\relax
303 \fi
304 \ifpdf
305   \def\AtBegShi@horigin{\pdfhorigin}%
306   \def\AtBegShi@vorigin{\pdfvorigin}%
307 \else
308   \def\AtBegShi@horigin{72.27pt}%
309   \def\AtBegShi@vorigin{72.27pt}%
310 \fi
311 \begingroup
312 \ifcase
313     \expandafter\ifx\csname picture\endcsname\relax
314       1%
315     \else
316       \expandafter\ifx\csname endpicture\endcsname\relax
317         1%
318       \else
319         0%
320       \fi
321     \fi
322   \endgroup
323   \def\AtBegShi@BeginPicture{%
324     \begingroup
325     \picture(0,0)\relax
326     \begingroup\expandafter\expandafter\expandafter\endgroup
327     \expandafter\ifx\csname unitlength\endcsname\relax
328     \else
329       \unitlength=1pt\relax
330     \fi
331     \ignorespaces
332   }%
333   \def\AtBegShi@EndPicture{%
334     \endpicture
335     \endgroup
336   }%
337 \else
338   \endgroup
339   \def\AtBegShi@BeginPicture{%
340     \setbox0=\hbox\bgroup
341     \begingroup
342     \ignorespaces
343   }%
344   \def\AtBegShi@EndPicture{%
345     \endgroup
346     \egroup
347     \ht0=0pt\relax
348     \dp0=0pt\relax
349     \copy0 %
350   }%
351 \fi
352 \def\AtBeginShipoutUpperLeft#1{%
353   \global\setbox\AtBeginShipoutBox=\hbox{%
354     \rlap{%
355       \kern-\AtBegShi@horigin\relax
356       \vbox to 0pt{%
357         \kern-\AtBegShi@vorigin\relax
358         \kern-\ht\AtBeginShipoutBox
359         \AtBegShi@BeginPicture
360         #1%
361         \AtBegShi@EndPicture
362         \vss
363       }%
364     }%
365     \box\AtBeginShipoutBox
366   }%
367 }
368 \def\AtBegShi@AbortIfUndefined#1{%
369   \begingroup\expandafter\expandafter\expandafter\endgroup
370   \expandafter\ifx\csname#1\endcsname\relax
371     \AtBegShi@AtEnd
372     \expandafter\endinput
373   \fi
374 }
375 \AtBegShi@AbortIfUndefined{currentgrouplevel}
376 \AtBegShi@AbortIfUndefined{AtBeginDocument}
377 \AtBegShi@AbortIfUndefined{@ifpackageloaded}
378 \AtBegShi@AbortIfUndefined{@ifclassloaded}
379 \def\AtBegShi@PatchCrop{%
380   \begingroup
381     \def\AtBegShi@Crop@shipout{%
382       \afterassignment\CROP@ship
383       \setbox\@cclv=%
384     }%
385     \def\AtBegShi@Crop@ship{%
386       \ifvoid\@cclv
387         \expandafter\aftergroup
388       \fi
389       \CROP@@ship
390     }%
391     \def\AtBegShi@Crop@shiplist{%
392       \lineskip\z@
393       \lineskiplimit\z@
394       \baselineskip\z@
395       \CROP@kernel
396       \box\@cclv
397     }%
398     \def\AtBegShi@Crop@@ship{%
399       \CROP@shipout\vbox{%
400         \CROP@shiplist
401       }%
402     }%
403     \ifx\AtBegShi@Crop@ship\CROP@ship
404       \ifx\AtBegShi@Crop@shiplist\CROP@shiplist
405         \ifx\AtBegShi@Crop@@ship\CROP@@ship
406           \let\AtBegShi@found\relax
407           \ifx\shipout\AtBegShi@Crop@shipout
408             \def\AtBegShi@found{\shipout}%
409           \else\ifx\AtBegShi@OrgShipout\AtBegShi@Crop@shipout
410             \def\AtBegShi@found{\AtBegShi@OrgShipout}%
411           \else\ifx\@EveryShipout@Org@Shipout\AtBegShi@Crop@shipout
412             \def\AtBegShi@found{\@EveryShipout@Org@Shipout}%
413           \else\ifx\GPTorg@shipout\AtBegShi@Crop@shipout
414             \def\AtBegShi@found{\GPTorg@shipout}%
415           \else\ifx\THBorg@shipout\AtBegShi@Crop@shipout
416             \def\AtBegShi@found{\THBorg@shipout}%
417           \else\ifx\mem@oldshipout\AtBegShi@Crop@shipout
418             \def\AtBegShi@found{\mem@oldshipout}%
419           \fi\fi\fi\fi\fi\fi
420           \ifx\AtBegShi@found\relax
421           \else
422             \expandafter\endgroup
423             \expandafter\def\AtBegShi@found{%
424               \edef\AtBegShi@GroupLevel{\number\currentgrouplevel}%
425               \afterassignment\CROP@ship
426               \setbox\AtBeginShipoutBox=%
427             }%
428             \def\CROP@ship{%
429               \ifnum\AtBegShi@GroupLevel=\currentgrouplevel
430               \else
431                 \expandafter\aftergroup
432               \fi
433               \CROP@@ship
434             }%
435             \def\CROP@shiplist{%
436               \lineskip\z@
437               \lineskiplimit\z@
438               \baselineskip\z@
439               \CROP@kernel
440               \box\AtBeginShipoutBox
441             }%
442             \def\CROP@@ship{%
443               \ifvoid\AtBeginShipoutBox
444               \else
445                 \setbox\AtBeginShipoutBox=\vbox{%
446                   \CROP@shiplist
447                 }%
448                 \expandafter\CROP@shipout
449                 \expandafter\box
450                 \expandafter\AtBeginShipoutBox
451               \fi
452             }%
453             \@PackageInfoNoLine{atbegshi}{Package `crop' patched}%
454             \begingroup
455           \fi
456         \fi
457       \fi
458     \fi
459   \endgroup
460   \let\AtBegShi@PatchCrop\relax
461 }
462 \@ifpackageloaded{crop}{%
463   \AtBegShi@PatchCrop
464 }{%
465   \AtBeginDocument{\AtBegShi@PatchCrop}%
466 }
467 \def\AtBegShi@PatchEveryshi{%
468   \begingroup
469     \long\def\AtBegShi@Everyshi@shipout{%
470       \afterassignment\@EveryShipout@Test
471       \global\setbox\@cclv= %
472     }%
473     \long\def\AtBegShi@Everyshi@Test{%
474       \ifvoid\@cclv\relax
475         \aftergroup\@EveryShipout@Output
476       \else
477         \@EveryShipout@Output
478       \fi
479     }%
480     \ifx\AtBegShi@Everyshi@Test\@EveryShipout@Test
481       \let\AtBegShi@found\relax
482       \ifx\shipout\AtBegShi@Everyshi@shipout
483         \def\AtBegShi@found{\shipout}%
484       \else\ifx\AtBegShi@OrgShipout\AtBegShi@Everyshi@shipout
485         \def\AtBegShi@found{\AtBegShi@OrgShipout}%
486       \else\ifx\CROP@shipout\AtBegShi@Everyshi@shipout
487         \def\AtBegShi@found{\CROP@shipout}%
488       \else\ifx\GPTorg@shipout\AtBegShi@Everyshi@shipout
489         \def\AtBegShi@found{\GPTorg@shipout}%
490       \else\ifx\THBorg@shipout\AtBegShi@Everyshi@shipout
491         \def\AtBegShi@found{\THBorg@shipout}%
492       \else\ifx\mem@oldshipout\AtBegShi@Everyshi@shipout
493         \def\AtBegShi@found{\mem@oldshipout}%
494       \else
495         \expandafter\ifx\csname @EveryShipout@Org@Shipout\endcsname
496                         \relax
497            \ifx\@EveryShipout@Shipout\AtBegShi@Everyshi@shipout
498              \def\AtBegShi@found{\@EveryShipout@Shipout}%
499            \fi
500         \fi
501       \fi\fi\fi\fi\fi\fi
502       \ifx\AtBegShi@found\relax
503       \else
504         \expandafter\endgroup
505         \expandafter\def\AtBegShi@found{%
506           \edef\AtBegShi@GroupLevel{\number\currentgrouplevel}%
507           \afterassignment\@EveryShipout@Test
508           \setbox\AtBeginShipoutBox=%
509         }%
510         \def\@EveryShipout@Test{%
511           \ifnum\AtBegShi@GroupLevel=\currentgrouplevel
512           \else
513             \expandafter\aftergroup
514           \fi
515           \AtBegShi@Everyshi@Output
516         }%
517         \def\AtBegShi@Everyshi@Output{%
518           \ifvoid\AtBeginShipoutBox
519           \else
520             \global\setbox\@cclv\box\AtBeginShipoutBox
521             \expandafter\@EveryShipout@Output
522           \fi
523         }%
524         \@PackageInfoNoLine{atbegshi}{Package `everyshi' patched}%
525         \begingroup
526       \fi
527     \fi
528   \endgroup
529   \let\AtBegShi@PatchEveryshi\relax
530 }
531 \@ifpackageloaded{everyshi}{%
532   \AtBegShi@PatchEveryshi
533 }{%
534   \AtBeginDocument{\AtBegShi@PatchEveryshi}%
535 }
536 \def\AtBegShi@PatchMemoir{%
537   \begingroup
538     \def\AtBegShi@Memoir@shipout{%
539       \afterassignment\mem@shipi
540       \setbox\@cclv=%
541     }%
542     \def\AtBegShi@Memoir@shipi{%
543       \ifvoid\@cclv
544         \expandafter\aftergroup
545       \fi
546       \mem@shipii
547     }%
548     \def\AtBegShi@Memoir@shipiiA{%
549       \mem@oldshipout\vbox{%
550         \trimmarks
551         \unvbox\@cclv
552       }%
553     }%
554     \def\AtBegShi@Memoir@shipiiB{%
555       \ifvoid\@cclv
556         \mem@oldshipout\box\@cclv
557       \else
558         \mem@oldshipout\vbox{%
559           \trimmarks
560           \unvbox\@cclv
561         }%
562       \fi
563     }%
564     \ifx\AtBegShi@Memoir@shipi\mem@shipi
565       \ifcase\ifx\AtBegShi@Memoir@shipiiA\mem@shipii
566                \z@
567              \else
568                \ifx\AtBegShi@Memoir@shipiiB\mem@shipii
569                  \z@
570                \else
571                  \@ne
572                \fi
573              \fi
574         \let\AtBegShi@found\relax
575         \ifx\shipout\AtBegShi@Memoir@shipout
576           \def\AtBegShi@found{\shipout}%
577         \else\ifx\AtBegShi@OrgShipout\AtBegShi@Memoir@shipout
578           \def\AtBegShi@found{\AtBegShi@OrgShipout}%
579         \else\ifx\CROP@shipout\AtBegShi@Memoir@shipout
580           \def\AtBegShi@found{\CROP@shipout}%
581         \else\ifx\GPTorg@shipout\AtBegShi@Memoir@shipout
582           \def\AtBegShi@found{\GPTorg@shipout}%
583         \else\ifx\THBorg@shipout\AtBegShi@Memoir@shipout
584           \def\AtBegShi@found{\THBorg@shipout}%
585         \else\ifx\@EveryShipout@Org@Shipout\AtBegShi@Memoir@shipout
586           \def\AtBegShi@found{\@EveryShipout@Org@Shipout}%
587         \fi\fi\fi\fi\fi\fi
588         \ifx\AtBegShi@found\relax
589         \else
590           \expandafter\endgroup
591           \expandafter\def\AtBegShi@found{%
592             \edef\AtBegShi@GroupLevel{\number\currentgrouplevel}%
593             \afterassignment\mem@shipi
594             \setbox\AtBeginShipoutBox=%
595           }%
596           \def\mem@shipi{%
597             \ifnum\AtBegShi@GroupLevel=\currentgrouplevel
598             \else
599               \expandafter\aftergroup
600             \fi
601             \mem@shipii
602           }%
603           \def\mem@shipii{%
604             \ifvoid\AtBeginShipoutBox
605             \else
606               \setbox\AtBeginShipoutBox=\vbox{%
607                 \trimmarks
608                 \ifvbox\AtBeginShipoutBox
609                   \unvbox\AtBeginShipoutBox
610                 \else
611                   \box\AtBeginShipoutBox
612                 \fi
613               }%
614               \expandafter\mem@oldshipout
615               \expandafter\box
616               \expandafter\AtBeginShipoutBox
617             \fi
618           }%
619           \@PackageInfoNoLine{atbegshi}{Class `memoir' patched}%
620           \begingroup
621         \fi
622       \fi
623     \fi
624   \endgroup
625   \let\AtBegShi@PatchMemoir\relax
626 }
627 \@ifclassloaded{memoir}{%
628   \AtBegShi@PatchMemoir
629 }{%
630   \AtBeginDocument{\AtBegShi@PatchMemoir}%
631 }
632 \AtBegShi@AtEnd
633 \endinput
634 %%
635 %% End of file `atbegshi.sty'.