2 %% This is file `atbegshi.sty',
3 %% generated with the docstrip utility.
5 %% The original source files were:
7 %% atbegshi.dtx (with options: `package')
9 %% This is a generated file.
11 %% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.de>
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.
21 %% This work has the LPPL maintenance status "maintained".
23 %% This Current Maintainer of this work is Heiko Oberdiek.
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.
37 \expandafter\let\expandafter\x\csname ver@atbegshi.sty\endcsname
50 \expandafter\ifx\csname PackageInfo\endcsname\relax
52 \immediate\write-1{Package #1 Info: #2.}%
55 \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
57 \x{atbegshi}{The package is already loaded}%
74 \expandafter\ifx\csname ProvidesPackage\endcsname\relax
75 \def\x#1#2#3[#4]{\endgroup
76 \immediate\write-1{Package: #3 #4}%
80 \def\x#1#2[#3]{\endgroup
87 \expandafter\x\csname ver@atbegshi.sty\endcsname
88 \ProvidesPackage{atbegshi}%
89 [2007/09/09 v1.6 At begin shipout hook (HO)]
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
106 \def\TMP@EnsureCode#1#2{%
107 \edef\AtBegShi@AtEnd{%
109 \catcode#1 \the\catcode#1\relax
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
127 \RequirePackage{infwarerr}[2007/09/09]%
129 \begingroup\expandafter\expandafter\expandafter\endgroup
130 \expandafter\ifx\csname @ifdefinable\endcsname\relax
131 \def\AtBegShi@CheckDefinable#1{%
142 Package atbegshi: \string#1\space
149 \def\AtBegShi@CheckDefinable#1{%
153 \newif\ifAtBegShi@Discarded
154 \AtBegShi@CheckDefinable\AtBeginShipoutDiscard
155 \def\AtBeginShipoutDiscard{%
157 \global\AtBegShi@Discardedtrue
159 \begingroup\expandafter\expandafter\expandafter\endgroup
160 \expandafter\ifx\csname currentgrouplevel\endcsname\relax
161 \catcode`X=9 % ignore
162 \catcode`E=14 % comment
164 \catcode`X=14 % comment
165 \catcode`E=9 % ignore
167 \def\AtBegShi@Shipout{%
169 X \setbox\AtBeginShipoutBox=\hbox\bgroup
171 E \edef\AtBegShi@GroupLevel{\number\currentgrouplevel}%
172 \afterassignment\AtBegShi@Test
174 \setbox\AtBeginShipoutBox=%
177 X \ifdim\lastkern=\z@
178 E \ifnum\AtBegShi@GroupLevel<\currentgrouplevel
179 \expandafter\aftergroup
183 \def\AtBegShi@Output{%
186 \ifvoid\AtBeginShipoutBox
187 \@PackageWarning{atbegshi}{Ignoring void shipout box}%
189 \let\AtBegShi@OrgProtect\protect
190 \csname set@typeset@protect\endcsname
191 \global\AtBegShi@Discardedfalse
194 \gdef\AtBegShi@HookNext{}%
195 \ifAtBegShi@Discarded
196 \@PackageInfoNoLine{atbegshi}{Shipout page discarded}%
197 \global\AtBegShi@Discardedfalse
199 \setbox\AtBeginShipoutBox\box\AtBeginShipoutBox
201 \let\protect\AtBegShi@OrgProtect
204 \let\protect\AtBegShi@OrgProtect
205 \AtBegShi@OrgShipout\box\AtBeginShipoutBox
211 \def\AtBegShi@First{%
214 \ifx\AtBegShi@HookFirst\@empty
224 \global\setbox\AtBeginShipoutBox=\vbox{%
229 \copy\AtBeginShipoutBox
232 \global\let\AtBegShi@First\@empty
233 \global\let\AtBeginShipoutFirst\AtBegShi@FirstDisabled
236 \gdef\AtBegShi@Hook{}
237 \gdef\AtBegShi@HookNext{}
238 \gdef\AtBegShi@HookFirst{}
239 \AtBegShi@CheckDefinable\AtBeginShipout
240 \def\AtBeginShipout{%
241 \AtBegShi@AddHook\AtBegShi@Hook
243 \AtBegShi@CheckDefinable\AtBeginShipoutNext
244 \def\AtBeginShipoutNext{%
245 \AtBegShi@AddHook\AtBegShi@HookNext
247 \AtBegShi@CheckDefinable\AtBeginShipoutFirst
248 \def\AtBeginShipoutFirst{%
249 \AtBegShi@AddTo\AtBegShi@HookFirst
251 \long\def\AtBegShi@FirstDisabled#1{%
252 \@PackageWarning{atbegshi}{%
253 First page is already shipped out, ignoring\MessageBreak
254 \string\AtBeginShipoutFirst
257 \begingroup\expandafter\expandafter\expandafter\endgroup
258 \expandafter\ifx\csname g@addto@macro\endcsname\relax
259 \long\def\AtBegShi@AddTo#1#2{%
261 \toks\z@\expandafter{#1#2}%
262 \xdef#1{\the\toks\z@}%
266 \let\AtBegShi@AddTo\g@addto@macro
268 \long\def\AtBegShi@AddHook#1#2{%
269 \AtBegShi@AddTo#1{\AtBegShi@Item{#2}}%
271 \long\def\AtBegShi@Item#1{%
272 \ifAtBegShi@Discarded
275 \ifvoid\AtBeginShipoutBox
276 \@PackageWarning{atbegshi}{%
277 Shipout box was voided by hook,\MessageBreak
278 ignoring shipout box%
280 \AtBeginShipoutDiscard
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{}%
292 \begingroup\expandafter\expandafter\expandafter\endgroup
293 \expandafter\ifx\csname AtBeginDocument\endcsname\relax
296 \AtBeginDocument{\AtBeginShipoutInit}%
298 \begingroup\expandafter\expandafter\expandafter\endgroup
299 \expandafter\ifx\csname RequirePackage\endcsname\relax
300 \input ifpdf.sty\relax
302 \RequirePackage{ifpdf}\relax
305 \def\AtBegShi@horigin{\pdfhorigin}%
306 \def\AtBegShi@vorigin{\pdfvorigin}%
308 \def\AtBegShi@horigin{72.27pt}%
309 \def\AtBegShi@vorigin{72.27pt}%
313 \expandafter\ifx\csname picture\endcsname\relax
316 \expandafter\ifx\csname endpicture\endcsname\relax
323 \def\AtBegShi@BeginPicture{%
326 \begingroup\expandafter\expandafter\expandafter\endgroup
327 \expandafter\ifx\csname unitlength\endcsname\relax
329 \unitlength=1pt\relax
333 \def\AtBegShi@EndPicture{%
339 \def\AtBegShi@BeginPicture{%
340 \setbox0=\hbox\bgroup
344 \def\AtBegShi@EndPicture{%
352 \def\AtBeginShipoutUpperLeft#1{%
353 \global\setbox\AtBeginShipoutBox=\hbox{%
355 \kern-\AtBegShi@horigin\relax
357 \kern-\AtBegShi@vorigin\relax
358 \kern-\ht\AtBeginShipoutBox
359 \AtBegShi@BeginPicture
365 \box\AtBeginShipoutBox
368 \def\AtBegShi@AbortIfUndefined#1{%
369 \begingroup\expandafter\expandafter\expandafter\endgroup
370 \expandafter\ifx\csname#1\endcsname\relax
372 \expandafter\endinput
375 \AtBegShi@AbortIfUndefined{currentgrouplevel}
376 \AtBegShi@AbortIfUndefined{AtBeginDocument}
377 \AtBegShi@AbortIfUndefined{@ifpackageloaded}
378 \AtBegShi@AbortIfUndefined{@ifclassloaded}
379 \def\AtBegShi@PatchCrop{%
381 \def\AtBegShi@Crop@shipout{%
382 \afterassignment\CROP@ship
385 \def\AtBegShi@Crop@ship{%
387 \expandafter\aftergroup
391 \def\AtBegShi@Crop@shiplist{%
398 \def\AtBegShi@Crop@@ship{%
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}%
420 \ifx\AtBegShi@found\relax
422 \expandafter\endgroup
423 \expandafter\def\AtBegShi@found{%
424 \edef\AtBegShi@GroupLevel{\number\currentgrouplevel}%
425 \afterassignment\CROP@ship
426 \setbox\AtBeginShipoutBox=%
429 \ifnum\AtBegShi@GroupLevel=\currentgrouplevel
431 \expandafter\aftergroup
440 \box\AtBeginShipoutBox
443 \ifvoid\AtBeginShipoutBox
445 \setbox\AtBeginShipoutBox=\vbox{%
448 \expandafter\CROP@shipout
450 \expandafter\AtBeginShipoutBox
453 \@PackageInfoNoLine{atbegshi}{Package `crop' patched}%
460 \let\AtBegShi@PatchCrop\relax
462 \@ifpackageloaded{crop}{%
465 \AtBeginDocument{\AtBegShi@PatchCrop}%
467 \def\AtBegShi@PatchEveryshi{%
469 \long\def\AtBegShi@Everyshi@shipout{%
470 \afterassignment\@EveryShipout@Test
471 \global\setbox\@cclv= %
473 \long\def\AtBegShi@Everyshi@Test{%
475 \aftergroup\@EveryShipout@Output
477 \@EveryShipout@Output
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}%
495 \expandafter\ifx\csname @EveryShipout@Org@Shipout\endcsname
497 \ifx\@EveryShipout@Shipout\AtBegShi@Everyshi@shipout
498 \def\AtBegShi@found{\@EveryShipout@Shipout}%
502 \ifx\AtBegShi@found\relax
504 \expandafter\endgroup
505 \expandafter\def\AtBegShi@found{%
506 \edef\AtBegShi@GroupLevel{\number\currentgrouplevel}%
507 \afterassignment\@EveryShipout@Test
508 \setbox\AtBeginShipoutBox=%
510 \def\@EveryShipout@Test{%
511 \ifnum\AtBegShi@GroupLevel=\currentgrouplevel
513 \expandafter\aftergroup
515 \AtBegShi@Everyshi@Output
517 \def\AtBegShi@Everyshi@Output{%
518 \ifvoid\AtBeginShipoutBox
520 \global\setbox\@cclv\box\AtBeginShipoutBox
521 \expandafter\@EveryShipout@Output
524 \@PackageInfoNoLine{atbegshi}{Package `everyshi' patched}%
529 \let\AtBegShi@PatchEveryshi\relax
531 \@ifpackageloaded{everyshi}{%
532 \AtBegShi@PatchEveryshi
534 \AtBeginDocument{\AtBegShi@PatchEveryshi}%
536 \def\AtBegShi@PatchMemoir{%
538 \def\AtBegShi@Memoir@shipout{%
539 \afterassignment\mem@shipi
542 \def\AtBegShi@Memoir@shipi{%
544 \expandafter\aftergroup
548 \def\AtBegShi@Memoir@shipiiA{%
549 \mem@oldshipout\vbox{%
554 \def\AtBegShi@Memoir@shipiiB{%
556 \mem@oldshipout\box\@cclv
558 \mem@oldshipout\vbox{%
564 \ifx\AtBegShi@Memoir@shipi\mem@shipi
565 \ifcase\ifx\AtBegShi@Memoir@shipiiA\mem@shipii
568 \ifx\AtBegShi@Memoir@shipiiB\mem@shipii
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}%
588 \ifx\AtBegShi@found\relax
590 \expandafter\endgroup
591 \expandafter\def\AtBegShi@found{%
592 \edef\AtBegShi@GroupLevel{\number\currentgrouplevel}%
593 \afterassignment\mem@shipi
594 \setbox\AtBeginShipoutBox=%
597 \ifnum\AtBegShi@GroupLevel=\currentgrouplevel
599 \expandafter\aftergroup
604 \ifvoid\AtBeginShipoutBox
606 \setbox\AtBeginShipoutBox=\vbox{%
608 \ifvbox\AtBeginShipoutBox
609 \unvbox\AtBeginShipoutBox
611 \box\AtBeginShipoutBox
614 \expandafter\mem@oldshipout
616 \expandafter\AtBeginShipoutBox
619 \@PackageInfoNoLine{atbegshi}{Class `memoir' patched}%
625 \let\AtBegShi@PatchMemoir\relax
627 \@ifclassloaded{memoir}{%
628 \AtBegShi@PatchMemoir
630 \AtBeginDocument{\AtBegShi@PatchMemoir}%
635 %% End of file `atbegshi.sty'.