Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % File: atenddvi.dtx
4 % Version: 2020-11-11 v1.5
5 % Info: At end DVI hook
6 %
7 % Copyright (C)
8 % 2007 Heiko Oberdiek
9 % 2016-2020 Oberdiek Package Support Group
10 % https://github.com/ho-tex/atenddvi/issues
11 %
12 % This work may be distributed and/or modified under the
13 % conditions of the LaTeX Project Public License, either
14 % version 1.3c of this license or (at your option) any later
15 % version. This version of this license is in
16 % https://www.latex-project.org/lppl/lppl-1-3c.txt
17 % and the latest version of this license is in
18 % https://www.latex-project.org/lppl.txt
19 % and version 1.3 or later is part of all distributions of
20 % LaTeX version 2005/12/01 or later.
21 %
22 % This work has the LPPL maintenance status "maintained".
23 %
24 % The Current Maintainers of this work are
25 % Heiko Oberdiek and the Oberdiek Package Support Group
26 % https://github.com/ho-tex/atenddvi/issues
27 %
28 % This work consists of the main source file atenddvi.dtx
29 % and the derived files
30 % atenddvi.sty, atenddvi.pdf, atenddvi.ins, atenddvi.drv.
31 %
32 % Distribution:
33 % CTAN:macros/latex/contrib/atenddvi/atenddvi.dtx
34 % CTAN:macros/latex/contrib/atenddvi/atenddvi.pdf
35 %
36 % Unpacking:
37 % (a) If atenddvi.ins is present:
38 % tex atenddvi.ins
39 % (b) Without atenddvi.ins:
40 % tex atenddvi.dtx
41 % (c) If you insist on using LaTeX
42 % latex \let\install=y\input{atenddvi.dtx}
43 % (quote the arguments according to the demands of your shell)
44 %
45 % Documentation:
46 % (a) If atenddvi.drv is present:
47 % latex atenddvi.drv
48 % (b) Without atenddvi.drv:
49 % latex atenddvi.dtx; ...
50 % The class ltxdoc loads the configuration file ltxdoc.cfg
51 % if available. Here you can specify further options, e.g.
52 % use A4 as paper format:
53 % \PassOptionsToClass{a4paper}{article}
54 %
55 % Programm calls to get the documentation (example):
56 % pdflatex atenddvi.dtx
57 % makeindex -s gind.ist atenddvi.idx
58 % pdflatex atenddvi.dtx
59 % makeindex -s gind.ist atenddvi.idx
60 % pdflatex atenddvi.dtx
61 %
62 % Installation:
63 % TDS:tex/latex/atenddvi/atenddvi.sty
64 % TDS:tex/latex/atenddvi/atenddvi-2019-12-11.sty
65 % TDS:doc/latex/atenddvi/atenddvi.pdf
66 % TDS:source/latex/atenddvi/atenddvi.dtx
67 %
68 %<*ignore>
69 \begingroup
70 \catcode123=1 %
71 \catcode125=2 %
72 \def\x{LaTeX2e}%
73 \expandafter\endgroup
74 \ifcase 0\ifx\install y1\fi\expandafter
75 \ifx\csname processbatchFile\endcsname\relax\else1\fi
76 \ifx\fmtname\x\else 1\fi\relax
77 \else\csname fi\endcsname
78 %</ignore>
79 %<*install>
80 \input docstrip.tex
81 \Msg{************************************************************************}
82 \Msg{* Installation}
83 \Msg{* Package: atenddvi 2020-11-11 v1.5 At end DVI hook (HO)}
84 \Msg{************************************************************************}
85
86 \keepsilent
87 \askforoverwritefalse
88
89 \let\MetaPrefix\relax
90 \preamble
91
92 This is a generated file.
93
94 Project: atenddvi
95 Version: 2020-11-11 v1.5
96
97 Copyright (C)
98 2007 Heiko Oberdiek
99 2016-2020 Oberdiek Package Support Group
100
101 This work may be distributed and/or modified under the
102 conditions of the LaTeX Project Public License, either
103 version 1.3c of this license or (at your option) any later
104 version. This version of this license is in
105 https://www.latex-project.org/lppl/lppl-1-3c.txt
106 and the latest version of this license is in
107 https://www.latex-project.org/lppl.txt
108 and version 1.3 or later is part of all distributions of
109 LaTeX version 2005/12/01 or later.
110
111 This work has the LPPL maintenance status "maintained".
112
113 The Current Maintainers of this work are
114 Heiko Oberdiek and the Oberdiek Package Support Group
115 https://github.com/ho-tex/atenddvi/issues
116
117
118 This work consists of the main source file atenddvi.dtx
119 and the derived files
120 atenddvi.sty, atenddvi.pdf, atenddvi.ins, atenddvi.drv.
121
122 \endpreamble
123 \let\MetaPrefix\DoubleperCent
124
125 \generate{%
126 \file{atenddvi.ins}{\from{atenddvi.dtx}{install}}%
127 \file{atenddvi.drv}{\from{atenddvi.dtx}{driver}}%
128 \usedir{tex/latex/atenddvi}%
129 \file{atenddvi.sty}{\from{atenddvi.dtx}{package}}%
130 \file{atenddvi-2019-12-11.sty}{\from{atenddvi.dtx}{packagefrozen}}
131 }
132
133 \catcode32=13\relax% active space
134 \let =\space%
135 \Msg{************************************************************************}
136 \Msg{*}
137 \Msg{* To finish the installation you have to move the following}
138 \Msg{* file into a directory searched by TeX:}
139 \Msg{*}
140 \Msg{* atenddvi.sty}
141 \Msg{*}
142 \Msg{* To produce the documentation run the file `atenddvi.drv'}
143 \Msg{* through LaTeX.}
144 \Msg{*}
145 \Msg{* Happy TeXing!}
146 \Msg{*}
147 \Msg{************************************************************************}
148
149 \endbatchfile
150 %</install>
151 %<*ignore>
152 \fi
153 %</ignore>
154 %<*driver>
155 \NeedsTeXFormat{LaTeX2e}
156 \ProvidesFile{atenddvi.drv}%
157 [2020-11-11 v1.5 At end DVI hook (HO)]%
158 \documentclass{ltxdoc}
159 \usepackage{holtxdoc}[2011/11/22]
160 \begin{document}
161 \DocInput{atenddvi.dtx}%
162 \end{document}
163 %</driver>
164 % \fi
165 %
166 %
167 %
168 % \GetFileInfo{atenddvi.drv}
169 %
170 % \title{The \xpackage{atenddvi} package}
171 % \date{2020-11-11 v1.5}
172 % \author{Heiko Oberdiek\thanks
173 % {Please report any issues at \url{https://github.com/ho-tex/atenddvi/issues}}}
174 %
175 % \maketitle
176 %
177 % \textbf{This package is unneeded and does nothing with a \LaTeX{} version
178 % 2020-10-01 or newer as \cs{AtBeginDvi} is then provided by the format.}
179 %
180 % \begin{abstract}
181 % \LaTeX\ offers \cs{AtBeginDvi}. This package \xpackage{atenddvi}
182 % provides the counterpart \cs{AtEndDvi}. The execution of its
183 % argument is delayed to the end of the document at the end of the
184 % last page. Thus \cs{special} and \cs{write} remain effective, because
185 % they are put into the last page. This is the main difference
186 % to \cs{AtEndDocument}.
187 % \end{abstract}
188 %
189 % \tableofcontents
190 %
191 % \section{Documentation}
192 %
193 % \begin{declcs}{AtEndDvi} \M{code}
194 % \end{declcs}
195 % Macro \cs{AtEndDvi} provides a hook mechanism to put \meta{code}
196 % at the end of the last output page. It is the logical counterpart
197 % to \cs{AtBeginDvi}. Despite the name the output type DVI, PDF or whatever
198 % does not matter.
199 %
200 % Unlike \cs{AtBeginDvi} the \meta{code} is not put in a box and
201 % therefore executed immediately. The hook for \cs{AtEndDvi} is based on
202 % a macro similar to \cs{AtBeginDocument} or \cs{AtEndDocument}. The
203 % execution of \meta{code} is delayed until the hook is executed on
204 % the last page.
205 %
206 % Commands such as \cs{special} or \cs{write} (not the \cs{immediate}
207 % variant) must go as nodes into the contents of a page to have the
208 % desired effect.
209 % When the hook for \cs{AtEndDocument} is executed, the last intended
210 % page may already be shipped out. Therefore \cs{special} or \cs{write}
211 % cannot be used in a reliable way without generating new page.
212 %
213 % This gap is closed by \cs{AtEndDvi} of this package \xpackage{atenddvi}.
214 % If the document is compiled the first time, the package remembers
215 % the last page in a reference. In the sceond run, it puts the hook
216 % on the page that has been detected in the previous run as last page.
217 % The package detectes if the number of pages has changed, and then
218 % generates a warning to rerun \LaTeX.
219 %
220 % \StopEventually{
221 % }
222 %
223 % \section{Implementation}
224 % \begin{macrocode}
225 %<*package>
226 \NeedsTeXFormat{LaTeX2e}
227 \ProvidesPackage{atenddvi}%
228 [2020-11-11 v1.5 At end DVI hook (HO)]%
229 \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
230 \IfFormatAtLeastTF{2020/10/01}
231 {%
232 \PackageWarning{atenddvi}
233 {Functionality of this package is already\MessageBreak
234 provided by LaTeX.\MessageBreak\MessageBreak
235 It is therefore no longer necessary to load it\MessageBreak
236 and you can safely remove it.\MessageBreak
237 Found on}{}%
238 }{\input{atenddvi-2019-12-11.sty}}
239 \IfFormatAtLeastTF{2020/10/01}{}{\endinput}
240
241 %</package>
242 % \end{macrocode}
243 %
244 % \begin{macrocode}
245 %<*packagefrozen>
246 \NeedsTeXFormat{LaTeX2e}
247 \ProvidesPackage{atenddvi}%
248 [2020-11-11 v1.5 At end DVI hook / legacy frozen code (HO) ]%
249 % \end{macrocode}
250 %
251 % Load the required packages
252 % \begin{macrocode}
253 \RequirePackage{zref-abspage,zref-lastpage}[2007/03/19]
254 \RequirePackage{atbegshi}
255 % \end{macrocode}
256 %
257 % \begin{macro}{\AtEndDvi@Hook}
258 % Macro \cs{AtEndDvi@Hook} is the data storage macro
259 % for the code that is executed later at end of the last page.
260 % \begin{macrocode}
261 \let\AtEndDvi@Hook\@empty
262 % \end{macrocode}
263 % \end{macro}
264 % \begin{macro}{\AtEndDvi}
265 % Macro \cs{AtEndDvi} is called in the same way as
266 % \cs{AtBeginDocument}. The argument is added to the hook macro.
267 % \begin{macrocode}
268 \newcommand*{\AtEndDvi}{%
269 \g@addto@macro\AtEndDvi@Hook
270 }
271 % \end{macrocode}
272 % \end{macro}
273 %
274 % \begin{macro}{\AtEndDvi@AtBeginShipout}
275 % \begin{macrocode}
276 \def\AtEndDvi@AtBeginShipout{%
277 \begingroup
278 % \end{macrocode}
279 % The reference `LastPage' is marked used. If the reference
280 % is not yet defined, then the user gets the warning because of
281 % the undefined reference and the rerun warning at the end of
282 % the compile run. However, we do not need a warning each page,
283 % the first page is enough.
284 % \begin{macrocode}
285 \ifnum\value{abspage}=1 %
286 \zref@refused{LastPage}%
287 \fi
288 % \end{macrocode}
289 % The current absolute page number is compared with the
290 % absolute page number of the reference `LastPage'.
291 % \begin{macrocode}
292 \ifnum\zref@extractdefault{LastPage}{abspage}{0}=\value{abspage}%
293 % \end{macrocode}
294 % \begin{macro}{\AtEndDvi@LastPage}
295 % We found the right page and remember it in a macro.
296 % \begin{macrocode}
297 \xdef\AtEndDvi@LastPage{\number\value{abspage}}%
298 % \end{macrocode}
299 % \end{macro}
300 % The hook of \cs{AtEndDvi} is now put on the last page
301 % after the contents of the page.
302 % \begin{macrocode}
303 \global\setbox\AtBeginShipoutBox=\vbox{%
304 \hbox{%
305 \box\AtBeginShipoutBox
306 \setbox\AtBeginShipoutBox=\hbox{%
307 \begingroup
308 \AtEndDvi@Hook
309 \endgroup
310 }%
311 \wd\AtBeginShipoutBox=\z@
312 \ht\AtBeginShipoutBox=\z@
313 \dp\AtBeginShipoutBox=\z@
314 \box\AtBeginShipoutBox
315 }%
316 }%
317 % \end{macrocode}
318 % We do not need the every page hook.
319 % \begin{macrocode}
320 \global\let\AtEndDvi@AtBeginShipout\@empty
321 % \end{macrocode}
322 % The hook is consumed, \cs{AtEndDvi} does not have an effect.
323 % \begin{macrocode}
324 \global\let\AtEndDvi\@gobble
325 % \end{macrocode}
326 % Make a protocol entry, which page is used by this package
327 % as last page.
328 % \begin{macrocode}
329 \let\on@line\@empty
330 \PackageInfo{atenddvi}{Last page = \AtEndDvi@LastPage}%
331 \fi
332 \endgroup
333 }
334 % \end{macrocode}
335 % \end{macro}
336 %
337 % \begin{macro}{\AtEndDvi@AtBeginDocument}
338 % In order to get as late as possible in the chain of the
339 % every shipout hook, the call of \cs{AtBeginShipout} is delayed.
340 % \begin{macrocode}
341 \def\AtEndDvi@AtBeginDocument{%
342 \AtBeginShipout{\AtEndDvi@AtBeginShipout}%
343 % \end{macrocode}
344 % \begin{macro}{\AtEndDvi@Check}
345 % After \cs{AtEndDocument} \LaTeX\ reads its \xfile{.aux} files
346 % again. Code in \cs{AtEndDocument} could generate additional
347 % pages. This is unlikely by code in the \xfile{.aux} file,
348 % thus we use the \xfile{.aux} file to run macro
349 % \cs{AtEndDvi@Check} for checking the last page.
350 %
351 % During the first reading of the \xfile{.aux} file,
352 % \cs{AtEndDvi@Check} is disabled, its real meaning
353 % is assigned afterwards.
354 % \begin{macrocode}
355 \if@filesw
356 \immediate\write\@mainaux{%
357 \string\providecommand\string\AtEndDvi@Check{}%
358 }%
359 \immediate\write\@mainaux{%
360 \string\AtEndDvi@Check
361 }%
362 \fi
363 \let\AtEndDvi@Check\AtEndDvi@CheckImpl
364 }
365 % \end{macrocode}
366 % \end{macro}
367 % \begin{macrocode}
368 \AtBeginDocument{\AtEndDvi@AtBeginDocument}
369 % \end{macrocode}
370 % \end{macro}
371 %
372 % \begin{macro}{\AtEndDvi@CheckImpl}
373 % First check is whether a last page was found at all.
374 % Secondly the found last page is compared with the real last page.
375 % \begin{macrocode}
376 \def\AtEndDvi@CheckImpl{%
377 \@ifundefined{AtEndDvi@LastPage}{%
378 \PackageWarningNoLine{atenddvi}{%
379 Rerun LaTeX, last page not yet found%
380 }%
381 }{%
382 \ifnum\AtEndDvi@LastPage=\value{abspage}%
383 \else
384 \PackageWarningNoLine{atenddvi}{%
385 Rerun LaTeX, last page has changed%
386 }%
387 \fi
388 }%
389 }
390 % \end{macrocode}
391 % \end{macro}
392 %
393 % \begin{macrocode}
394 %</packagefrozen>
395 % \end{macrocode}
396 %
397 % \section{Installation}
398 %
399 % \subsection{Download}
400 %
401 % \paragraph{Package.} This package is available on
402 % CTAN\footnote{\CTANpkg{atenddvi}}:
403 % \begin{description}
404 % \item[\CTAN{macros/latex/contrib/atenddvi/atenddvi.dtx}] The source file.
405 % \item[\CTAN{macros/latex/contrib/atenddvi/atenddvi.pdf}] Documentation.
406 % \end{description}
407 %
408 % \subsection{Package installation}
409 %
410 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
411 % \docstrip\ archive. The files are extracted by running the
412 % \xfile{.dtx} through \plainTeX:
413 % \begin{quote}
414 % \verb|tex atenddvi.dtx|
415 % \end{quote}
416 %
417 % \paragraph{TDS.} Now the different files must be moved into
418 % the different directories in your installation TDS tree
419 % (also known as \xfile{texmf} tree):
420 % \begin{quote}
421 % \def\t{^^A
422 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
423 % atenddvi.sty & tex/latex/atenddvi/atenddvi.sty\\
424 % atenddvi-2019-12-11.sty & atenddvi-2019-12-11.sty\\
425 % atenddvi.pdf & doc/latex/atenddvi/atenddvi.pdf\\
426 % atenddvi.dtx & source/latex/atenddvi/atenddvi.dtx\\
427 % \end{tabular}^^A
428 % }^^A
429 % \sbox0{\t}^^A
430 % \ifdim\wd0>\linewidth
431 % \begingroup
432 % \advance\linewidth by\leftmargin
433 % \advance\linewidth by\rightmargin
434 % \edef\x{\endgroup
435 % \def\noexpand\lw{\the\linewidth}^^A
436 % }\x
437 % \def\lwbox{^^A
438 % \leavevmode
439 % \hbox to \linewidth{^^A
440 % \kern-\leftmargin\relax
441 % \hss
442 % \usebox0
443 % \hss
444 % \kern-\rightmargin\relax
445 % }^^A
446 % }^^A
447 % \ifdim\wd0>\lw
448 % \sbox0{\small\t}^^A
449 % \ifdim\wd0>\linewidth
450 % \ifdim\wd0>\lw
451 % \sbox0{\footnotesize\t}^^A
452 % \ifdim\wd0>\linewidth
453 % \ifdim\wd0>\lw
454 % \sbox0{\scriptsize\t}^^A
455 % \ifdim\wd0>\linewidth
456 % \ifdim\wd0>\lw
457 % \sbox0{\tiny\t}^^A
458 % \ifdim\wd0>\linewidth
459 % \lwbox
460 % \else
461 % \usebox0
462 % \fi
463 % \else
464 % \lwbox
465 % \fi
466 % \else
467 % \usebox0
468 % \fi
469 % \else
470 % \lwbox
471 % \fi
472 % \else
473 % \usebox0
474 % \fi
475 % \else
476 % \lwbox
477 % \fi
478 % \else
479 % \usebox0
480 % \fi
481 % \else
482 % \lwbox
483 % \fi
484 % \else
485 % \usebox0
486 % \fi
487 % \end{quote}
488 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
489 % TDS installing feature, then some files can already be in the right
490 % place, see the documentation of \docstrip.
491 %
492 % \subsection{Refresh file name databases}
493 %
494 % If your \TeX~distribution
495 % (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
496 % these. For example, \TeX\,Live\ users run \verb|texhash| or
497 % \verb|mktexlsr|.
498 %
499 % \subsection{Some details for the interested}
500 %
501 % \paragraph{Unpacking with \LaTeX.}
502 % The \xfile{.dtx} chooses its action depending on the format:
503 % \begin{description}
504 % \item[\plainTeX:] Run \docstrip\ and extract the files.
505 % \item[\LaTeX:] Generate the documentation.
506 % \end{description}
507 % If you insist on using \LaTeX\ for \docstrip\ (really,
508 % \docstrip\ does not need \LaTeX), then inform the autodetect routine
509 % about your intention:
510 % \begin{quote}
511 % \verb|latex \let\install=y\input{atenddvi.dtx}|
512 % \end{quote}
513 % Do not forget to quote the argument according to the demands
514 % of your shell.
515 %
516 % \paragraph{Generating the documentation.}
517 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
518 % the documentation. The process can be configured by the
519 % configuration file \xfile{ltxdoc.cfg}. For instance, put this
520 % line into this file, if you want to have A4 as paper format:
521 % \begin{quote}
522 % \verb|\PassOptionsToClass{a4paper}{article}|
523 % \end{quote}
524 % An example follows how to generate the
525 % documentation with pdf\LaTeX:
526 % \begin{quote}
527 %\begin{verbatim}
528 %pdflatex atenddvi.dtx
529 %makeindex -s gind.ist atenddvi.idx
530 %pdflatex atenddvi.dtx
531 %makeindex -s gind.ist atenddvi.idx
532 %pdflatex atenddvi.dtx
533 %\end{verbatim}
534 % \end{quote}
535 %
536 % \begin{History}
537 % \begin{Version}{2007/03/20 v1.0}
538 % \item
539 % First version.
540 % \end{Version}
541 % \begin{Version}{2007/04/17 v1.1}
542 % \item
543 % Package \xpackage{atbegshi} replaces package \xpackage{everyshi}.
544 % \end{Version}
545 % \begin{Version}{2016/05/16 v1.2}
546 % \item
547 % Documentation updates.
548 % \end{Version}
549 % \begin{Version}{2019/12/05 v1.3}
550 % \item
551 % Documentation updates.
552 % \end{Version}
553 % \begin{Version}{2019-12-11 v1.4}
554 % \item Updated
555 % \end{Version}
556 % \begin{Version}{2020-11-11 v1.5}
557 % \item The package is now unneeded as LaTeX formats
558 % newer than 2020-10-01 provide \cs{AtBeginDvi} and so does nothing
559 % in this case.
560 % The old code has been frozen.
561 % \end{Version}
562 % \end{History}
563 %
564 % \PrintIndex
565 %
566 % \Finale
567 \endinput