Debian Codegraph @

texmf-dist/source/latex/everyshi/everyshi.dtx

raw
1 % \iffalse meta-comment
2 %
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %
5 % Copyright (C) Martin Schröder, 1994–2001
6 % Marei Peischl (peiTeX) <[email protected]>, 2020
7 %
8 % This work may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.3c
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % http://www.latex-project.org/lppl.txt
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % This work has the LPPL maintenance status `maintained'.
17 %
18 % The Current Maintainer of this work is
19 % Marei Peischl <[email protected]>.
20 %
21 % This work consists of the files
22 % README.md
23 % everyshi.dtx
24 % everyshi.ins
25 % and the derived files
26 % everyshi.sty
27 % everyshi-2001-05-15.sty
28 % everyshi.pdf
29 %
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 %
32 % \fi
33 % \iffalse
34 %
35 %<package|fallback>\NeedsTeXFormat{LaTeX2e}
36 %<package>\ProvidesPackage{everyshi}
37 %<package> [2020/11/18 v4.00 EveryShipout Package]
38 %
39 %<*driver>
40 \documentclass{ltxdoc}
41 \usepackage{url}
42 \usepackage{everyshi}
43 \GetFileInfo{everyshi.sty}
44 \setcounter{IndexColumns}{2}
45 \EnableCrossrefs
46 \CodelineIndex % Index code by line number
47 %\OnlyDescription % comment out for implementation details
48 \setcounter{IndexColumns}{2}
49 \setlength{\IndexMin}{30ex}
50 \setlength{\columnseprule}{.4pt}
51 \begin{document}
52 \DocInput{everyshi.dtx}
53 \end{document}
54 %</driver>
55 % \fi
56 % \CheckSum{68}
57 %
58 %
59 %% \CharacterTable
60 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
61 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
62 %% Digits \0\1\2\3\4\5\6\7\8\9
63 %% Exclamation \! Double quote \" Hash (number) \#
64 %% Dollar \$ Percent \% Ampersand \&
65 %% Acute accent \' Left paren \( Right paren \)
66 %% Asterisk \* Plus \+ Comma \,
67 %% Minus \- Point \. Solidus \/
68 %% Colon \: Semicolon \; Less than \<
69 %% Equals \= Greater than \> Question mark \?
70 %% Commercial at \@ Left bracket \[ Backslash \\
71 %% Right bracket \] Circumflex \^ Underscore \_
72 %% Grave accent \` Left brace \{ Vertical bar \|
73 %% Right brace \} Tilde \~}
74 %%
75 % \newcommand*{\package}[1]{\textnormal{\sffamily#1}}
76 % \changes{v1.00}{1994/12/04}{New}
77 % \changes{v1.02}{1994/12/07}{Name changed from \textsf{atshipou} to
78 % \textsf{everyshi}}
79 % \changes{v1.03}{1994/12/09}{Documentation improved}
80 % \changes{v2.00}{1995/01/25}{Redesign}
81 % \changes{v2.02}{1998/08/09}{Documentation improved}
82 % \changes{v2.03}{1999/06/08}{Moved to LPPL}
83 % \changes{v3.00}{2001/05/15}{\cs{AtNextShipout} added}
84 % \changes{v4.00}{2020/11/18}{Mark \package{everyshi} as obsolete and use the kernel methods}
85 %
86 % ^^A -----------------------------
87 %
88 % \changes{v2.01}{1997-03-09}{Fixed use of \cs{newline} in title.}
89 % \title{\unskip
90 % The obsolete \package{everyshi} package^^A
91 % \thanks{^^A
92 % The version umber of this file is \fileversion,
93 % last revised \filedate.\protect\newline
94 % The name \textsf{everyshi} is a tribute to the $8+3$
95 % file-naming convention of certain ``operating
96 % systems''; strictly speaking it should be
97 % \textsf{everyshipout}.}^^A
98 % }
99 % \author{Martin Schröder\thanks{maintained by Marei Peischl}}
100 % \date{\filedate}
101 % \maketitle
102 %
103 % ^^A -----------------------------
104 % \renewcommand*{\abstractname}{Why you should no longer use this package:}
105 % \begin{abstract}
106 % This packages provides hooks into \cs{sshipout}
107 % called \cs{EveryShipout} and \cs{AtNextShipout} analogous to
108 % \cs{AtBeginDocument}.
109 %
110 % With the introduction of the \LaTeX{} hook management this package became obsolete in 2020.
111 % Information on their usage can be found in the the corresponding documentation for
112 % \package{lthooks}\cite{lthooks-doc} and \package{ltshipout}\cite{ltshipout-doc}.
113 % We only provide this package to allow backwards compatibility.
114 % For current versions of \LaTeX{} it's only mapping the hooks to the original \package{everyshi} macros.
115 % In case you use an older \LaTeX{} format, \package{everyshi} will automatically fallback to its' old implementation by loading \package{everyshi-2001-05-15}.
116 % \end{abstract}
117 %
118 % \pagestyle{headings}
119 %
120 % ^^A -----------------------------
121 %
122 % \tableofcontents
123 %
124 % ^^A -----------------------------
125 %
126 % \section{Introduction}
127 %
128 % \changes{v4.00}{2020/11/18}{Information on new kernel methods}
129 % This package provides the hooks \cs{EveryShipout} and
130 % \cs{AtNextShipout} whose arguments are executed after the output
131 % routine has constructed \cs{box255}, and before \cs{shipout} is
132 % called.
133 % \changes{v4.00}{2020/11/18}{Remove example applications.}
134 % ^^A -----------------------------
135 %
136 % \section{Usage}
137 %
138 % \cs{EveryShipout}\marg{code} declares
139 % \mbox{$\langle$\emph{code}$\rangle$} that is saved internally
140 % and executed before each \cs{shipout}.
141 %
142 % \emph{Warning:} The \mbox{$\langle$\emph{code}$\rangle$} is saved
143 % globally; there is currently no way to remove it.
144 %
145 % \DescribeMacro{\AtNextShipout}
146 % \cs{AtNextShipout}\marg{code} declares
147 % \mbox{$\langle$\emph{code}$\rangle$} that is saved internally
148 % and executed just before \emph{only the next} \cs{shipout}.
149 %
150 % The \meta{code} is executed after \cs{box255} has been constructed
151 % by the output routine and can change \cs{box255}.
152 % \cs{shipout} is called \emph{after} \meta{code}.
153 %
154 % Repeated use of the commands is permitted: the code in the
155 % argument is stored (and executed) in the order of their
156 % declarations.
157 %
158 % The argument of \cs{AtNextShipout} is executed \emph{after}
159 % the argument of \cs{EveryShipout}.
160 %
161 % ^^A -----------------------------
162 %
163 % \section{Options}
164 %
165 % The package has no options.
166 %
167 % ^^A -----------------------------
168 %
169 % \section{Required packages}
170 %
171 % The package does not require any further packages.
172 %
173 % ^^A -----------------------------
174 %
175 % \begin{thebibliography}{1}
176 % \bibitem{lthooks-doc}
177 % Frank Mittelbach.
178 % \newblock The \package{ltshipout} package.
179 % \newblock \url{http://mirrors.ctan.org/macros/latex/base/lthooks-doc.pdf}
180 % \bibitem{ltshipout-doc}
181 % Frank Mittelbach.
182 % \newblock The \package{ltshipout} package.
183 % \newblock \url{http://mirrors.ctan.org/macros/latex/base/ltshipout-doc.pdf}
184 % \end{thebibliography}
185 %
186 % \StopEventually{^^A
187 % ^^A -----------------------------
188 %
189 % \section{Acknowledgements}
190 % ^^A
191 % Thanks to Ulrike Fischer for the advice during preparation of Version 4.00.
192 % Version 2.0 of \package{everyshi} borrows heavily from
193 % \textsf{quire.tex} of the \textsf{Midnight Macros} by Marcel R.~van
194 % der Goot (\texttt{[email protected]}).
195 % The pointer to \textsf{quire} was provided by Lothar Meyer-Lerbs
196 % (\texttt{\TeX{}[email protected]}).
197 % As usual Rebecca Stiels improved the quality of this documentation.
198 %
199 %
200 % \PrintChanges
201 % }
202 % ^^A -----------------------------
203 %
204 % \section{The implementation}
205 % \changes{v4.00}{2020/11/18}{Emulate everyshi if the kernel is new enough.}
206 % \raggedright
207 % \begin{macrocode}
208 %<*package>
209 \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
210 \IfFormatAtLeastTF{2020/10/01}{}{\input{everyshi-2001-05-15.sty}}
211 \IfFormatAtLeastTF{2020/10/01}{}{\endinput}
212 \protected \def \EveryShipout {\AddToHook{shipout/before}}
213 \protected \def \AtNextShipout {\AddToHookNext{shipout/before}}
214 %</package>
215 % \end{macrocode}
216 % \subsection{The original implementation by Martin Schröder}
217 % To provide compatibility for older \LaTeX{} formats we wrap the
218 % original implementation of \package{everyshi} version 3.00 into
219 % the fallback package \package{everyshi-2001-05-15}.
220 % \begin{macrocode}
221 %<*fallback>
222 \ProvidesPackage{everyshi-2001-05-15}
223 [2020/11/18 v4.00 EveryShipout Package (fallback mechanism)]
224 % \end{macrocode}
225 %
226 % \subsection{Allocations}
227 %
228 % First we allocate the hooks
229 % \begin{macro}{\@EveryShipout@Hook}
230 % \changes{v2.00}{1995/01/25}{Name changed from \cs{@shipouthook} to
231 % \cs{@EveryShipout@Hook}}
232 % \changes{v3.00}{2001/05/15}{\cs{newcommand}}
233 % The code to be executed before \cs{shipout} is stored in
234 % \cs{@EveryShipout@Hook}.
235 % \begin{macrocode}
236 \newcommand{\@EveryShipout@Hook}{}
237 % \end{macrocode}
238 % \end{macro}
239 %
240 % \begin{macro}{\@EveryShipout@AtNextHook}
241 % \changes{v3.00}{2001/05/15}{new}
242 % The code to be executed just before the normal \cs{shipout}
243 % and \cs{@EveryShipout@EveryHook}.
244 % \begin{macrocode}
245 \newcommand{\@EveryShipout@AtNextHook}{}
246 % \end{macrocode}
247 % \end{macro}
248 %
249 %
250 % ^^A -----------------------------
251 %
252 % \subsection{The user-visible commands}
253 % ^^A
254 % \begin{macro}{\EveryShipout}
255 % \begin{macro}{\AtNextShipout}
256 % \changes{v1.01}{1994/12/06}{\cs{newcommand} instead of \cs{def}}
257 % \changes{v1.02}{1994/12/07}{Name changed from \cs{AtShipout} to
258 % \cs{EveryShipOut}}
259 % \changes{v3.00}{2001/05/15}{\cs{AtNextShipout} added}
260 % The commands are modeled after \cs{AtBeginDocument}.
261 % \begin{macrocode}
262 \newcommand*{\EveryShipout}[1]
263 {\g@addto@macro\@EveryShipout@Hook{#1}}
264 \newcommand*{\AtNextShipout}[1]
265 {\g@addto@macro\@EveryShipout@AtNextHook{#1}}
266 % \end{macrocode}
267 % \end{macro}
268 % \end{macro}
269 %
270 %
271 % ^^A -----------------------------
272 %
273 % \subsection{Inserting the hooks}
274 % ^^A
275 % We want to redefine \cs{shipout} so that first \cs{box255} is
276 % constructed and after that we can do something and at last shipout
277 % the (possible modified) \cs{box255}.
278 % Alas, this does not work in the usual way, since \cs{shipout} is
279 % a \TeX{} primitive whose argument is a \meta{box}.
280 % This means that simply redefining \cs{shipout} via \cs{newcommand[1]}
281 % is impossible since \meta{box} can be something like \cs{box255} or
282 % something like \cs{vbox\{\ldots\}}.
283 % In the first case \texttt{\#1} would be \meta{\cs{box}} (without
284 % \meta{255}); in the second case it would be \meta{\cs{vbox}} (without
285 % \meta{\{\ldots\}}).
286 %
287 % The solution we use here is borrowed from \textsf{quire.tex} by
288 % Marcel R.~van der Goot.
289 % It is based upon \cs{afterassignment} and \cs{aftergroup}.
290 %
291 % \begin{macro}{\@EveryShipout@Shipout}
292 % \changes{v2.00}{1995/01/25}{new}
293 % \cs{@EveryShipout@Shipout} is our replacement for \cs{shipout}.
294 % \begin{macrocode}
295 \newcommand{\@EveryShipout@Shipout}{%
296 \afterassignment\@EveryShipout@Test
297 \global\setbox\@cclv= %
298 }
299 % \end{macrocode}
300 % \cs{box255} is set to whatever comes after \cs{shipout}; but after
301 % that assignment \cs{@EveryShipout@Test} is called.
302 % \end{macro}
303 %
304 % \begin{macro}{\@EveryShipout@Test}
305 % \changes{v2.00}{1995/01/25}{new}
306 % \cs{@EveryShipout@Test} determines if \cs{shipout} is called with
307 % an argument like \cs{box255} or something like \cs{vbox\{\ldots\}}.
308 % In the later case we delay the call of \cs{@EveryShipout@Output}
309 % (where the original \cs{shipout} is called) via \cs{aftergroup}.
310 % \begin{macrocode}
311 \newcommand{\@EveryShipout@Test}{%
312 \ifvoid\@cclv\relax
313 \aftergroup\@EveryShipout@Output
314 \else
315 \@EveryShipout@Output
316 \fi%
317 }
318 % \end{macrocode}
319 % \end{macro}
320 %
321 % \begin{macro}{\@EveryShipout@Output}
322 % \changes{v2.00}{1995/01/25}{new}
323 % \changes{v3.00}{2001/05/15}{added call to \cs{@EveryShipout@AtNextHook}}
324 % \cs{@EveryShipout@Output} does the actual work.
325 % First the \meta{code} accumulated via \cs{EveryShipout} and
326 % \cs{AtNextShipout} is called and then the original \cs{shipout} stored
327 % in \cs{@EveryShipout@Org@Shipout} is called to finally ship out
328 % \cs{box255}.
329 % \begin{macrocode}
330 \newcommand{\@EveryShipout@Output}{%
331 \@EveryShipout@Hook%
332 \@EveryShipout@AtNextHook%
333 % \end{macrocode}
334 % We have to reset \cs{@EveryShipout@AtNextHook} after each use.
335 % \begin{macrocode}
336 \gdef\@EveryShipout@AtNextHook{}%
337 \@EveryShipout@Org@Shipout\box\@cclv%
338 }
339 % \end{macrocode}
340 % \end{macro}
341 %
342 % \begin{macro}{\@EveryShipout@Org@Shipout}
343 % \changes{v2.00}{1995/01/25}{new}
344 % The original \cs{shipout} is stored in \cs{@EveryShipout@Org@Shipout}
345 % by \cs{@EveryShipout@Init}.
346 % Here we allocate it.
347 % \begin{macrocode}
348 \newcommand{\@EveryShipout@Org@Shipout}{}
349 % \end{macrocode}
350 % \end{macro}
351 %
352 % \begin{macro}{\@EveryShipout@Init}
353 % \changes{v2.00}{1995/01/25}{new}
354 % \changes{v3.00}{2001/05/15}{output message}
355 % \cs{@EveryShipout@Init} stores the original \cs{shipout} in
356 % \cs{@EveryShipout@Org@Shipout} and sets \cs{shipout} to
357 % \cs{@EveryShipout@Shipout}.
358 % This is done at \cs{begin\{document\}} via \cs{AtBeginDocument}.
359 % \begin{macrocode}
360 \newcommand*{\@EveryShipout@Init}{%
361 \message{ABD: EveryShipout initializing macros}%
362 \let\@EveryShipout@Org@Shipout\shipout
363 \let\shipout\@EveryShipout@Shipout
364 }
365 \AtBeginDocument{\@EveryShipout@Init}
366 % \end{macrocode}
367 % \end{macro}
368 %
369 % \begin{macrocode}
370 %</fallback>
371 % \end{macrocode}
372 %
373 %
374 % ^^A -----------------------------
375 %
376 % \Finale
377 %