Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % File: auxhook.dtx
4 % Version: 2019-12-17 v1.6
5 % Info: Hooks for auxiliary files
6 %
7 % Copyright (C)
8 % 2006, 2007, 2009, 2011 Heiko Oberdiek
9 % 2016-2019 Oberdiek Package Support Group
10 % https://github.com/ho-tex/auxhook/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/auxhook/issues
27 %
28 % This work consists of the main source file auxhook.dtx
29 % and the derived files
30 % auxhook.sty, auxhook.pdf, auxhook.ins, auxhook.drv.
31 %
32 % Distribution:
33 % CTAN:macros/latex/contrib/auxhook/auxhook.dtx
34 % CTAN:macros/latex/contrib/auxhook/auxhook.pdf
35 %
36 % Unpacking:
37 % (a) If auxhook.ins is present:
38 % tex auxhook.ins
39 % (b) Without auxhook.ins:
40 % tex auxhook.dtx
41 % (c) If you insist on using LaTeX
42 % latex \let\install=y\input{auxhook.dtx}
43 % (quote the arguments according to the demands of your shell)
44 %
45 % Documentation:
46 % (a) If auxhook.drv is present:
47 % latex auxhook.drv
48 % (b) Without auxhook.drv:
49 % latex auxhook.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 auxhook.dtx
57 % makeindex -s gind.ist auxhook.idx
58 % pdflatex auxhook.dtx
59 % makeindex -s gind.ist auxhook.idx
60 % pdflatex auxhook.dtx
61 %
62 % Installation:
63 % TDS:tex/latex/auxhook/auxhook.sty
64 % TDS:doc/latex/auxhook/auxhook.pdf
65 % TDS:source/latex/auxhook/auxhook.dtx
66 %
67 %<*ignore>
68 \begingroup
69 \catcode123=1 %
70 \catcode125=2 %
71 \def\x{LaTeX2e}%
72 \expandafter\endgroup
73 \ifcase 0\ifx\install y1\fi\expandafter
74 \ifx\csname processbatchFile\endcsname\relax\else1\fi
75 \ifx\fmtname\x\else 1\fi\relax
76 \else\csname fi\endcsname
77 %</ignore>
78 %<*install>
79 \input docstrip.tex
80 \Msg{************************************************************************}
81 \Msg{* Installation}
82 \Msg{* Package: auxhook 2019-12-17 v1.6 Hooks for auxiliary files (HO)}
83 \Msg{************************************************************************}
84
85 \keepsilent
86 \askforoverwritefalse
87
88 \let\MetaPrefix\relax
89 \preamble
90
91 This is a generated file.
92
93 Project: auxhook
94 Version: 2019-12-17 v1.6
95
96 Copyright (C)
97 2006, 2007, 2009, 2011 Heiko Oberdiek
98 2016-2019 Oberdiek Package Support Group
99
100 This work may be distributed and/or modified under the
101 conditions of the LaTeX Project Public License, either
102 version 1.3c of this license or (at your option) any later
103 version. This version of this license is in
104 https://www.latex-project.org/lppl/lppl-1-3c.txt
105 and the latest version of this license is in
106 https://www.latex-project.org/lppl.txt
107 and version 1.3 or later is part of all distributions of
108 LaTeX version 2005/12/01 or later.
109
110 This work has the LPPL maintenance status "maintained".
111
112 The Current Maintainers of this work are
113 Heiko Oberdiek and the Oberdiek Package Support Group
114 https://github.com/ho-tex/auxhook/issues
115
116
117 This work consists of the main source file auxhook.dtx
118 and the derived files
119 auxhook.sty, auxhook.pdf, auxhook.ins, auxhook.drv.
120
121 \endpreamble
122 \let\MetaPrefix\DoubleperCent
123
124 \generate{%
125 \file{auxhook.ins}{\from{auxhook.dtx}{install}}%
126 \file{auxhook.drv}{\from{auxhook.dtx}{driver}}%
127 \usedir{tex/latex/auxhook}%
128 \file{auxhook.sty}{\from{auxhook.dtx}{package}}%
129 }
130
131 \catcode32=13\relax% active space
132 \let =\space%
133 \Msg{************************************************************************}
134 \Msg{*}
135 \Msg{* To finish the installation you have to move the following}
136 \Msg{* file into a directory searched by TeX:}
137 \Msg{*}
138 \Msg{* auxhook.sty}
139 \Msg{*}
140 \Msg{* To produce the documentation run the file `auxhook.drv'}
141 \Msg{* through LaTeX.}
142 \Msg{*}
143 \Msg{* Happy TeXing!}
144 \Msg{*}
145 \Msg{************************************************************************}
146
147 \endbatchfile
148 %</install>
149 %<*ignore>
150 \fi
151 %</ignore>
152 %<*driver>
153 \NeedsTeXFormat{LaTeX2e}
154 \ProvidesFile{auxhook.drv}%
155 [2019-12-17 v1.6 Hooks for auxiliary files (HO)]%
156 \documentclass{ltxdoc}
157 \usepackage{holtxdoc}[2011/11/22]
158 \begin{document}
159 \DocInput{auxhook.dtx}%
160 \end{document}
161 %</driver>
162 % \fi
163 %
164 %
165 %
166 % \GetFileInfo{auxhook.drv}
167 %
168 % \title{The \xpackage{auxhook} package}
169 % \date{2019-12-17 v1.6}
170 % \author{Heiko Oberdiek\thanks
171 % {Please report any issues at \url{https://github.com/ho-tex/auxhook/issues}}}
172 %
173 % \maketitle
174 %
175 % \begin{abstract}
176 % Package \xpackage{auxhook} provides hooks for adding stuff at
177 % the begin of \xfile{.aux} files.
178 % \end{abstract}
179 %
180 % \tableofcontents
181 %
182 % \section{User interface}
183 %
184 % There are two kinds of \xfile{.aux} files, the main \xfile{.aux} file
185 % and the \xfile{.aux} file that belongs to an included file, specified
186 % by \cs{include}.
187 %
188 % Some packages write macros in the auxiliary files.
189 % If the user stops using the package, these macros will usually
190 % cause error messages because of unknown commands. Prominent example
191 % is package \xpackage{babel}'s \cs{select@language}.
192 %
193 % But such a package could be written more cooperative. It can
194 % also provide a definition in the auxiliary file (\cs{providecommand})
195 % that silently disables the macros of the package
196 % if the package is no longer in use.
197 %
198 % In case of the main auxiliary file, \cs{AtBeginDocument} can be used
199 % for this purpose. Especially if several packages are involved, the
200 % order cannot be controlled always (e.g., see package
201 % \xpackage{hypdestopt} that hooks into \xpackage{hyperref}'s macros).
202 % And there isn't any hook for the auxiliary files of the \cs{include}
203 % feature.
204 %
205 % Thus this package patches \LaTeX's macros \cs{document} and
206 % \cs{@include} to add the hooks where the auxiliary files
207 % are opend and the first line with \cs{relax} is written.
208 %
209 % The patching can fail, if these macros are redefined by some
210 % other package. If the other package still uses the original
211 % definition, then load package \xpackage{auxhook} earlier.
212 % (With \cs{RequirePackage} the package also can be loaded before
213 % the class). If the redefinition doesn't use the original meaning,
214 % then you can try to load package \xpackage{auxhook} afterwards,
215 % but you need luck that the patch succeeds.
216 %
217 % The hooks are macros:
218 % \begin{description}
219 % \item[\cs{@beginmainauxhook}:] Start of the main auxiliary file.
220 % The hook is called after the first line with \cs{relax} is written.
221 % \item[\cs{@beginpartauxhook}:] The same for the auxiliary files
222 % that belongs to the files that are included by \cs{include}.
223 % \end{description}
224 % If you want to add something to these hooks, you can use
225 % \cs{g@addto@macro} from \LaTeX's kernel. But the package provides
226 % macros to add code that adds a line to the auxiliary file:
227 %
228 % \begin{declcs}{AddLineBeginMainAux}\,\M{line}\\
229 % \cs{AddLineBeginPartAux}\,\M{line}\\
230 % \cs{AddLineBeginAux}\,\M{line}
231 % \end{declcs}
232 % The \meta{line} is added at the begin of the main auxiliary file
233 % by \cs{AddLineBeginMainAux} and at the begin of the auxiliary files
234 % of included files by \cs{AddLineBeginPartAux}. \cs{AddLineBeginAux} writes
235 % in both kinds of auxiliary files.
236 %
237 % Examples, see packages \xpackage{hypdestopt} (\cite{hypdestopt}) and
238 % \xpackage{zref} (\cite{zref}).
239 %
240 % \StopEventually{
241 % }
242 %
243 % \section{Implementation}
244 %
245 % \subsection{Identification}
246 %
247 % \begin{macrocode}
248 %<*package>
249 \NeedsTeXFormat{LaTeX2e}
250 \ProvidesPackage{auxhook}%
251 [2019-12-17 v1.6 Hooks for auxiliary files (HO)]%
252 % \end{macrocode}
253 %
254 % \subsection{Hook setup}
255 %
256 % \begin{macro}{\@beginmainauxhook}
257 % The hook for the main auxiliary file, initially empty.
258 % \begin{macrocode}
259 \providecommand*{\@beginmainauxhook}{}
260 % \end{macrocode}
261 % \end{macro}
262 % \begin{macro}{\@beginpartauxhook}
263 % The hook for auxiliary files of included files, initially empty.
264 % \begin{macrocode}
265 \providecommand*{\@beginpartauxhook}{}
266 % \end{macrocode}
267 % \end{macro}
268 %
269 % \begin{macrocode}
270 \ifx\AtBeginDocument\@firstofone
271 \global\let\@beginmainauxhook\relax
272 \else
273 \g@addto@macro{\@beginmainauxhook}{%
274 \global\let\@beginmainauxhook\relax
275 }%
276 \fi
277 % \end{macrocode}
278 %
279 % \subsection{User macros}
280 %
281 % \begin{macro}{\AddLineBeginMainAux}
282 % \begin{macrocode}
283 \newcommand{\AddLineBeginMainAux}[1]{%
284 \ifx\@beginmainauxhook\relax
285 \if@filesw
286 \PackageInfo{auxhook}{%
287 \@backslashchar AddLineBeginMainAux comes a little late,%
288 \MessageBreak
289 because the main .aux file is already opened%
290 }%
291 \immediate\write\@mainaux{#1}%
292 \fi
293 \else
294 \g@addto@macro\@beginmainauxhook{%
295 \immediate\write\@mainaux{#1}%
296 }%
297 \fi
298 }
299 % \end{macrocode}
300 % \end{macro}
301 % \begin{macro}{\AtBeginPartAuxLine}
302 % \begin{macrocode}
303 \newcommand{\AddLineBeginPartAux}[1]{%
304 \g@addto@macro\@beginpartauxhook{%
305 \immediate\write\@partaux{#1}%
306 }%
307 }
308 % \end{macrocode}
309 % \end{macro}
310 % \begin{macro}{\AddLineBeginAux}
311 % \begin{macrocode}
312 \newcommand{\AddLineBeginAux}[1]{%
313 \AddLineBeginMainAux{#1}%
314 \AddLineBeginPartAux{#1}%
315 }
316 % \end{macrocode}
317 % \end{macro}
318 %
319 % \subsection{Patches}
320 %
321 % \subsubsection{\cs{document}}
322 %
323 % \begin{macrocode}
324 \begingroup
325 \@ifundefined{beamer@origdocument}{%
326 \def\auxhook@document{\document}%
327 }{%
328 \def\auxhook@document{\beamer@origdocument}%
329 }%
330 \long\def\y#1\immediate\write\@mainaux#2#3\auxhook@nil{%
331 \toks@{%
332 #1\immediate\write\@mainaux{#2}%
333 \@beginmainauxhook
334 #3%
335 }%
336 \expandafter\xdef\auxhook@document{\the\toks@}%
337 \endgroup
338 }%
339 \long\def\x#1\immediate\write\@mainaux#2#3\auxhook@nil{%
340 \toks@{#3}%
341 \edef\x{\the\toks@}%
342 \ifx\x\@empty
343 \PackageWarningNoLine{auxhook}{%
344 Cannot patch \expandafter\string\auxhook@document,%
345 \MessageBreak
346 using \string\AtBeginDocument\space instead%
347 }%
348 \endgroup
349 \AtBeginDocument{%
350 \if@filesw
351 \@beginmainauxhook
352 \fi
353 }%
354 \else
355 \expandafter\expandafter\expandafter\y\auxhook@document
356 \auxhook@nil
357 \fi
358 }%
359 \expandafter\expandafter\expandafter\x\auxhook@document
360 \immediate\write\@mainaux{}\auxhook@nil
361 % \end{macrocode}
362 %
363 % \subsubsection{\cs{@include}}
364 %
365 % \begin{macrocode}
366 \begingroup
367 \long\def\y#1\immediate\write\@partaux#2#3\auxhook@nil#4{%
368 \endgroup
369 \def#4##1 {%
370 #1\immediate\write\@partaux{#2}%
371 \@beginpartauxhook
372 #3%
373 }%
374 }%
375 \long\def\x#1\immediate\write\@partaux#2#3\auxhook@nil#4{%
376 \toks@{#3}%
377 \edef\x{\the\toks@}%
378 \ifx\x\@empty
379 \PackageWarningNoLine{auxhook}{%
380 Cannot patch \string#4,\MessageBreak
381 patch dropped%
382 }%
383 \endgroup
384 \else
385 \expandafter\y#4{##1} \auxhook@nil#4%
386 \fi
387 }%
388 \@ifundefined{ReFiCh@org@include}{%
389 \expandafter\x\@include{#1} %
390 \immediate\write\@partaux{}\auxhook@nil\@include
391 }{%
392 \expandafter\x\ReFiCh@org@include{#1} %
393 \immediate\write\@partaux{}\auxhook@nil\ReFiCh@org@include
394 }%
395 % \end{macrocode}
396 %
397 % \begin{macrocode}
398 %</package>
399 % \end{macrocode}
400 %
401 % \section{Installation}
402 %
403 % \subsection{Download}
404 %
405 % \paragraph{Package.} This package is available on
406 % CTAN\footnote{\CTANpkg{auxhook}}:
407 % \begin{description}
408 % \item[\CTAN{macros/latex/contrib/auxhook/auxhook.dtx}] The source file.
409 % \item[\CTAN{macros/latex/contrib/auxhook/auxhook.pdf}] Documentation.
410 % \end{description}
411 %
412 %
413 % \paragraph{Bundle.} All the packages of the bundle `auxhook'
414 % are also available in a TDS compliant ZIP archive. There
415 % the packages are already unpacked and the documentation files
416 % are generated. The files and directories obey the TDS standard.
417 % \begin{description}
418 % \item[\CTANinstall{install/macros/latex/contrib/auxhook.tds.zip}]
419 % \end{description}
420 % \emph{TDS} refers to the standard ``A Directory Structure
421 % for \TeX\ Files'' (\CTANpkg{tds}). Directories
422 % with \xfile{texmf} in their name are usually organized this way.
423 %
424 % \subsection{Bundle installation}
425 %
426 % \paragraph{Unpacking.} Unpack the \xfile{auxhook.tds.zip} in the
427 % TDS tree (also known as \xfile{texmf} tree) of your choice.
428 % Example (linux):
429 % \begin{quote}
430 % |unzip auxhook.tds.zip -d ~/texmf|
431 % \end{quote}
432 %
433 % \subsection{Package installation}
434 %
435 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
436 % \docstrip\ archive. The files are extracted by running the
437 % \xfile{.dtx} through \plainTeX:
438 % \begin{quote}
439 % \verb|tex auxhook.dtx|
440 % \end{quote}
441 %
442 % \paragraph{TDS.} Now the different files must be moved into
443 % the different directories in your installation TDS tree
444 % (also known as \xfile{texmf} tree):
445 % \begin{quote}
446 % \def\t{^^A
447 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
448 % auxhook.sty & tex/latex/auxhook/auxhook.sty\\
449 % auxhook.pdf & doc/latex/auxhook/auxhook.pdf\\
450 % auxhook.dtx & source/latex/auxhook/auxhook.dtx\\
451 % \end{tabular}^^A
452 % }^^A
453 % \sbox0{\t}^^A
454 % \ifdim\wd0>\linewidth
455 % \begingroup
456 % \advance\linewidth by\leftmargin
457 % \advance\linewidth by\rightmargin
458 % \edef\x{\endgroup
459 % \def\noexpand\lw{\the\linewidth}^^A
460 % }\x
461 % \def\lwbox{^^A
462 % \leavevmode
463 % \hbox to \linewidth{^^A
464 % \kern-\leftmargin\relax
465 % \hss
466 % \usebox0
467 % \hss
468 % \kern-\rightmargin\relax
469 % }^^A
470 % }^^A
471 % \ifdim\wd0>\lw
472 % \sbox0{\small\t}^^A
473 % \ifdim\wd0>\linewidth
474 % \ifdim\wd0>\lw
475 % \sbox0{\footnotesize\t}^^A
476 % \ifdim\wd0>\linewidth
477 % \ifdim\wd0>\lw
478 % \sbox0{\scriptsize\t}^^A
479 % \ifdim\wd0>\linewidth
480 % \ifdim\wd0>\lw
481 % \sbox0{\tiny\t}^^A
482 % \ifdim\wd0>\linewidth
483 % \lwbox
484 % \else
485 % \usebox0
486 % \fi
487 % \else
488 % \lwbox
489 % \fi
490 % \else
491 % \usebox0
492 % \fi
493 % \else
494 % \lwbox
495 % \fi
496 % \else
497 % \usebox0
498 % \fi
499 % \else
500 % \lwbox
501 % \fi
502 % \else
503 % \usebox0
504 % \fi
505 % \else
506 % \lwbox
507 % \fi
508 % \else
509 % \usebox0
510 % \fi
511 % \end{quote}
512 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
513 % TDS installing feature, then some files can already be in the right
514 % place, see the documentation of \docstrip.
515 %
516 % \subsection{Refresh file name databases}
517 %
518 % If your \TeX~distribution
519 % (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
520 % these. For example, \TeX\,Live\ users run \verb|texhash| or
521 % \verb|mktexlsr|.
522 %
523 % \subsection{Some details for the interested}
524 %
525 % \paragraph{Unpacking with \LaTeX.}
526 % The \xfile{.dtx} chooses its action depending on the format:
527 % \begin{description}
528 % \item[\plainTeX:] Run \docstrip\ and extract the files.
529 % \item[\LaTeX:] Generate the documentation.
530 % \end{description}
531 % If you insist on using \LaTeX\ for \docstrip\ (really,
532 % \docstrip\ does not need \LaTeX), then inform the autodetect routine
533 % about your intention:
534 % \begin{quote}
535 % \verb|latex \let\install=y\input{auxhook.dtx}|
536 % \end{quote}
537 % Do not forget to quote the argument according to the demands
538 % of your shell.
539 %
540 % \paragraph{Generating the documentation.}
541 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
542 % the documentation. The process can be configured by the
543 % configuration file \xfile{ltxdoc.cfg}. For instance, put this
544 % line into this file, if you want to have A4 as paper format:
545 % \begin{quote}
546 % \verb|\PassOptionsToClass{a4paper}{article}|
547 % \end{quote}
548 % An example follows how to generate the
549 % documentation with pdf\LaTeX:
550 % \begin{quote}
551 %\begin{verbatim}
552 %pdflatex auxhook.dtx
553 %makeindex -s gind.ist auxhook.idx
554 %pdflatex auxhook.dtx
555 %makeindex -s gind.ist auxhook.idx
556 %pdflatex auxhook.dtx
557 %\end{verbatim}
558 % \end{quote}
559 %
560 % \begin{thebibliography}{9}
561 %
562 % \bibitem{hypdestopt}
563 % Heiko Oberdiek: \textit{The \xpackage{hypdestopt} package};
564 % 2006/05/30 v1.0;
565 % \CTANpkg{hypdestopt}.
566 %
567 % \bibitem{hyperref}
568 % Sebastian Rahtz, Heiko Oberdiek:
569 % \textit{The \xpackage{hyperref} package};
570 % 2006/08/16 v6.75c;
571 % \CTANpkg{hyperref}.
572 %
573 % \bibitem{zref}
574 % Heiko Oberdiek: \textit{The \xpackage{zref} package};
575 % 2006/05/25 v1.2;
576 % \CTANpkg{zref}.
577 %
578 % \end{thebibliography}
579 %
580 % \begin{History}
581 % \begin{Version}{2006/05/31 v1.0}
582 % \item
583 % First version.
584 % \end{Version}
585 % \begin{Version}{2007/04/06 v1.1}
586 % \item
587 % Fix for class \xclass{beamer}.
588 % \end{Version}
589 % \begin{Version}{2009/12/14 v1.2}
590 % \item
591 % Support for package \xpackage{rerunfilecheck} added (\cs{@include}).
592 % \end{Version}
593 % \begin{Version}{2011/03/04 v1.3}
594 % \item
595 % \cs{AddLineBeginMainAux} also supports write requests after
596 % the main \xext{aux} file is opened.
597 % \end{Version}
598 % \begin{Version}{2016/05/16 v1.4}
599 % \item
600 % Documentation updates.
601 % \end{Version}
602 % \begin{Version}{2019/12/15 v1.5}
603 % \item
604 % Documentation updates.
605 % \end{Version}
606 % \begin{Version}{2019-12-17 v1.6}
607 % \item Updated
608 % \end{Version}
609 % \end{History}
610 %
611 % \PrintIndex
612 %
613 % \Finale
614 \endinput