| 1 |
% \iffalse meta-comment |
| 2 |
%<=*COPYRIGHT> |
| 3 |
%% Copyright (c) 2011-2022 by Martin Scharrer <[email protected]> |
| 4 |
%% ---------------------------------------------------------------------- |
| 5 |
%% This work may be distributed and/or modified under the |
| 6 |
%% conditions of the LaTeX Project Public License, either version 1.3 |
| 7 |
%% of this license or (at your option) any later version. |
| 8 |
%% The latest version of this license is in |
| 9 |
%% http://www.latex-project.org/lppl.txt |
| 10 |
%% and version 1.3 or later is part of all distributions of LaTeX |
| 11 |
%% version 2005/12/01 or later. |
| 12 |
%% |
| 13 |
%% This work has the LPPL maintenance status `maintained'. |
| 14 |
%% |
| 15 |
%% The Current Maintainer of this work is Martin Scharrer. |
| 16 |
%% |
| 17 |
%% This work consists of the files filehook.dtx and filehook.ins |
| 18 |
%% and the derived files filehook.sty, filehook-fink.sty, |
| 19 |
%% filehook-listings.sty, filehook-memoir.sty, filehook-scrlfile.sty |
| 20 |
%% and pgf-filehook.sty |
| 21 |
%% |
| 22 |
%<=/COPYRIGHT> |
| 23 |
% \fi |
| 24 |
% |
| 25 |
% \iffalse |
| 26 |
%<*driver> |
| 27 |
\ProvidesFile{filehook.dtx}[% |
| 28 |
%<=*DATE> |
| 29 |
2022/10/25 |
| 30 |
%<=/DATE> |
| 31 |
%<=*VERSION> |
| 32 |
v0.8b |
| 33 |
%<=/VERSION> |
| 34 |
Hooks for input files] |
| 35 |
\documentclass{ydoc} |
| 36 |
\GetFileInfo{filehook.dtx} |
| 37 |
\usepackage{filehook}[\filedate] |
| 38 |
\usepackage[utf8]{inputenc} |
| 39 |
\usepackage[TS1,T1]{fontenc} |
| 40 |
\EnableCrossrefs |
| 41 |
\CodelineIndex |
| 42 |
\RecordChanges |
| 43 |
\makeatletter |
| 44 |
\providecommand*\tablecaption{% |
| 45 |
\@tempdima=\abovecaptionskip |
| 46 |
\abovecaptionskip=\belowcaptionskip |
| 47 |
\belowcaptionskip=\@tempdima |
| 48 |
\caption |
| 49 |
} |
| 50 |
\makeatother |
| 51 |
\listfiles |
| 52 |
\begin{document} |
| 53 |
\DocInput{filehook.dtx} |
| 54 |
\PrintChanges |
| 55 |
\PrintIndex |
| 56 |
\end{document} |
| 57 |
%</driver> |
| 58 |
% \fi |
| 59 |
% |
| 60 |
% \CheckSum{1494} |
| 61 |
% |
| 62 |
% \CharacterTable |
| 63 |
% {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 |
| 64 |
% 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 |
| 65 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 66 |
% Exclamation \! Double quote \" Hash (number) \# |
| 67 |
% Dollar \$ Percent \% Ampersand \& |
| 68 |
% Acute accent \' Left paren \( Right paren \) |
| 69 |
% Asterisk \* Plus \+ Comma \, |
| 70 |
% Minus \- Point \. Solidus \/ |
| 71 |
% Colon \: Semicolon \; Less than \< |
| 72 |
% Equals \= Greater than \> Question mark \? |
| 73 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 74 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 75 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 76 |
% Right brace \} Tilde \~} |
| 77 |
% |
| 78 |
% |
| 79 |
% \changes{v0.1}{2010/04/08}{Initial version} |
| 80 |
% \changes{v0.2}{2010/12/08}{Added support for 'memoir' class and 'scrlfile' package. Remove support for deprecated 'fink' package.} |
| 81 |
% \changes{v0.3}{2010/12/20}{Added hooks for package and class files. Changed a warning to an error and added the 'force' option to overwrite this.} |
| 82 |
% \changes{v0.4}{2011/01/03}{^^A |
| 83 |
% Improved support for 'memoir' class and 'scrlfile' package. |
| 84 |
% Added AtBeginOfEveryFile and AtEndOfEveryFile hooks. |
| 85 |
% Changed handling of macro arguments in hook code. |
| 86 |
% Added filename parsing code to support TeX files with and without extension. |
| 87 |
% Added AtBeginOfEveryFile/AtEndOfEveryFile hooks. |
| 88 |
% Fixes misspelled \string\AfterOfIncludeFile. |
| 89 |
% Added patch for listings \lstinputlistings to avoid hooks for verbatim files. |
| 90 |
% Added star argument for AtBeginOfClass and PackageFile. |
| 91 |
% Worked on scrlfile and memoir compatibility. |
| 92 |
% Readded fink compatibility code. |
| 93 |
% Updated documentation. |
| 94 |
% } |
| 95 |
% \changes{v0.5}{2011/01/09}{Added PGF key interface for hooks. Added macro to clear hooks.} |
| 96 |
% \changes{v0.5a}{2011/03/09}{Added required \string\long\space to an internal macro.} |
| 97 |
% \changes{v0.5b}{2011/07/18}{Replaced \cs{@nameuse} for use with eTeX code to avoid the definition of non-existing hooks to \cs{relax}.} |
| 98 |
% \changes{v0.5c}{2011/10/07}{Added fall-back code for non-eTeX compilers.} |
| 99 |
% \changes{v0.5d}{2011/10/12}{Fix for fall-back code.} |
| 100 |
% \changes{v0.5e}{2019/08/19}{Fix for new LaTeX format.} |
| 101 |
% \changes{v0.6}{2019/10/03}{Fix for InputIfFileExists for LaTeX format 2019/10/01.} |
| 102 |
% \changes{v0.7}{2020/02/03}{Further fixes for InputIfFileExists for LaTeX format 2019/10/01.} |
| 103 |
% \changes{v0.8}{2020/09/27}{Support for LaTeX format 2020/10/01.} |
| 104 |
% \changes{v0.8a}{2020/09/29}{Further fixes for LaTeX format 2020/10/01.} |
| 105 |
% \changes{v0.8b}{2022/10/25}{Updated package URLs. Added DEPENDS.txt file.} |
| 106 |
% |
| 107 |
% \GetFileInfo{filehook.dtx} |
| 108 |
% |
| 109 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 110 |
% |
| 111 |
% \author{Martin Scharrer} |
| 112 |
% \email{[email protected]} |
| 113 |
% \github{MartinScharrer/filehook} |
| 114 |
% \maketitle |
| 115 |
% |
| 116 |
% \begin{abstract} |
| 117 |
% This package provides hooks for input files. Document and package authors can use these hooks to |
| 118 |
% execute code at begin or the end of specific or all input files. |
| 119 |
% \end{abstract} |
| 120 |
% |
| 121 |
% \section{Changes due to new \LaTeX\ core hooks} |
| 122 |
% With the \LaTeX\ release 2020/10/01 file hooks are now provided by the \LaTeX\ core. This package has been adjusted to use these hooks |
| 123 |
% while trying to provide the same interface and behaviour than before. Simpler usages should work without any differences but advanced |
| 124 |
% usages which rely on the exact hook order and position might see some unwanted changes. |
| 125 |
% Users should try to use the \LaTeX\ hooks instead for new documents. |
| 126 |
% Please see \LaTeX\ core filehook documentation |
| 127 |
% \href{http://mirrors.ctan.org/macros/latex-dev/base/ltfilehook-doc.pdf}{\texttt{ltfilehook-doc}} for |
| 128 |
% the new hook system. |
| 129 |
% |
| 130 |
% Support of other hooking systems in other packages and classes has been dropped as this package no longer installs own hooks. |
| 131 |
% |
| 132 |
% If this package is run under a \LaTeX\ release prior to 2020/10/01 the old implementation will be loaded. |
| 133 |
% For this switch two sub-packages \pkg{filehook-2019} and \pkg{filehook-2020} are used and loaded according to the \LaTeX\ release version. |
| 134 |
% Please do not load these packages directly as they might be changes or disappear on later releases. |
| 135 |
% |
| 136 |
% |
| 137 |
% \section{Introduction} |
| 138 |
% These package (under \LaTeX\ prior 2020/10/01) changes some internal \LaTeX{} macros used to load input files so that they include `hooks'. |
| 139 |
% A hook is an (internal) macro executed at specific points. Normally it is initially empty, but can be extended using |
| 140 |
% an user level macro. The most common hook in \LaTeX{} is the `At-Begin-Document' hook. Code can be added to this hook |
| 141 |
% using \Macro\AtBeginDocument{<\TeX\ code>}. |
| 142 |
% |
| 143 |
% |
| 144 |
% This package provides hooks for files read by the \LaTeX{} macros \Macro\input, \Macro\include and |
| 145 |
% \Macro\InputIfFileExists as well as (since v0.3 from 2010/12/20) for class and package files, |
| 146 |
% i.e. macros \Macro\documentclass, \Macro\LoadClassWithOptions and \Macro\LoadClass |
| 147 |
% as well as \Macro\usepackage, \Macro\RequirePackageWithOptions and \Macro\RequirePackage. |
| 148 |
% Note that \Macro\InputIfFileExists, and therefore its hooks, is used by the aforementioned macros. |
| 149 |
% In v0.4 from 2011/03/01 special hooks where added which are executed for every read file, but will not be |
| 150 |
% executed a second time by the internal \Macro\InputIfFileExists inside \Macro\input and \Macro\include. |
| 151 |
% |
| 152 |
% For all files a `AtBegin' and a `AtEnd' hook is installed. For \Macro\include files there is also a `After' hook which |
| 153 |
% it is executed \emph{after} the page break (\Macro\clearpage) is inserted by the \Macro\include code. |
| 154 |
% In contrast, the `AtEnd' hook is executed before the trailing page break |
| 155 |
% and the `AtBegin' hook is executed after the \emph{leading} page break. |
| 156 |
% The `AtBegin' hook can be used to set macros to file specific values. |
| 157 |
% These macros can be reset in the `AtEnd' hook to the parent file values. |
| 158 |
% If these macros appear in the page header or footer they need to be reset `After' hook |
| 159 |
% to ensure that the correct values are used for the last page. |
| 160 |
% |
| 161 |
% In addition to general hooks which are executed for all files of there type, |
| 162 |
% file specific one can be defined which are only executed for the named file. |
| 163 |
% The hooks for classes and packages are always specific to one file. |
| 164 |
% |
| 165 |
% Older versions of this package provided the file name as argument |#1| for the general hooks. |
| 166 |
% This has been changed in v0.4 from 2011/01/03: the hook code is stored and executed without modifications, |
| 167 |
% i.e.\ macro argument characters (|#|) are now handled like normal and don't have to be doubled. |
| 168 |
% See section~\ref{sec:upgrade} for information how to upgrade older documents. |
| 169 |
% |
| 170 |
% \section{Usage} |
| 171 |
% The below macros can be used to add material (\TeX{} code) to the related hooks. |
| 172 |
% All `AtBegin' macros will \emph{append} the code to the hooks, but the `AtEnd' and `After' macros will \emph{prefix} the code instead. |
| 173 |
% This ensures that two different packages adding material in `AtBegin'/`AtEnd' pairs do not overlap each other. |
| 174 |
% Instead the later used package adds the code closer to the file content, `inside' the material added by the first package. |
| 175 |
% Therefore it is safely possible to surround the content of a file with multiple \LaTeX{} environments using multiple `AtBegin'/`AtEnd' macro calls. |
| 176 |
% If required inside another package a different order can be enforced by using the internal hook macros shown in the implementation section. |
| 177 |
% |
| 178 |
%^^A Some internal macros to draw the hook positions: |
| 179 |
% \def\Hook#1{\textsf{Hook: #1}\MacroArgs} |
| 180 |
% |
| 181 |
% \def\DrawInputIfB#1{% |
| 182 |
% \hbox{\vbox{% |
| 183 |
% \sffamily |
| 184 |
% \hbox{\Macro\InputIfFileExists:}% |
| 185 |
% \hbox{\fbox{\vbox{% |
| 186 |
% \hbox{\Hook{AtBeginOfFile}{<file name>}}% |
| 187 |
% #1% |
| 188 |
% \hbox{\Hook{AtBeginOfFiles}}% |
| 189 |
% \hbox{\fbox{\emph{Content}}}% |
| 190 |
% \vspace{2pt}% |
| 191 |
% \hbox{\Hook{AtEndOfFiles}}% |
| 192 |
% \hbox{\Hook{AtEndOfFile}{<file name>}}% |
| 193 |
% }}}% |
| 194 |
% }}% |
| 195 |
% }% |
| 196 |
% |
| 197 |
% \def\DrawInputIf#1{% |
| 198 |
% \hbox{\vbox{% |
| 199 |
% \sffamily |
| 200 |
% \hbox{\Macro\InputIfFileExists:}% |
| 201 |
% \hbox{\fbox{\vbox{% |
| 202 |
% \hbox{\Hook{AtBeginOfEveryFile}}% |
| 203 |
% \hbox{\Hook{AtBeginOfFile}{<file name>}}% |
| 204 |
% #1% |
| 205 |
% \hbox{\Hook{AtBeginOfFiles}}% |
| 206 |
% \hbox{\fbox{\emph{Content}}}% |
| 207 |
% \vspace{2pt}% |
| 208 |
% \hbox{\Hook{AtEndOfFiles}}% |
| 209 |
% \hbox{\Hook{AtEndOfFile}{<file name>}}% |
| 210 |
% \hbox{\Hook{AtEndOfEveryFile}}% |
| 211 |
% }}}% |
| 212 |
% }}% |
| 213 |
% }% |
| 214 |
% |
| 215 |
% |
| 216 |
% \subsection*{Every File} |
| 217 |
% |
| 218 |
% \DescribeMacro{\AtBeginOfEveryFile}{<\TeX\ code>} |
| 219 |
% \DescribeMacro{\AtEndOfEveryFile}{<\TeX\ code>} |
| 220 |
% Sometime certain code should be executed at the begin and end of every read file, e.g.\ pushing and popping a file stack. |
| 221 |
% The `At...OfFiles' hooks already do a good job here. Unfortunately there is the issue with the \Macro\clearpage in \Macro\include. |
| 222 |
% The \Macro\AtEndOfFiles is executed before it, which can cause issues with page headers and footers. |
| 223 |
% A workaround, e.g.\ done by older versions of the \pkg{currfile} package, is to execute the code twice for include files: |
| 224 |
% once in the |include| related hooks and once in the |OfFiles| hooks. |
| 225 |
% |
| 226 |
% A better solution for this problem was added in v0.4 from 2011/01/03: |
| 227 |
% the |EveryFile| hooks will be executed exactly once for every file, independent if it is |
| 228 |
% read using \Macro\input, \Macro\include or \Macro\InputIfFileExists. |
| 229 |
% Special care is taken to suppress them for the \Macro\InputIfFileExists inside \Macro\input and \Macro\include. |
| 230 |
% |
| 231 |
% These hooks are located around the more specific hooks: |
| 232 |
% For \Macro\input files the `Begin' hook is executed before the \Macro\AtBeginOfInputs hook and the `End' hook after |
| 233 |
% the \Macro\AtEndOfInputs. |
| 234 |
% Similarly, for \Macro\include files the `Begin' hook is executed before the \Macro\AtBeginOfIncludes hook and the `End' hook after |
| 235 |
% the \Macro\AfterIncludes\relax (!). |
| 236 |
% For files read by \Macro\InputIfFileExists\relax (e.g. also for \Macro\usepackage, etc.) they are executed before and after the |
| 237 |
% \Macro\AtBeginOfFiles and \Macro\AtEndOfFiles hooks, respectively. |
| 238 |
% Note that the \Macro\AtBeginOfEveryFile hook is executed before the \Macro\AtBeginOfPackageFile/\Macro\AtBeginOfClassFile hooks |
| 239 |
% and that the \Macro\AtEndOfEveryFile hook is executed also before the hooks \Macro\AtEndOfPackageFile/\Macro\AtEndOfClassFile. |
| 240 |
% Therefore the `Every' and `PackageFile'/`ClassFile' hooks do not nest correctly like all other hooks do. |
| 241 |
% |
| 242 |
% |
| 243 |
% \subsection*{All Files} |
| 244 |
% |
| 245 |
% \DescribeMacro{\AtBeginOfFiles}{<\TeX\ code>} |
| 246 |
% \DescribeMacro{\AtEndOfFiles}{<\TeX\ code>} |
| 247 |
% These macros add the given \marg{code} to two hooks executed for all files read using the \Macro\InputIfFileExists macro. This macro is used internally by the |
| 248 |
% \Macro\input, \Macro\include and \Macro\usepackage/\Macro\RequirePackage macros. Packages and classes might use it to include additional or auxiliary files. |
| 249 |
% Authors can exclude those files from the hooks by using the following code instead:\\\hspace*{\bigskipamount}\Macro\IfFileExists{<file name>}'{\@input\@filef@und}{}' |
| 250 |
% |
| 251 |
% \DescribeMacro{\AtBeginOfFile}{<file name>}{<\TeX\ code>} |
| 252 |
% \DescribeMacro{\AtEndOfFile}{<file name>}{<\TeX\ code>} |
| 253 |
% Like the {\Macro{...OfIncludeFile}{<file name>}{<\TeX\ code>}} macros above, just for `all' read files. |
| 254 |
% If the \meta{file name} does not include a file extension it will be set to `|.tex|'. |
| 255 |
% |
| 256 |
% The `all files' hooks are closer to the file content than the \Macro\input and \Macro\include hook, i.e.\ the \Macro\AtBeginOfFiles comes \emph{after} the \Macro\AtBeginOfIncludes and |
| 257 |
% the \Macro\AtEndOfFiles comes \emph{before} the \Macro\AtEndOfIncludes hook. |
| 258 |
% |
| 259 |
% The following figure shows the positions of the hooks inside the macro:\par\medskip |
| 260 |
% \centerline{\DrawInputIf{}} |
| 261 |
% |
| 262 |
% |
| 263 |
% \subsection*{Include Files} |
| 264 |
% \DescribeMacro{\AtBeginOfIncludes}{<\TeX\ code>} |
| 265 |
% \DescribeMacro{\AtEndOfIncludes}{<\TeX\ code>} |
| 266 |
% \DescribeMacro{\AfterIncludes}{<\TeX\ code>} |
| 267 |
% As described above the `AtEnd' hook is executed before and the `After' hook is executed after the trailing \Macro\clearpage. |
| 268 |
% Note that material which appears in the page header or footer should be updated in the `After' hook, not the `AtEnd' hook, to ensure |
| 269 |
% that the old values are still valid for the last page. |
| 270 |
% |
| 271 |
% \DescribeMacro{\AtBeginOfIncludeFile}{<file name>}{<\TeX\ code>} |
| 272 |
% \DescribeMacro{\AtEndOfIncludeFile}{<file name>}{<\TeX\ code>} |
| 273 |
% \DescribeMacro{\AfterIncludeFile}{<file name>}{<\TeX\ code>} |
| 274 |
% These file-specific macros take the two arguments. The \meta{code} is only executed for the file with the given \meta{file name} |
| 275 |
% and only if it is read using \Macro\include. |
| 276 |
% The \meta{file name} should be identical to the name used for \Macro\include and not include the `|.tex|' extension. |
| 277 |
% Files with a different extension are neither supported by \Macro\include nor this hooks. |
| 278 |
% |
| 279 |
% The following figure shows the positions of the hooks inside the macro:\par\medskip |
| 280 |
% \centerline{\hbox{\vbox{% |
| 281 |
% \sffamily |
| 282 |
% \hbox{\Macro\include:}% |
| 283 |
% \hbox{\fbox{\vbox{% |
| 284 |
% \hbox{\Macro\clearpage~~(implicit)}% |
| 285 |
% \hbox{\Hook{AtBeginOfEveryFile}}% |
| 286 |
% \hbox{\Hook{AtBeginOfIncludeFile}{<file name>}}% |
| 287 |
% \hbox{\Hook{AtBeginOfIncludes}}% |
| 288 |
% \hbox{\fbox{\DrawInputIfB{}}}% |
| 289 |
% \vspace{2pt}% |
| 290 |
% \hbox{\Hook{AtEndOfIncludes}}% |
| 291 |
% \hbox{\Hook{AtEndOfIncludeFile}{<file name>}}% |
| 292 |
% \hbox{\Macro\clearpage~~(implicit)}% |
| 293 |
% \hbox{\Hook{AfterIncludes}}% |
| 294 |
% \hbox{\Hook{AfterIncludeFile}{<file name>}}% |
| 295 |
% \hbox{\Hook{AtEndOfEveryFile}}% |
| 296 |
% }}}% |
| 297 |
% }}} |
| 298 |
% |
| 299 |
% |
| 300 |
% \subsection*{Input Files} |
| 301 |
% |
| 302 |
% \DescribeMacro{\AtBeginOfInputs}{<\TeX\ code>} |
| 303 |
% \DescribeMacro{\AtEndOfInputs}{<\TeX\ code>} |
| 304 |
% Like the \Macro{...OfIncludes}{code} macros above, just for file read using \Macro\input. |
| 305 |
% |
| 306 |
% \DescribeMacro{\AtBeginOfInputFile}{<file name>}{<\TeX\ code>} |
| 307 |
% \DescribeMacro{\AtEndOfInputFile}{<file name>}{<\TeX\ code>} |
| 308 |
% Like the \Macro{...OfIncludeFile}{<file name>}{code} macros above, just for file read using \Macro\input. |
| 309 |
% If the \meta{file name} does not include a file extension it will be set to `|.tex|'. |
| 310 |
% |
| 311 |
% The following figure shows the positions of the hooks inside the macro:\par\medskip |
| 312 |
% \centerline{\hbox{\vbox{% |
| 313 |
% \sffamily |
| 314 |
% \hbox{\Macro\input:}% |
| 315 |
% \hbox{\fbox{\vbox{% |
| 316 |
% \hbox{\Hook{AtBeginOfEveryFile}}% |
| 317 |
% \hbox{\Hook{AtBeginOfInputFile}{<file name>}}% |
| 318 |
% \hbox{\Hook{AtBeginOfInputs}}% |
| 319 |
% \hbox{\fbox{\DrawInputIfB{}}}% |
| 320 |
% \vspace{2pt}% |
| 321 |
% \hbox{\Hook{AtEndOfInputs}}% |
| 322 |
% \hbox{\Hook{AtEndOfInputFile}{<file name>}}% |
| 323 |
% \hbox{\Hook{AtEndOfEveryFile}}% |
| 324 |
% }}}% |
| 325 |
% }}} |
| 326 |
% |
| 327 |
% |
| 328 |
% |
| 329 |
% \subsection*{Package Files} |
| 330 |
% |
| 331 |
% \DescribeMacro{\AtBeginOfPackageFile}*{<package name>}{<\TeX\ code>} |
| 332 |
% \DescribeMacro{\AtEndOfPackageFile}*{<package name>}{<\TeX\ code>} |
| 333 |
% This macros install the given \MacroArgs<\TeX\ code> in the `AtBegin' and `AtEnd' hooks of the given package file. |
| 334 |
% The \Macro\AtBeginOfPackageFile simply executes \Macro\AtBeginOfFile{<package name>.sty}{<\TeX code>}. |
| 335 |
% Special care is taken to ensure that the `AtEnd' code is executed \emph{after} any code installed by the package itself |
| 336 |
% using the \LaTeX\ macro \Macro\AtEndOfPackage. Note that it is therefore executed after the `AtEndOfEveryFile' hook. |
| 337 |
% If the starred version is used and the package is already loaded the code |
| 338 |
% is executed right away. |
| 339 |
% |
| 340 |
% The following figure shows the positions of the hooks inside the macros:\par\medskip |
| 341 |
% \centerline{\hbox{\vbox{% |
| 342 |
% \sffamily |
| 343 |
% \hbox{\Macro\usepackage/\Macro\RequirePackage/\Macro\RequirePackageWithOptions:}% |
| 344 |
% \hbox{\fbox{\vbox{% |
| 345 |
% \hbox{\fbox{\DrawInputIf{\hbox{ (includes AtBeginOfPackageFile\MacroArgs{<file name>})}}}}% |
| 346 |
% \vspace{2pt}% |
| 347 |
% \hbox{\Hook{AtEndOfPackage}~~(\LaTeX\ hook)}% |
| 348 |
% \hbox{\Hook{AtEndOfPackageFile}{<file name>}}% |
| 349 |
% }}}% |
| 350 |
% }}} |
| 351 |
% |
| 352 |
% \subsection*{Class Files} |
| 353 |
% |
| 354 |
% \DescribeMacro{\AtBeginOfClassFile}*{<class name>}{<\TeX\ code>} |
| 355 |
% \DescribeMacro{\AtEndOfClassFile}*{<class name>}{<\TeX\ code>} |
| 356 |
% This macros install the given \MacroArgs<\TeX\ code> in the `AtBegin' and `AtEnd' hooks of the given class file. |
| 357 |
% They work with classes loaded using \Macro\LoadClass, \Macro\LoadClassWithOptions and also \Macro\documentclass. |
| 358 |
% However, in the latter case |filehook| must be loaded using \Macro\RequirePackage beforehand. |
| 359 |
% The macro \Macro\AtBeginOfClassFile simply executes \Macro\AtBeginOfFile{<class name>.cls}{\ldots}. |
| 360 |
% Special care is taken to ensure that the `AtEnd' code is executed \emph{after} any code installed by the class itself |
| 361 |
% using the \LaTeX\ macro \Macro\AtEndOfClass. |
| 362 |
% Note that it is therefore executed after the `AtEndOfEveryFile' hook. |
| 363 |
% If the starred version is used and the class is already loaded the code |
| 364 |
% is executed right away. |
| 365 |
% |
| 366 |
% The following figure shows the positions of the hooks inside the macros:\par\medskip |
| 367 |
% \centerline{\hbox{\vbox{% |
| 368 |
% \sffamily |
| 369 |
% \hbox{\Macro\documentclass/\Macro\LoadClass/\Macro\LoadClassWithOptions:}% |
| 370 |
% \hbox{\fbox{\vbox{% |
| 371 |
% \hbox{\fbox{\DrawInputIf{\hbox{ (includes AtBeginOfClassFile\MacroArgs{<file name>})}}}}% |
| 372 |
% \vspace{2pt}% |
| 373 |
% \hbox{\Hook{AtEndOfClass}~~(\LaTeX\ hook)}% |
| 374 |
% \hbox{\Hook{AtEndOfClassFile}{<file name>}}% |
| 375 |
% }}}% |
| 376 |
% }}} |
| 377 |
% |
| 378 |
% \subsection{Clearing Hooks} |
| 379 |
% \DescribeMacro\ClearHook\AlsoMacro{At...Of...}<argument(s) of hook macro> |
| 380 |
% Using\marginpar{New in v0.5 2011/01/09} this macro existing hooks can be globally cleared, i.e.\ set to empty. |
| 381 |
% This should be used with care because it will also remove all (user level) hook code set |
| 382 |
% by packages into this hook. |
| 383 |
% Note that the special hook code installed by the packages \pkg{currfile} and \pkg{svn-multi} |
| 384 |
% as well as the compatibility code described in section~\ref{sec:comp} is not affected. |
| 385 |
% The syntax for this macro is the same as for the normal hook macros only with a leading \Macro\ClearHook, |
| 386 |
% where the \meta{code} argument is mandatory but its content is ignored. |
| 387 |
% Examples:\\ |
| 388 |
% \hspace*{\bigskipamount}\Macro\ClearHook\AlsoMacro\AtBeginOfInputFile{<file name>}{<ignored>}\\ |
| 389 |
% \hspace*{\bigskipamount}\Macro\ClearHook\AlsoMacro\AtBeginOfFiles{<ignored>} |
| 390 |
% |
| 391 |
% |
| 392 |
% |
| 393 |
% \clearpage |
| 394 |
% \section{PGF Key Interface} |
| 395 |
% An auxiliary package |pgf-filehook| is provided which adds support for the versatile \pkg{pgfkeys} interface. |
| 396 |
% This interface is heavily used by \pkg{pgf} (portable graphics format) and its higher level format Ti\textit{k}Z. |
| 397 |
% It allows the definition and execution of styles and commands (macros) using a \MacroArgs<key>'='<value> format. |
| 398 |
% Main benefits over similar formats is the support for a ``directory structure'' inside the key and the ability |
| 399 |
% to call functions on the value before it gets processed by the key. The main way to define and execute keys |
| 400 |
% is the macro \Macro\pgfkeys{<key>'='<value>',...'}. Ti\textit{k}Z provides the similar macro \Macro\tikzstyle |
| 401 |
% which defaults to the main path `|/tikz|'. |
| 402 |
% More detailed information can be found in the official |pgfmanual|. |
| 403 |
% |
| 404 |
% All |filehook| macros described in the previous section (\Macro{AtXXXOfYYY}) can also be accessed using the |
| 405 |
% pgf keys directory `|/filehook|', where all hook type have an own sub-directory (|/filehook/YYY|) in which |
| 406 |
% the hooks for this type are located (|/filehook/YYY/AtXXX|). |
| 407 |
% For example {\Macro\AtBeginOfInputs{<code>}} can also be |
| 408 |
% accessed using \\\hspace*{\parindent}\Macro\pgfkeys{'/filehook/Inputs/AtBegin='{<code>}}\\ or \Macro\AfterIncludeFile{<file name>}{<code>} as |
| 409 |
% \\\hspace*{\parindent}{\Macro\pgfkeys{'/filehook/IncludeFile/After='{<file name>}{<code>}}}\\ as well as |
| 410 |
% \Macro\AtEndOfClassFile*{<file name>}{<code>} as |
| 411 |
% \\\hspace*{\parindent}{\Macro\pgfkeys{'/filehook/ClassFile/AtEnd='*{<file name>}{<code>}}.} |
| 412 |
% |
| 413 |
% \DescribeMacro\pgffilehook{<key>'='<value>',...'} |
| 414 |
% This macro is like \Macro\pgfkeys but defaults to the `|/filehook|' directory, so that it can be dropped from the |
| 415 |
% \meta{key}. Note that |pgfkeys| also supports to ``change the directory'' using \MacroArgs<directory>'/.cd', so that |
| 416 |
% it does not need to be included in further keys. All directories are defined as `\textit{is family}' so that the |/.cd| is |
| 417 |
% assumed if the directory is used on its own. |
| 418 |
% For example\\\centerline{\Macro\pgfkeys{'/filehook/Inputs/AtBegin='{<code>}',/filehook/Inputs/AtEnd='{<code>}}} |
| 419 |
% can be shorten as\\\centerline{\Macro\pgffilehook{'Inputs,AtBegin='{<code>}',AtEnd='{<code>}}.} |
| 420 |
% |
| 421 |
% \medskip |
| 422 |
% Some of the pgf key functions can become useful, e.g.\ if the hook code should be expanded before it is added to the hook:\\ |
| 423 |
% \hspace*{\parindent}\Macro\pgffilehook{'EveryFile/AtBegin/.expand once='{\AlsoMacro\headertext\space\AlsoMacro\currfilename}}\\ |
| 424 |
% will expand the first macro \Macro\headertext\relax (actually the first token) in the hook code once (using \Macro\expandafter), but |
| 425 |
% not any other tokens. In this example future changes of \Macro\headertext would not have any effect on the hook code, but |
| 426 |
% \Macro\currfilename will be expanded for every file. |
| 427 |
% Other useful functions are `|.expand twice|' (expand the first token twice) and `|.expanded|' (expand the whole hook code using \Macro\edef). |
| 428 |
% |
| 429 |
% \clearpage |
| 430 |
% \section{Compatibility Issues with Classes and other Packages}\label{sec:comp} |
| 431 |
% The |filehook| package might clash with other packages or classes which also redefine \Macro\InputIfFileExists |
| 432 |
% or internal macros used by \Macro\include and \Macro\input\relax (which are \Macro\@input@ and \Macro\@iinput). |
| 433 |
% Special compatibility code is in place for the packages listed below (in their current implementation). |
| 434 |
% If any other unknown definition of \Macro\InputIfFileExists is found an error will be raised. |
| 435 |
% The package option `|force|' can be used to prevent this and to force the redefinition of this macro. |
| 436 |
% Then any previous modifications will be lost, which will most likely break the other package. |
| 437 |
% Table~\ref{tab:incomp} lists all packages and classes which where found do be incompatible. |
| 438 |
% The packages \pkg{auxhook}, \pkg{stampinclude}, \pkg{rerunfilecheck} and \pkg{excludeonly} redefine |
| 439 |
% one or more of the above macros but have been found compatible with |filehook|. |
| 440 |
% Please do not hesitate to inform the author of |filehook| of any encountered problems with other packages. |
| 441 |
% |
| 442 |
% \subsection{Supported Classes and Packages} |
| 443 |
% The following classes and packages are actively supported and should work as normal when used together with |filehook|. |
| 444 |
% Please note that most of them are incompatible to each other, which |filehook| might not fix. |
| 445 |
% |
| 446 |
% \subsubsection*{memoir} |
| 447 |
% The |memoir| class redefines \Macro\InputIfFileExists to add own hooks identical to the `At...OfFiles' hooks (there called \Macro\AtBeginFile and \Macro\AtEndFile). |
| 448 |
% This hooks will be moved to the corresponding ones of |filehook| and will keep working as normal. |
| 449 |
% Since v0.4 from 2011/01/03 this modification will be also applied when the |filehook| package is loaded (using \Macro\RequirePackage) \emph{before} the |
| 450 |
% |memoir| class. However, the hooks from |filehook| need to be temporally disabled while reading the |memoir| class. |
| 451 |
% They will not be triggered for all files read directly by this class, like configuration and patch files. |
| 452 |
% Note that the `At...OfClassFile' hooks still work for the |memoir| class file itself. In fact they are used to restore the default definition of \Macro\InputIfFileExists |
| 453 |
% at the begin and patch it at the end of the class file. |
| 454 |
% The |filehook| package should be loaded either before the class (using \Macro\RequirePackage) or directly |
| 455 |
% after it. Because the |memoir| hook code is moved to the |filehook| hooks this class should then be |
| 456 |
% compatible with below packages if |memoir| and |filehook| are loaded before them. |
| 457 |
% |
| 458 |
% |
| 459 |
% \subsubsection*{scrlfile} |
| 460 |
% The |scrlfile| package from the \emph{koma-script} bundle redefines \Macro\InputIfFileExists to allow file name aliases and to also add hooks. |
| 461 |
% If required it should be loaded before |filehook|, which will add its hooks correctly to the modified definition. |
| 462 |
% Since v0.4 from 2011/01/03 this modification will be also applied when the |scrlfile| package is loaded after |filehook|. |
| 463 |
% |
| 464 |
% |
| 465 |
% \subsubsection*{fink} |
| 466 |
% The |filehook| and |currfile| packages where written as replacements for the |fink| package, where |filehook| provides the necessary hooks for |currfile|. |
| 467 |
% The |fink| package has now been deprecated in favour of |currfile| and should not be used anymore. The |fink| compatibility code has been removed from |filehook| |
| 468 |
% and both cannot be used successfully together as both redefine the \Macro\InputIfFileExists macro. |
| 469 |
% |
| 470 |
% |
| 471 |
% \subsubsection*{listings} |
| 472 |
% The \pkg{listings} package uses \Macro\input inside \Macro\lstinputlisting. Therefore the |InputFile|(|s|) and |File|(|s|) hooks are also triggered for these files. |
| 473 |
% Please note that this hooks are executing inside a verbatim environment. While the code in the hook is not affected (because it was added outside the verbatim |
| 474 |
% environment), any further code read using any input macro (\Macro\input, \Macro\@input, \Macro\@@input\relax (\TeX's \Macro\input), \ldots) will be processed verbatim and typeset |
| 475 |
% as part of the listing. |
| 476 |
% Since v0.4 this macro is automatically patched so \Macro\@input is used instead to avoid this issue. |
| 477 |
% |
| 478 |
% |
| 479 |
% \subsection{Other Classes and Packages} |
| 480 |
% |
| 481 |
% \subsubsection*{jmlrbook} |
| 482 |
% The |jmlrbook| class from the |jmlr| bundle temporary redefines \Macro\InputIfFileExists to import papers. |
| 483 |
% The `original' definition is saved away at load time of the package and is used internally by the new definition. |
| 484 |
% This means that the hooks will not be active for this imported files because |filehook| is loaded after the class. |
| 485 |
% This should not affect its normal usage. |
| 486 |
% Note that, in theory, the package could be loaded before \Macro\documentclass using \Macro\RequirePackage to enable the file hooks also for these files. |
| 487 |
% |
| 488 |
% \subsubsection*{\LaTeX's \textbackslash bibliography} |
| 489 |
% The standard \LaTeX\ macro \Macro\bibliography uses the same internal macro \Macro\@input@ to read a file |
| 490 |
% as \Macro\include does. |
| 491 |
% The `include' hooks will also be executed for this |.bbl| file if the macro is directly followed by \Macro\clearpage, |
| 492 |
% because the |filehook| code will assume it is executed inside \Macro\include. |
| 493 |
% This rare case can be easily avoided by placing a \Macro\relax after \Macro\bibliography{\ldots}. |
| 494 |
% |
| 495 |
% |
| 496 |
% \begin{table} |
| 497 |
% \centering |
| 498 |
% \tablecaption{Incompatible packages and classes} |
| 499 |
% \label{tab:incomp} |
| 500 |
% |
| 501 |
% \begin{tabular}{>{\ttfamily}llll} |
| 502 |
% \toprule |
| 503 |
% Name & Type & Note & Affected Hooks \\ |
| 504 |
% \midrule |
| 505 |
% paper & class & with \texttt{journal} option & All hocks for \Macro\include\unskip'd files \\ |
| 506 |
% journal & class & & All hocks for \Macro\include\unskip'd files \\ |
| 507 |
% gmparts & package & & \Macro\include hooks \\ |
| 508 |
% newclude & package & formally \texttt{includex} & All hocks for \Macro\include\unskip'd files \\ |
| 509 |
% \bottomrule |
| 510 |
% \end{tabular} |
| 511 |
% \end{table} |
| 512 |
% |
| 513 |
% \section{Upgrade Guide} |
| 514 |
% \label{sec:upgrade} |
| 515 |
% This sections gives information for users of older versions of this package which unfortunately might not be 100\% backwards compatible. |
| 516 |
% |
| 517 |
% \subsection*{Upgrade to v0.4 - 2011/01/03} |
| 518 |
% \begin{itemize} |
| 519 |
% \item The macro \Macro\AfterIncludeFile was misspelled as \Macro\AfterOfIncludeFile in the implementation of earlier versions, but not in the documentation. |
| 520 |
% This has now be corrected. Please adjust your code to use the correct name and to require the |filehook| package from 2011/01/03. |
| 521 |
% \item All general hooks (the one not taking a file argument) used to have an implicit argument |#1| which was expanded to the file name (i.e.\ the argument of \Macro\input etc.). |
| 522 |
% This has now be changed, so that macro arguments are not handled special in hook code, which e.g.\ simplifies macro definitions. |
| 523 |
% Older hook code might need to change |##| to |#| to compensate for this change. |
| 524 |
% If the file name is required the macros (e.g.\ \Macro\currfilename) of the partner package \pkg{currfile} should be used. |
| 525 |
% These macros are available everywhere including in all hocks. |
| 526 |
% \end{itemize} |
| 527 |
% |
| 528 |
% \StopEventually{} |
| 529 |
% \clearpage |
| 530 |
% \section{Implementation}\label{sec:impl} |
| 531 |
% |
| 532 |
% \iffalse |
| 533 |
%<*filehook.sty> |
| 534 |
% \fi |
| 535 |
% \begin{macrocode} |
| 536 |
%<!COPYRIGHT> |
| 537 |
\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 538 |
\ProvidesPackage{filehook}[% |
| 539 |
%<!DATE> |
| 540 |
%<!VERSION> |
| 541 |
%<*DRIVER> |
| 542 |
2099/01/01 develop |
| 543 |
%</DRIVER> |
| 544 |
Hooks for input files] |
| 545 |
% \end{macrocode} |
| 546 |
% |
| 547 |
% |
| 548 |
% \subsection{Options} |
| 549 |
% \begin{macrocode} |
| 550 |
\DeclareOption{force}{\PassOptionsToPackage{force}{filehook-2019}} |
| 551 |
\ProcessOptions\relax |
| 552 |
% \end{macrocode} |
| 553 |
% |
| 554 |
% \subsection{Load actual package} |
| 555 |
% \begin{macrocode} |
| 556 |
\@ifl@t@r\fmtversion{2020/10/01}{\RequirePackage{filehook-2020}}{\RequirePackage{filehook-2019}} |
| 557 |
% \end{macrocode} |
| 558 |
% |
| 559 |
% \iffalse |
| 560 |
%</filehook.sty> |
| 561 |
% \fi |
| 562 |
% |
| 563 |
% \iffalse |
| 564 |
%<*filehook-2019.sty> |
| 565 |
% \fi |
| 566 |
% \begin{macrocode} |
| 567 |
%<!COPYRIGHT> |
| 568 |
\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 569 |
\ProvidesPackage{filehook-2019}[% filehook subpackage, do not load directly |
| 570 |
%<!DATE> |
| 571 |
%<!VERSION> |
| 572 |
%<*DRIVER> |
| 573 |
2099/01/01 develop |
| 574 |
%</DRIVER> |
| 575 |
Hooks for input files] |
| 576 |
% \end{macrocode} |
| 577 |
% |
| 578 |
% |
| 579 |
% \subsection{Options} |
| 580 |
% \begin{macrocode} |
| 581 |
\newif\iffilehook@force |
| 582 |
\DeclareOption{force}{\filehook@forcetrue} |
| 583 |
\ProcessOptions\relax |
| 584 |
% \end{macrocode} |
| 585 |
% |
| 586 |
% \subsection{General stuff} |
| 587 |
% |
| 588 |
% \begin{macro}{\iffilehook@newfmt} |
| 589 |
% \begin{macrocode} |
| 590 |
\newif\iffilehook@newfmt |
| 591 |
\@ifl@t@r\fmtversion{2019/10/01}{\filehook@newfmttrue}{\filehook@newfmtfalse} |
| 592 |
% \end{macrocode} |
| 593 |
% \end{macro} |
| 594 |
% |
| 595 |
% \begin{macro}{\filehook@let}[2]{<macro name 1>}{<macro name 2>} |
| 596 |
% \begin{macrocode} |
| 597 |
\def\filehook@let#1#2{% |
| 598 |
\expandafter\ifx\csname #2\space\endcsname\relax |
| 599 |
\expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname |
| 600 |
\else |
| 601 |
\expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}% |
| 602 |
\expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname |
| 603 |
\fi |
| 604 |
} |
| 605 |
% \end{macrocode} |
| 606 |
% \end{macro} |
| 607 |
% |
| 608 |
% \begin{macro}{\filehook@glet}[2]{<macro name 1>}{<macro name 2>} |
| 609 |
% \begin{macrocode} |
| 610 |
\def\filehook@glet#1#2{% |
| 611 |
\expandafter\ifx\csname #2\space\endcsname\relax |
| 612 |
\expandafter\global\expandafter\let\csname #1\expandafter\endcsname\csname #2\endcsname |
| 613 |
\else |
| 614 |
\expandafter\global\expandafter\def\csname #1\expandafter\endcsname\expandafter{\expandafter\protect\csname #1\space\endcsname}% |
| 615 |
\expandafter\global\expandafter\let\csname #1\space\expandafter\endcsname\csname #2\space\endcsname |
| 616 |
\fi |
| 617 |
} |
| 618 |
% \end{macrocode} |
| 619 |
% \end{macro} |
| 620 |
% |
| 621 |
% |
| 622 |
% \begin{macro}{\filehook@cmp}[2]{<macro name 1>}{<macro name 2>} |
| 623 |
% Compare two macros definition including its space form in case of robust macros. |
| 624 |
% \begin{macrocode} |
| 625 |
\def\filehook@cmp#1#2{% |
| 626 |
\expandafter\ifx\csname #2\space\endcsname\relax |
| 627 |
\expandafter\ifx\csname #1\expandafter\endcsname\csname #2\endcsname |
| 628 |
\expandafter\expandafter\expandafter\@firstoftwo |
| 629 |
\else |
| 630 |
\expandafter\expandafter\expandafter\@secondoftwo |
| 631 |
\fi |
| 632 |
\else |
| 633 |
\expandafter\ifx\csname #1\space\expandafter\endcsname\csname #2\space\endcsname |
| 634 |
\expandafter\expandafter\expandafter\@firstoftwo |
| 635 |
\else |
| 636 |
\expandafter\expandafter\expandafter\@secondoftwo |
| 637 |
\fi |
| 638 |
\fi |
| 639 |
} |
| 640 |
% \end{macrocode} |
| 641 |
% \end{macro} |
| 642 |
% |
| 643 |
% |
| 644 |
% \subsection{Initialisation of Hooks} |
| 645 |
% The general hooks are initialised to call the file specific hooks. |
| 646 |
% |
| 647 |
% \begin{macro}{\filehook@csuse} |
| 648 |
% \begin{macrocode} |
| 649 |
\begingroup |
| 650 |
\gdef\filehook@csuse#1{\ifcsname #1\endcsname\csname #1\expandafter\endcsname\fi} |
| 651 |
\expandafter\ifx\csname csuse\endcsname\relax |
| 652 |
\expandafter\ifx\csname ifcsname\endcsname\relax |
| 653 |
\gdef\filehook@csuse#1{\expandafter\ifx\csname #1\endcsname\relax\else\csname #1\expandafter\endcsname\fi} |
| 654 |
\fi |
| 655 |
\else |
| 656 |
\global\let\filehook@csuse\csuse |
| 657 |
\fi |
| 658 |
\endgroup |
| 659 |
% \end{macrocode} |
| 660 |
% \end{macro} |
| 661 |
% |
| 662 |
% \begin{macro}{\filehook@include@atbegin} |
| 663 |
% \begin{macrocode} |
| 664 |
\def\filehook@include@atbegin#1{% |
| 665 |
\filehook@let{InputIfFileExists}{filehook@@InputIfFileExists}% |
| 666 |
\filehook@csuse{\filehook@include@atbegin@#1}% |
| 667 |
\filehook@include@@atbegin |
| 668 |
} |
| 669 |
% \end{macrocode} |
| 670 |
% \end{macro} |
| 671 |
% |
| 672 |
% \begin{macro}{\filehook@include@@atbegin} |
| 673 |
% \begin{macrocode} |
| 674 |
\def\filehook@include@@atbegin{} |
| 675 |
% \end{macrocode} |
| 676 |
% \end{macro} |
| 677 |
% |
| 678 |
% \begin{macro}{\filehook@include@atend} |
| 679 |
% \begin{macrocode} |
| 680 |
\def\filehook@include@atend#1{% |
| 681 |
\filehook@include@@atend |
| 682 |
\filehook@csuse{\filehook@include@atend@#1}% |
| 683 |
} |
| 684 |
% \end{macrocode} |
| 685 |
% \end{macro} |
| 686 |
% |
| 687 |
% \begin{macro}{\filehook@include@@atend} |
| 688 |
% \begin{macrocode} |
| 689 |
\def\filehook@include@@atend{} |
| 690 |
% \end{macrocode} |
| 691 |
% \end{macro} |
| 692 |
% |
| 693 |
% \begin{macro}{\filehook@include@after} |
| 694 |
% \begin{macrocode} |
| 695 |
\def\filehook@include@after#1{% |
| 696 |
\filehook@include@@after |
| 697 |
\filehook@csuse{\filehook@include@after@#1}% |
| 698 |
} |
| 699 |
% \end{macrocode} |
| 700 |
% \end{macro} |
| 701 |
% |
| 702 |
% \begin{macro}{\filehook@include@@after} |
| 703 |
% \begin{macrocode} |
| 704 |
\def\filehook@include@@after{} |
| 705 |
% \end{macrocode} |
| 706 |
% \end{macro} |
| 707 |
% |
| 708 |
% \begin{macro}{\filehook@input@atbegin} |
| 709 |
% \begin{macrocode} |
| 710 |
\def\filehook@input@atbegin#1{% |
| 711 |
\filehook@let{InputIfFileExists}{filehook@@InputIfFileExists}% |
| 712 |
\filehook@csuse{\filehook@input@atbegin@\filehook@ensureext{#1}}% |
| 713 |
\filehook@input@@atbegin |
| 714 |
} |
| 715 |
% \end{macrocode} |
| 716 |
% \end{macro} |
| 717 |
% |
| 718 |
% \begin{macro}{\filehook@input@@atbegin} |
| 719 |
% \begin{macrocode} |
| 720 |
\def\filehook@input@@atbegin{} |
| 721 |
% \end{macrocode} |
| 722 |
% \end{macro} |
| 723 |
% |
| 724 |
% \begin{macro}{\filehook@input@atend} |
| 725 |
% \begin{macrocode} |
| 726 |
\def\filehook@input@atend#1{% |
| 727 |
\filehook@input@@atend |
| 728 |
\filehook@csuse{\filehook@input@atend@\filehook@ensureext{#1}}% |
| 729 |
} |
| 730 |
% \end{macrocode} |
| 731 |
% \end{macro} |
| 732 |
% |
| 733 |
% \begin{macro}{\filehook@input@@atend} |
| 734 |
% \begin{macrocode} |
| 735 |
\def\filehook@input@@atend{} |
| 736 |
% \end{macrocode} |
| 737 |
% \end{macro} |
| 738 |
% |
| 739 |
% \begin{macro}{\filehook@atbegin} |
| 740 |
% \begin{macrocode} |
| 741 |
\def\filehook@atbegin#1{% |
| 742 |
\filehook@csuse{\filehook@atbegin@\filehook@ensureext{#1}}% |
| 743 |
\filehook@@atbegin |
| 744 |
} |
| 745 |
% \end{macrocode} |
| 746 |
% \end{macro} |
| 747 |
% |
| 748 |
% \begin{macro}{\filehook@@atbegin} |
| 749 |
% \begin{macrocode} |
| 750 |
\def\filehook@@atbegin{} |
| 751 |
% \end{macrocode} |
| 752 |
% \end{macro} |
| 753 |
% |
| 754 |
% \begin{macro}{\filehook@atend} |
| 755 |
% \begin{macrocode} |
| 756 |
\def\filehook@atend#1{% |
| 757 |
\filehook@@atend |
| 758 |
\filehook@csuse{\filehook@atend@\filehook@ensureext{#1}}% |
| 759 |
} |
| 760 |
% \end{macrocode} |
| 761 |
% \end{macro} |
| 762 |
% |
| 763 |
% \begin{macro}{\filehook@@atend} |
| 764 |
% \begin{macrocode} |
| 765 |
\def\filehook@@atend{} |
| 766 |
% \end{macrocode} |
| 767 |
% \end{macro} |
| 768 |
% |
| 769 |
% \begin{macro}{\filehook@every@atbegin} |
| 770 |
% \begin{macrocode} |
| 771 |
\def\filehook@every@atbegin#1{% |
| 772 |
\filehook@every@@atbegin |
| 773 |
} |
| 774 |
% \end{macrocode} |
| 775 |
% \end{macro} |
| 776 |
% |
| 777 |
% \begin{macro}{\filehook@every@@atbegin} |
| 778 |
% \begin{macrocode} |
| 779 |
\def\filehook@every@@atbegin{} |
| 780 |
% \end{macrocode} |
| 781 |
% \end{macro} |
| 782 |
% |
| 783 |
% \begin{macro}{\filehook@every@atend} |
| 784 |
% \begin{macrocode} |
| 785 |
\def\filehook@every@atend#1{% |
| 786 |
\filehook@every@@atend |
| 787 |
} |
| 788 |
% \end{macrocode} |
| 789 |
% \end{macro} |
| 790 |
% |
| 791 |
% \begin{macro}{\filehook@every@@atend} |
| 792 |
% \begin{macrocode} |
| 793 |
\def\filehook@every@@atend{} |
| 794 |
% \end{macrocode} |
| 795 |
% \end{macro} |
| 796 |
% |
| 797 |
% |
| 798 |
% |
| 799 |
% \subsection{Hook Modification Macros} |
| 800 |
% The following macros are used to modify the hooks, i.e.\ to prefix or append code to them. |
| 801 |
% |
| 802 |
% |
| 803 |
% \subsubsection*{Internal Macros} |
| 804 |
% |
| 805 |
% The macro prefixes for the file specific hooks are stored in macros to reduce the number of |
| 806 |
% tokens in the following macro definitions. |
| 807 |
% \begin{macrocode} |
| 808 |
\def\filehook@include@atbegin@{filehook@include@atbegin@} |
| 809 |
\def\filehook@include@atend@{filehook@include@atend@} |
| 810 |
\def\filehook@include@after@{filehook@include@after@} |
| 811 |
\def\filehook@input@atbegin@{filehook@input@atbegin@} |
| 812 |
\def\filehook@input@atend@{filehook@input@atend@} |
| 813 |
\def\filehook@input@after@{filehook@input@after@} |
| 814 |
\def\filehook@atbegin@{filehook@atbegin@} |
| 815 |
\def\filehook@atend@{filehook@atend@} |
| 816 |
\def\filehook@after@{filehook@after@} |
| 817 |
% \end{macrocode} |
| 818 |
% |
| 819 |
% |
| 820 |
% \begin{macro}{\filehook@append} |
| 821 |
% Uses default \LaTeX{} macro. |
| 822 |
% \begin{macrocode} |
| 823 |
\def\filehook@append{\g@addto@macro} |
| 824 |
% \end{macrocode} |
| 825 |
% \end{macro} |
| 826 |
% |
| 827 |
% \begin{macro}{\filehook@appendwarg} |
| 828 |
% Appends code with one macro argument. The |\@tempa| intermediate step is required because of the |
| 829 |
% included |##1| which wouldn't correctly expand otherwise. |
| 830 |
% \begin{macrocode} |
| 831 |
\long\def\filehook@appendwarg#1#2{% |
| 832 |
\begingroup |
| 833 |
\toks@\expandafter{#1{##1}#2}% |
| 834 |
\edef\@tempa{\the\toks@}% |
| 835 |
\expandafter\gdef\expandafter#1\expandafter##\expandafter1\expandafter{\@tempa}% |
| 836 |
\endgroup |
| 837 |
} |
| 838 |
% \end{macrocode} |
| 839 |
% \end{macro} |
| 840 |
% |
| 841 |
% \begin{macro}{\filehook@prefix} |
| 842 |
% Prefixes code to a hook. |
| 843 |
% \begin{macrocode} |
| 844 |
\long\def\filehook@prefix#1#2{% |
| 845 |
\begingroup |
| 846 |
\@temptokena{#2}% |
| 847 |
\toks@\expandafter{#1}% |
| 848 |
\xdef#1{\the\@temptokena\the\toks@}% |
| 849 |
\endgroup |
| 850 |
} |
| 851 |
% \end{macrocode} |
| 852 |
% \end{macro} |
| 853 |
% |
| 854 |
% \begin{macro}{\filehook@prefixwarg} |
| 855 |
% Prefixes code with an argument to a hook. |
| 856 |
% \begin{macrocode} |
| 857 |
\long\def\filehook@prefixwarg#1#2{% |
| 858 |
\begingroup |
| 859 |
\@temptokena{#2}% |
| 860 |
\toks@\expandafter{#1{##1}}% |
| 861 |
\edef\@tempa{\the\@temptokena\the\toks@}% |
| 862 |
\expandafter\gdef\expandafter#1\expandafter##\expandafter1\expandafter{\@tempa}% |
| 863 |
\endgroup |
| 864 |
} |
| 865 |
% \end{macrocode} |
| 866 |
% \end{macro} |
| 867 |
% |
| 868 |
% \begin{macro}{\filehook@addtohook}[3]{Macro which should be used to add the material to the hook}{Macro name prefix}{End of macro name (file name)} |
| 869 |
% The macro first expands the file name (|#3|) to flatten all included macros. An extension is added if missing, as well as the prefix. |
| 870 |
% All modifications of |\@tempa| are made inside a group to keep them local. |
| 871 |
% \begin{macrocode} |
| 872 |
\def\filehook@addtohook#1#2#3{% |
| 873 |
\begingroup |
| 874 |
\edef\@tempa{#3}% |
| 875 |
\edef\@tempa{#2\filehook@ensureext{\@tempa}}% |
| 876 |
\@ifundefined{\@tempa}{\global\@namedef{\@tempa}{}}{}% |
| 877 |
\expandafter\endgroup |
| 878 |
\expandafter#1\csname\@tempa\endcsname |
| 879 |
} |
| 880 |
% \end{macrocode} |
| 881 |
% \end{macro} |
| 882 |
% |
| 883 |
% \subsubsection*{User Level Macros} |
| 884 |
% The user level macros simple use the above defined macros on the appropriate hook. |
| 885 |
% |
| 886 |
% \begin{macro}{\AtBeginOfIncludes} |
| 887 |
% \begin{macrocode} |
| 888 |
\newcommand*\AtBeginOfIncludes{% |
| 889 |
\filehook@append\filehook@include@@atbegin |
| 890 |
} |
| 891 |
% \end{macrocode} |
| 892 |
% \end{macro} |
| 893 |
% |
| 894 |
% \begin{macro}{\AtEndOfIncludes} |
| 895 |
% \begin{macrocode} |
| 896 |
\newcommand*\AtEndOfIncludes{% |
| 897 |
\filehook@prefix\filehook@include@@atend |
| 898 |
} |
| 899 |
% \end{macrocode} |
| 900 |
% \end{macro} |
| 901 |
% |
| 902 |
% \begin{macro}{\AfterIncludes} |
| 903 |
% \begin{macrocode} |
| 904 |
\newcommand*\AfterIncludes{% |
| 905 |
\filehook@prefix\filehook@include@@after |
| 906 |
} |
| 907 |
% \end{macrocode} |
| 908 |
% \end{macro} |
| 909 |
% |
| 910 |
% \begin{macro}{\AtBeginOfIncludeFile} |
| 911 |
% \begin{macrocode} |
| 912 |
\newcommand*\AtBeginOfIncludeFile[1]{% |
| 913 |
\filehook@addtohook\filehook@append\filehook@include@atbegin@{\filehook@ensuretex{#1}}% |
| 914 |
} |
| 915 |
% \end{macrocode} |
| 916 |
% \end{macro} |
| 917 |
% |
| 918 |
% \begin{macro}{\AtEndOfIncludeFile} |
| 919 |
% \begin{macrocode} |
| 920 |
\newcommand*\AtEndOfIncludeFile[1]{% |
| 921 |
\filehook@addtohook\filehook@prefix\filehook@include@atend@{\filehook@ensuretex{#1}}% |
| 922 |
} |
| 923 |
% \end{macrocode} |
| 924 |
% \end{macro} |
| 925 |
% |
| 926 |
% \begin{macro}{\AfterIncludeFile} |
| 927 |
% \begin{macrocode} |
| 928 |
\newcommand*\AfterIncludeFile[1]{% |
| 929 |
\filehook@addtohook\filehook@prefix\filehook@include@after@{\filehook@ensuretex{#1}}% |
| 930 |
} |
| 931 |
% \end{macrocode} |
| 932 |
% \end{macro} |
| 933 |
% |
| 934 |
% \begin{macro}{\AtBeginOfInputs} |
| 935 |
% \begin{macrocode} |
| 936 |
\newcommand*\AtBeginOfInputs{% |
| 937 |
\filehook@append\filehook@input@@atbegin |
| 938 |
} |
| 939 |
% \end{macrocode} |
| 940 |
% \end{macro} |
| 941 |
% |
| 942 |
% \begin{macro}{\AtEndOfInputs} |
| 943 |
% \begin{macrocode} |
| 944 |
\newcommand*\AtEndOfInputs{% |
| 945 |
\filehook@prefix\filehook@input@@atend |
| 946 |
} |
| 947 |
% \end{macrocode} |
| 948 |
% \end{macro} |
| 949 |
% |
| 950 |
% \begin{macro}{\AtBeginOfInputFile} |
| 951 |
% \begin{macrocode} |
| 952 |
\newcommand*\AtBeginOfInputFile{% |
| 953 |
\filehook@addtohook\filehook@append\filehook@input@atbegin@ |
| 954 |
} |
| 955 |
% \end{macrocode} |
| 956 |
% \end{macro} |
| 957 |
% |
| 958 |
% \begin{macro}{\AtEndOfInputFile} |
| 959 |
% \begin{macrocode} |
| 960 |
\newcommand*\AtEndOfInputFile{% |
| 961 |
\filehook@addtohook\filehook@prefix\filehook@input@atend@ |
| 962 |
} |
| 963 |
% \end{macrocode} |
| 964 |
% \end{macro} |
| 965 |
% |
| 966 |
% \begin{macro}{\AtBeginOfFiles} |
| 967 |
% \begin{macrocode} |
| 968 |
\newcommand*\AtBeginOfFiles{% |
| 969 |
\filehook@append\filehook@@atbegin |
| 970 |
} |
| 971 |
% \end{macrocode} |
| 972 |
% \end{macro} |
| 973 |
% |
| 974 |
% \begin{macro}{\AtEndOfFiles} |
| 975 |
% \begin{macrocode} |
| 976 |
\newcommand*\AtEndOfFiles{% |
| 977 |
\filehook@prefix\filehook@@atend |
| 978 |
} |
| 979 |
% \end{macrocode} |
| 980 |
% \end{macro} |
| 981 |
% |
| 982 |
% \begin{macro}{\AtBeginOfEveryFile} |
| 983 |
% \begin{macrocode} |
| 984 |
\newcommand*\AtBeginOfEveryFile{% |
| 985 |
\filehook@append\filehook@every@@atbegin |
| 986 |
} |
| 987 |
% \end{macrocode} |
| 988 |
% \end{macro} |
| 989 |
% |
| 990 |
% \begin{macro}{\AtEndOfEveryFile} |
| 991 |
% \begin{macrocode} |
| 992 |
\newcommand*\AtEndOfEveryFile{% |
| 993 |
\filehook@prefix\filehook@every@@atend |
| 994 |
} |
| 995 |
% \end{macrocode} |
| 996 |
% \end{macro} |
| 997 |
% |
| 998 |
% \begin{macro}{\AtBeginOfFile} |
| 999 |
% \begin{macrocode} |
| 1000 |
\newcommand*\AtBeginOfFile{% |
| 1001 |
\filehook@addtohook\filehook@append\filehook@atbegin@ |
| 1002 |
} |
| 1003 |
% \end{macrocode} |
| 1004 |
% \end{macro} |
| 1005 |
% |
| 1006 |
% \begin{macro}{\AtEndOfFile} |
| 1007 |
% \begin{macrocode} |
| 1008 |
\newcommand*\AtEndOfFile{% |
| 1009 |
\filehook@addtohook\filehook@prefix\filehook@atend@ |
| 1010 |
} |
| 1011 |
% \end{macrocode} |
| 1012 |
% \end{macro} |
| 1013 |
% |
| 1014 |
% |
| 1015 |
% |
| 1016 |
% \begin{macro}{\AtBeginOfClassFile} |
| 1017 |
% \begin{macrocode} |
| 1018 |
\newcommand*\AtBeginOfClassFile{% |
| 1019 |
\@ifnextchar* |
| 1020 |
{\AtBeginOfXFile@star\@clsextension}% |
| 1021 |
{\AtBeginOfXFile@normal\@clsextension}% |
| 1022 |
} |
| 1023 |
% \end{macrocode} |
| 1024 |
% \end{macro} |
| 1025 |
% |
| 1026 |
% \begin{macro}{\AtBeginOfPackageFile} |
| 1027 |
% \begin{macrocode} |
| 1028 |
\newcommand*\AtBeginOfPackageFile{% |
| 1029 |
\@ifnextchar* |
| 1030 |
{\AtBeginOfXFile@star\@pkgextension}% |
| 1031 |
{\AtBeginOfXFile@normal\@pkgextension}% |
| 1032 |
} |
| 1033 |
% \end{macrocode} |
| 1034 |
% \end{macro} |
| 1035 |
% |
| 1036 |
% \begin{macro}{\AtBeginOfXFile@star}[2]{extension}{name} |
| 1037 |
% If the class or package is already loaded the code is executed right away. |
| 1038 |
% Otherwise it is installed normally. |
| 1039 |
% \begin{macrocode} |
| 1040 |
\def\AtBeginOfXFile@star#1*#2{% |
| 1041 |
\@ifl@aded{#1}{#2}% |
| 1042 |
{\@firstofone}% |
| 1043 |
{\AtBeginOfXFile@normal{#1}{#2}}% |
| 1044 |
} |
| 1045 |
% \end{macrocode} |
| 1046 |
% \end{macro} |
| 1047 |
% |
| 1048 |
% \begin{macro}{\AtBeginOfXFile@normal}[2]{extension}{name} |
| 1049 |
% \begin{macrocode} |
| 1050 |
\def\AtBeginOfXFile@normal#1#2{% |
| 1051 |
\AtBeginOfFile{#2.#1}% |
| 1052 |
} |
| 1053 |
% \end{macrocode} |
| 1054 |
% \end{macro} |
| 1055 |
% |
| 1056 |
% |
| 1057 |
% \begin{macro}{\AtEndOfClassFile} |
| 1058 |
% \begin{macrocode} |
| 1059 |
\newcommand*\AtEndOfClassFile{% |
| 1060 |
\@ifnextchar* |
| 1061 |
{\AtEndOfXFile@star\@clsextension}% |
| 1062 |
{\AtEndOfXFile@normal\@clsextension}% |
| 1063 |
} |
| 1064 |
% \end{macrocode} |
| 1065 |
% \end{macro} |
| 1066 |
% |
| 1067 |
% \begin{macro}{\AtEndOfPackageFile} |
| 1068 |
% \begin{macrocode} |
| 1069 |
\newcommand*\AtEndOfPackageFile{% |
| 1070 |
\@ifnextchar* |
| 1071 |
{\AtEndOfXFile@star\@pkgextension}% |
| 1072 |
{\AtEndOfXFile@normal\@pkgextension}% |
| 1073 |
} |
| 1074 |
% \end{macrocode} |
| 1075 |
% \end{macro} |
| 1076 |
% |
| 1077 |
% |
| 1078 |
% \begin{macro}{\AtEndOfXFile@star}[2]{extension}{name} |
| 1079 |
% If the class or package is already loaded the code is executed right away. |
| 1080 |
% Otherwise it is installed normally. |
| 1081 |
% \begin{macrocode} |
| 1082 |
\def\AtEndOfXFile@star#1*#2{% |
| 1083 |
\@ifl@aded{#1}{#2}% |
| 1084 |
{\@firstofone}% |
| 1085 |
{\AtEndOfXFile@normal{#1}{#2}}% |
| 1086 |
} |
| 1087 |
% \end{macrocode} |
| 1088 |
% \end{macro} |
| 1089 |
% |
| 1090 |
% \begin{macro}{\AtEndOfXFile@normal}[2]{extension}{name} |
| 1091 |
% Note that \Macro\AtEndOfClass is identical to \Macro\AtEndOfPackage, so no |
| 1092 |
% differentiation between classes and packages is needed here. |
| 1093 |
% \begin{macrocode} |
| 1094 |
\long\def\AtEndOfXFile@normal#1#2#3{% |
| 1095 |
\AtEndOfFile{#2.#1}{\AtEndOfPackage{#3}}% |
| 1096 |
} |
| 1097 |
% \end{macrocode} |
| 1098 |
% \end{macro} |
| 1099 |
% |
| 1100 |
% \begin{macro}{\ClearHook} |
| 1101 |
% Clears the hook by temporary redefining the prefix and append macros |
| 1102 |
% to do a simple definition to empty. |
| 1103 |
% \begin{macrocode} |
| 1104 |
\newcommand*\ClearHook{% |
| 1105 |
\begingroup |
| 1106 |
\def\filehook@prefix##1##2{% |
| 1107 |
\gdef##1{}% |
| 1108 |
\endgroup |
| 1109 |
}% |
| 1110 |
\let\filehook@append\filehook@prefix |
| 1111 |
} |
| 1112 |
% \end{macrocode} |
| 1113 |
% \end{macro} |
| 1114 |
% |
| 1115 |
% |
| 1116 |
% |
| 1117 |
% |
| 1118 |
% \subsection{Installation of Hooks} |
| 1119 |
% The \Macro\@input@ and \Macro\@iinput macros from |latex.ltx| are redefined to install the hooks. |
| 1120 |
% |
| 1121 |
% First the original definitions are saved away. |
| 1122 |
% \begin{macro}{\filehook@orig@@input@} |
| 1123 |
% \begin{macrocode} |
| 1124 |
\let\filehook@orig@@input@\@input@ |
| 1125 |
% \end{macrocode} |
| 1126 |
% \end{macro} |
| 1127 |
% |
| 1128 |
% \begin{macro}{\filehook@orig@@iinput} |
| 1129 |
% \begin{macrocode} |
| 1130 |
\let\filehook@orig@@iinput\@iinput |
| 1131 |
% \end{macrocode} |
| 1132 |
% \end{macro} |
| 1133 |
% |
| 1134 |
% \begin{macro}{\@input@} |
| 1135 |
% This macro is redefined for the \Macro\include file hooks. |
| 1136 |
% Checks if the next command is \Macro\clearpage which indicates that we are inside \Macro\@include. |
| 1137 |
% If so the hooks are installed, otherwise the original macro is used unchanged. |
| 1138 |
% For the `after' hook an own \Macro\clearpage is inserted and the original one is gobbled. |
| 1139 |
% |
| 1140 |
% \begin{macrocode} |
| 1141 |
\def\@input@#1{% |
| 1142 |
\@ifnextchar\clearpage |
| 1143 |
{% |
| 1144 |
\filehook@every@atbegin{#1}% |
| 1145 |
\filehook@include@atbegin{#1}% |
| 1146 |
\filehook@orig@@input@{#1}% |
| 1147 |
\filehook@include@atend{#1}% |
| 1148 |
\clearpage |
| 1149 |
\filehook@include@after{#1}% |
| 1150 |
\filehook@every@atend{#1}% |
| 1151 |
\@gobble |
| 1152 |
}% |
| 1153 |
{\filehook@orig@@input@{#1}}% |
| 1154 |
} |
| 1155 |
% \end{macrocode} |
| 1156 |
% \end{macro} |
| 1157 |
% |
| 1158 |
% \begin{macro}{\@iinput} |
| 1159 |
% This macro is redefined for the \Macro\input file hooks. |
| 1160 |
% it simply surrounds the original macro with the hooks. |
| 1161 |
% \begin{macrocode} |
| 1162 |
\def\filehook@@iinput#1{% |
| 1163 |
\filehook@every@atbegin{#1}% |
| 1164 |
\filehook@input@atbegin{#1}% |
| 1165 |
\filehook@orig@@iinput{#1}% |
| 1166 |
\filehook@input@atend{#1}% |
| 1167 |
\filehook@every@atend{#1}% |
| 1168 |
} |
| 1169 |
\let\@iinput\filehook@@iinput |
| 1170 |
% \end{macrocode} |
| 1171 |
% \end{macro} |
| 1172 |
% |
| 1173 |
% \begin{macro}{\filehook@swap} |
| 1174 |
% Auxiliary macro which swaps the two arguments. This is needed to expand |
| 1175 |
% \Macro\@filef@und, which is given as first argument but needed then as the second one. |
| 1176 |
% \begin{macrocode} |
| 1177 |
\def\filehook@swap#1#2{#2#1} |
| 1178 |
% \end{macrocode} |
| 1179 |
% \end{macro} |
| 1180 |
% |
| 1181 |
% \begin{macro}{\filehook@ensureext} |
| 1182 |
% This macro ensures the existence of a file name extension. If non is given `|.tex|' is |
| 1183 |
% added. |
| 1184 |
% \begin{macrocode} |
| 1185 |
\def\filehook@ensureext#1{% |
| 1186 |
\expandafter\filehook@@ensureext#1\empty.tex\empty\empty |
| 1187 |
} |
| 1188 |
% \end{macrocode} |
| 1189 |
% \end{macro} |
| 1190 |
% |
| 1191 |
% \begin{macro}{\filehook@@ensureext} |
| 1192 |
% \begin{macrocode} |
| 1193 |
\def\filehook@@ensureext#1.#2\empty#3\empty{#1.#2} |
| 1194 |
% \end{macrocode} |
| 1195 |
% \end{macro} |
| 1196 |
% |
| 1197 |
% |
| 1198 |
% \begin{macro}{\filehook@ensuretex} |
| 1199 |
% Ensures a `|.tex|' extension, i.e. adds it if missing, even if there is a different one. |
| 1200 |
% \begin{macrocode} |
| 1201 |
\def\filehook@ensuretex#1{% |
| 1202 |
\expandafter\filehook@@ensuretex#1\empty.tex\empty\empty |
| 1203 |
} |
| 1204 |
% \end{macrocode} |
| 1205 |
% \end{macro} |
| 1206 |
% |
| 1207 |
% \begin{macro}{\filehook@@ensuretex} |
| 1208 |
% \begin{macrocode} |
| 1209 |
\def\filehook@@ensuretex#1.tex\empty#2\empty{#1.tex} |
| 1210 |
% \end{macrocode} |
| 1211 |
% \end{macro} |
| 1212 |
% |
| 1213 |
% |
| 1214 |
% The |filehook| default definition of \Macro\InputIfFileExists is defined here |
| 1215 |
% together with alternatives definitions for comparison. |
| 1216 |
% There are stored first in a token register and later stored in a macro which is expanded if required. |
| 1217 |
% This is always done inside a group to keep them temporary only. |
| 1218 |
% The token register is used to avoid doubling of macro argument characters. |
| 1219 |
% |
| 1220 |
% \begin{macro}{\latex@InputIfFileExists} |
| 1221 |
% Standard \LaTeX\ definition of \Macro\InputIfFileExists. |
| 1222 |
% \begin{macrocode} |
| 1223 |
\iffilehook@newfmt |
| 1224 |
\expandafter\def\expandafter\latex@InputIfFileExists\expandafter{% |
| 1225 |
\expandafter\protect\csname InputIfFileExists\space\endcsname |
| 1226 |
} |
| 1227 |
\expandafter\long\expandafter\def\csname latex@InputIfFileExists\space\endcsname#1#2{% |
| 1228 |
\IfFileExists{#1}% |
| 1229 |
{% |
| 1230 |
\expandafter\@swaptwoargs\expandafter |
| 1231 |
{\@filef@und}{#2\@addtofilelist{#1}\@@input}}} |
| 1232 |
\else |
| 1233 |
\long\def\latex@InputIfFileExists#1#2{% |
| 1234 |
\IfFileExists{#1}% |
| 1235 |
{#2\@addtofilelist{#1}% |
| 1236 |
\@@input\@filef@und |
| 1237 |
}% |
| 1238 |
} |
| 1239 |
\fi |
| 1240 |
% \end{macrocode} |
| 1241 |
% \end{macro} |
| 1242 |
% |
| 1243 |
% |
| 1244 |
% \begin{macro}{\filehook@default@InputIfFileExists} |
| 1245 |
% \begin{macrocode} |
| 1246 |
\DeclareRobustCommand\filehook@default@InputIfFileExists[2]{% |
| 1247 |
\IfFileExists{#1}% |
| 1248 |
{\expandafter\filehook@swap |
| 1249 |
\expandafter{\@filef@und}% |
| 1250 |
{#2\@addtofilelist{#1}% |
| 1251 |
\filehook@every@atbegin{#1}% |
| 1252 |
\filehook@atbegin{#1}% |
| 1253 |
\@@input}% |
| 1254 |
\filehook@atend{#1}% |
| 1255 |
\filehook@every@atend{#1}% |
| 1256 |
}% |
| 1257 |
} |
| 1258 |
% \end{macrocode} |
| 1259 |
% Make sure definition is global: |
| 1260 |
% \begin{macrocode} |
| 1261 |
\filehook@glet{filehook@default@InputIfFileExists}{filehook@default@InputIfFileExists}% |
| 1262 |
% \end{macrocode} |
| 1263 |
% \end{macro} |
| 1264 |
% |
| 1265 |
% \begin{macro}{\filehook@@default@InputIfFileExists} |
| 1266 |
% \begin{macrocode} |
| 1267 |
\DeclareRobustCommand\filehook@@default@InputIfFileExists[2]{% |
| 1268 |
\filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% |
| 1269 |
\IfFileExists{#1}% |
| 1270 |
{\expandafter\filehook@swap |
| 1271 |
\expandafter{\@filef@und}% |
| 1272 |
{#2\@addtofilelist{#1}% |
| 1273 |
\filehook@atbegin{#1}% |
| 1274 |
\@@input}% |
| 1275 |
\filehook@atend{#1}% |
| 1276 |
}% |
| 1277 |
} |
| 1278 |
% \end{macrocode} |
| 1279 |
% Make sure definition is global: |
| 1280 |
% \begin{macrocode} |
| 1281 |
\filehook@glet{filehook@@default@InputIfFileExists}{filehook@@default@InputIfFileExists}% |
| 1282 |
% \end{macrocode} |
| 1283 |
% \end{macro} |
| 1284 |
% |
| 1285 |
% |
| 1286 |
% \begin{macro}{\InputIfFileExists} |
| 1287 |
% First we test for the |scrlfile| package. The test macro adds the necessary patches if so. |
| 1288 |
% In order to also support it when it is loaded afterwards the two hooks below are used to revert the definition |
| 1289 |
% before the package and patch it afterwards. |
| 1290 |
% \begin{macrocode} |
| 1291 |
\AtBeginOfPackageFile{scrlfile}{% |
| 1292 |
\filehook@glet{InputIfFileExists}{latex@InputIfFileExists}% |
| 1293 |
}% |
| 1294 |
\AtEndOfPackageFile*{scrlfile}{% |
| 1295 |
\RequirePackage{filehook-scrlfile}% |
| 1296 |
}% |
| 1297 |
% \end{macrocode} |
| 1298 |
% Fink: |
| 1299 |
% \begin{macrocode} |
| 1300 |
\AtBeginOfPackageFile*{fink}{% |
| 1301 |
\RequirePackage{kvoptions}% |
| 1302 |
\begingroup |
| 1303 |
\filehook@let{InputIfFileExists}{latex@InputIfFileExists}% |
| 1304 |
}% |
| 1305 |
\AtEndOfPackageFile*{fink}{% |
| 1306 |
\edef\@tempa{\noexpand\PassOptionsToPackage{mainext=\fnk@mainext,maindir=\fnk@maindir}{currfile}}% |
| 1307 |
\expandafter\endgroup\@tempa |
| 1308 |
\RequirePackage{filehook-fink}% |
| 1309 |
}% |
| 1310 |
% \end{macrocode} |
| 1311 |
% If |memoir| is detected its hooks |
| 1312 |
% are added to the appropriate `At...OfFiles' hooks. This works fine because its hooks have the |
| 1313 |
% exact same position. Please note that the case when |memoir| is used together with |scrlfile| is not explicitly covered. |
| 1314 |
% In this case the |scrlfile| package will overwrite |memoir|s definition. |
| 1315 |
% \begin{macrocode} |
| 1316 |
\AtBeginOfClassFile{memoir}{% |
| 1317 |
\filehook@let{InputIfFileExists}{latex@InputIfFileExists}% |
| 1318 |
\let\@iinput\filehook@orig@@iinput |
| 1319 |
}% |
| 1320 |
\AtEndOfClassFile*{memoir}{% |
| 1321 |
\let\@iinput\filehook@@iinput |
| 1322 |
\RequirePackage{filehook-memoir}% |
| 1323 |
}% |
| 1324 |
% \end{macrocode} |
| 1325 |
% Finally, if no specific alternate definition is detected the original \LaTeX\ definition is checked for and a |
| 1326 |
% error is given if any other unknown definition is detected. |
| 1327 |
% The \opt{force} option will change the error into a warning and overwrite the macro with the default. |
| 1328 |
% \begin{macrocode} |
| 1329 |
\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% |
| 1330 |
{}% already set up |
| 1331 |
{% |
| 1332 |
\filehook@cmp{InputIfFileExists}{latex@InputIfFileExists}% |
| 1333 |
{% |
| 1334 |
\filehook@let{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% |
| 1335 |
\filehook@let{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% |
| 1336 |
\filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% |
| 1337 |
}% |
| 1338 |
{% |
| 1339 |
\iffilehook@force |
| 1340 |
\filehook@let{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% |
| 1341 |
\filehook@let{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% |
| 1342 |
\filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% |
| 1343 |
\PackageWarning{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% |
| 1344 |
The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% |
| 1345 |
\else |
| 1346 |
\PackageError{filehook}{Detected unknown definition of \string\InputIfFileExists.^^J% |
| 1347 |
Use the 'force' option of 'filehook' to overwrite it.}{}% |
| 1348 |
\fi |
| 1349 |
}% |
| 1350 |
}% |
| 1351 |
% \end{macrocode} |
| 1352 |
% \end{macro} |
| 1353 |
% |
| 1354 |
% \begin{macrocode} |
| 1355 |
\AtBeginDocument{% |
| 1356 |
% Check if definition got changed again. For the new LaTeX format we check again \InputIfFileExists<space>, |
| 1357 |
% for the old format to \InputIfFileExists directly. |
| 1358 |
\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}{}{% |
| 1359 |
\PackageWarning{filehook}{Macro \string\InputIfFileExists\space got redefined after 'filehook' was loaded.^^J% |
| 1360 |
Certain file hooks might now be dysfunctional!}% |
| 1361 |
}% |
| 1362 |
} |
| 1363 |
% \end{macrocode} |
| 1364 |
% |
| 1365 |
% \iffalse |
| 1366 |
%</filehook-2019.sty> |
| 1367 |
% \fi |
| 1368 |
% |
| 1369 |
% \iffalse |
| 1370 |
%<*filehook-2020.sty> |
| 1371 |
% \fi |
| 1372 |
% \begin{macrocode} |
| 1373 |
%<!COPYRIGHT> |
| 1374 |
\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 1375 |
\ProvidesPackage{filehook-2020}[% filehook subpackage, do not load directly |
| 1376 |
%<!DATE> |
| 1377 |
%<!VERSION> |
| 1378 |
%<*DRIVER> |
| 1379 |
2099/01/01 develop |
| 1380 |
%</DRIVER> |
| 1381 |
Hooks for input files] |
| 1382 |
% \end{macrocode} |
| 1383 |
% |
| 1384 |
% |
| 1385 |
% \subsection{Options} |
| 1386 |
% \begin{macrocode} |
| 1387 |
\DeclareOption{force}{} |
| 1388 |
\ProcessOptions\relax |
| 1389 |
% \end{macrocode} |
| 1390 |
% |
| 1391 |
% \subsection{General stuff} |
| 1392 |
% |
| 1393 |
% \subsection{Initialisation of Hooks} |
| 1394 |
% The general hooks are initialised to call the file specific hooks. |
| 1395 |
% |
| 1396 |
% \begin{macro}{\filehook@csuse} |
| 1397 |
% \begin{macrocode} |
| 1398 |
\begingroup |
| 1399 |
\gdef\filehook@csuse#1{\ifcsname #1\endcsname\csname #1\expandafter\endcsname\fi} |
| 1400 |
\expandafter\ifx\csname csuse\endcsname\relax |
| 1401 |
\expandafter\ifx\csname ifcsname\endcsname\relax |
| 1402 |
\gdef\filehook@csuse#1{\expandafter\ifx\csname #1\endcsname\relax\else\csname #1\expandafter\endcsname\fi} |
| 1403 |
\fi |
| 1404 |
\else |
| 1405 |
\global\let\filehook@csuse\csuse |
| 1406 |
\fi |
| 1407 |
\endgroup |
| 1408 |
% \end{macrocode} |
| 1409 |
% \end{macro} |
| 1410 |
% |
| 1411 |
% \begin{macro}{\filehook@include@atbegin} |
| 1412 |
% \begin{macrocode} |
| 1413 |
\def\filehook@include@atbegin#1{% |
| 1414 |
\filehook@csuse{\filehook@include@atbegin@#1}% |
| 1415 |
\filehook@include@@atbegin |
| 1416 |
} |
| 1417 |
% \end{macrocode} |
| 1418 |
% \end{macro} |
| 1419 |
% |
| 1420 |
% \begin{macro}{\filehook@include@@atbegin} |
| 1421 |
% \begin{macrocode} |
| 1422 |
\def\filehook@include@@atbegin{} |
| 1423 |
% \end{macrocode} |
| 1424 |
% \end{macro} |
| 1425 |
% |
| 1426 |
% \begin{macro}{\filehook@include@atend} |
| 1427 |
% \begin{macrocode} |
| 1428 |
\def\filehook@include@atend#1{% |
| 1429 |
\filehook@include@@atend |
| 1430 |
\filehook@csuse{\filehook@include@atend@#1}% |
| 1431 |
} |
| 1432 |
% \end{macrocode} |
| 1433 |
% \end{macro} |
| 1434 |
% |
| 1435 |
% \begin{macro}{\filehook@include@@atend} |
| 1436 |
% \begin{macrocode} |
| 1437 |
\def\filehook@include@@atend{} |
| 1438 |
% \end{macrocode} |
| 1439 |
% \end{macro} |
| 1440 |
% |
| 1441 |
% \begin{macro}{\filehook@include@after} |
| 1442 |
% \begin{macrocode} |
| 1443 |
\def\filehook@include@after#1{% |
| 1444 |
\filehook@include@@after |
| 1445 |
\filehook@csuse{\filehook@include@after@#1}% |
| 1446 |
} |
| 1447 |
% \end{macrocode} |
| 1448 |
% \end{macro} |
| 1449 |
% |
| 1450 |
% \begin{macro}{\filehook@include@@after} |
| 1451 |
% \begin{macrocode} |
| 1452 |
\def\filehook@include@@after{} |
| 1453 |
% \end{macrocode} |
| 1454 |
% \end{macro} |
| 1455 |
% |
| 1456 |
% \begin{macro}{\filehook@input@atbegin} |
| 1457 |
% \begin{macrocode} |
| 1458 |
\def\filehook@input@atbegin#1{% |
| 1459 |
\filehook@csuse{\filehook@input@atbegin@\filehook@ensureext{#1}}% |
| 1460 |
\filehook@input@@atbegin |
| 1461 |
} |
| 1462 |
% \end{macrocode} |
| 1463 |
% \end{macro} |
| 1464 |
% |
| 1465 |
% \begin{macro}{\filehook@input@@atbegin} |
| 1466 |
% \begin{macrocode} |
| 1467 |
\def\filehook@input@@atbegin{} |
| 1468 |
% \end{macrocode} |
| 1469 |
% \end{macro} |
| 1470 |
% |
| 1471 |
% \begin{macro}{\filehook@input@atend} |
| 1472 |
% \begin{macrocode} |
| 1473 |
\def\filehook@input@atend#1{% |
| 1474 |
\filehook@input@@atend |
| 1475 |
\filehook@csuse{\filehook@input@atend@\filehook@ensureext{#1}}% |
| 1476 |
} |
| 1477 |
% \end{macrocode} |
| 1478 |
% \end{macro} |
| 1479 |
% |
| 1480 |
% \begin{macro}{\filehook@input@@atend} |
| 1481 |
% \begin{macrocode} |
| 1482 |
\def\filehook@input@@atend{} |
| 1483 |
% \end{macrocode} |
| 1484 |
% \end{macro} |
| 1485 |
% |
| 1486 |
% \begin{macro}{\filehook@atbegin} |
| 1487 |
% \begin{macrocode} |
| 1488 |
\def\filehook@atbegin#1{% |
| 1489 |
\filehook@csuse{\filehook@atbegin@\filehook@ensureext{#1}}% |
| 1490 |
\filehook@@atbegin |
| 1491 |
} |
| 1492 |
% \end{macrocode} |
| 1493 |
% \end{macro} |
| 1494 |
% |
| 1495 |
% \begin{macro}{\filehook@@atbegin} |
| 1496 |
% \begin{macrocode} |
| 1497 |
\def\filehook@@atbegin{} |
| 1498 |
% \end{macrocode} |
| 1499 |
% \end{macro} |
| 1500 |
% |
| 1501 |
% \begin{macro}{\filehook@atend} |
| 1502 |
% \begin{macrocode} |
| 1503 |
\def\filehook@atend#1{% |
| 1504 |
\filehook@@atend |
| 1505 |
\filehook@csuse{\filehook@atend@\filehook@ensureext{#1}}% |
| 1506 |
} |
| 1507 |
% \end{macrocode} |
| 1508 |
% \end{macro} |
| 1509 |
% |
| 1510 |
% \begin{macro}{\filehook@@atend} |
| 1511 |
% \begin{macrocode} |
| 1512 |
\def\filehook@@atend{} |
| 1513 |
% \end{macrocode} |
| 1514 |
% \end{macro} |
| 1515 |
% |
| 1516 |
% \begin{macro}{\filehook@every@atbegin} |
| 1517 |
% \begin{macrocode} |
| 1518 |
\def\filehook@every@atbegin#1{% |
| 1519 |
\filehook@every@@atbegin |
| 1520 |
} |
| 1521 |
% \end{macrocode} |
| 1522 |
% \end{macro} |
| 1523 |
% |
| 1524 |
% \begin{macro}{\filehook@every@@atbegin} |
| 1525 |
% \begin{macrocode} |
| 1526 |
\def\filehook@every@@atbegin{} |
| 1527 |
% \end{macrocode} |
| 1528 |
% \end{macro} |
| 1529 |
% |
| 1530 |
% \begin{macro}{\filehook@every@atend} |
| 1531 |
% \begin{macrocode} |
| 1532 |
\def\filehook@every@atend#1{% |
| 1533 |
\filehook@every@@atend |
| 1534 |
} |
| 1535 |
% \end{macrocode} |
| 1536 |
% \end{macro} |
| 1537 |
% |
| 1538 |
% \begin{macro}{\filehook@every@@atend} |
| 1539 |
% \begin{macrocode} |
| 1540 |
\def\filehook@every@@atend{} |
| 1541 |
% \end{macrocode} |
| 1542 |
% \end{macro} |
| 1543 |
% |
| 1544 |
% |
| 1545 |
% |
| 1546 |
% \subsection{Hook Modification Macros} |
| 1547 |
% The following macros are used to modify the hooks, i.e.\ to prefix or append code to them. |
| 1548 |
% |
| 1549 |
% |
| 1550 |
% \subsubsection*{Internal Macros} |
| 1551 |
% |
| 1552 |
% The macro prefixes for the file specific hooks are stored in macros to reduce the number of |
| 1553 |
% tokens in the following macro definitions. |
| 1554 |
% \begin{macrocode} |
| 1555 |
\def\filehook@include@atbegin@{filehook@include@atbegin@} |
| 1556 |
\def\filehook@include@atend@{filehook@include@atend@} |
| 1557 |
\def\filehook@include@after@{filehook@include@after@} |
| 1558 |
\def\filehook@input@atbegin@{filehook@input@atbegin@} |
| 1559 |
\def\filehook@input@atend@{filehook@input@atend@} |
| 1560 |
\def\filehook@input@after@{filehook@input@after@} |
| 1561 |
\def\filehook@atbegin@{filehook@atbegin@} |
| 1562 |
\def\filehook@atend@{filehook@atend@} |
| 1563 |
\def\filehook@after@{filehook@after@} |
| 1564 |
% \end{macrocode} |
| 1565 |
% |
| 1566 |
% |
| 1567 |
% \begin{macro}{\filehook@append} |
| 1568 |
% Uses default \LaTeX{} macro. |
| 1569 |
% \begin{macrocode} |
| 1570 |
\def\filehook@append{\g@addto@macro} |
| 1571 |
% \end{macrocode} |
| 1572 |
% \end{macro} |
| 1573 |
% |
| 1574 |
% \begin{macro}{\filehook@appendwarg} |
| 1575 |
% Appends code with one macro argument. The |\@tempa| intermediate step is required because of the |
| 1576 |
% included |##1| which wouldn't correctly expand otherwise. |
| 1577 |
% \begin{macrocode} |
| 1578 |
\long\def\filehook@appendwarg#1#2{% |
| 1579 |
\begingroup |
| 1580 |
\toks@\expandafter{#1{##1}#2}% |
| 1581 |
\edef\@tempa{\the\toks@}% |
| 1582 |
\expandafter\gdef\expandafter#1\expandafter##\expandafter1\expandafter{\@tempa}% |
| 1583 |
\endgroup |
| 1584 |
} |
| 1585 |
% \end{macrocode} |
| 1586 |
% \end{macro} |
| 1587 |
% |
| 1588 |
% \begin{macro}{\filehook@prefix} |
| 1589 |
% Prefixes code to a hook. |
| 1590 |
% \begin{macrocode} |
| 1591 |
\long\def\filehook@prefix#1#2{% |
| 1592 |
\begingroup |
| 1593 |
\@temptokena{#2}% |
| 1594 |
\toks@\expandafter{#1}% |
| 1595 |
\xdef#1{\the\@temptokena\the\toks@}% |
| 1596 |
\endgroup |
| 1597 |
} |
| 1598 |
% \end{macrocode} |
| 1599 |
% \end{macro} |
| 1600 |
% |
| 1601 |
% \begin{macro}{\filehook@prefixwarg} |
| 1602 |
% Prefixes code with an argument to a hook. |
| 1603 |
% \begin{macrocode} |
| 1604 |
\long\def\filehook@prefixwarg#1#2{% |
| 1605 |
\begingroup |
| 1606 |
\@temptokena{#2}% |
| 1607 |
\toks@\expandafter{#1{##1}}% |
| 1608 |
\edef\@tempa{\the\@temptokena\the\toks@}% |
| 1609 |
\expandafter\gdef\expandafter#1\expandafter##\expandafter1\expandafter{\@tempa}% |
| 1610 |
\endgroup |
| 1611 |
} |
| 1612 |
% \end{macrocode} |
| 1613 |
% \end{macro} |
| 1614 |
% |
| 1615 |
% \begin{macro}{\filehook@addtohook}[3]{Macro which should be used to add the material to the hook}{Macro name prefix}{End of macro name (file name)} |
| 1616 |
% The macro first expands the file name (|#3|) to flatten all included macros. An extension is added if missing, as well as the prefix. |
| 1617 |
% All modifications of |\@tempa| are made inside a group to keep them local. |
| 1618 |
% \begin{macrocode} |
| 1619 |
\def\filehook@addtohook#1#2#3{% |
| 1620 |
\begingroup |
| 1621 |
\edef\@tempa{#3}% |
| 1622 |
\edef\@tempa{#2\filehook@ensureext{\@tempa}}% |
| 1623 |
\@ifundefined{\@tempa}{\global\@namedef{\@tempa}{}}{}% |
| 1624 |
\expandafter\endgroup |
| 1625 |
\expandafter#1\csname\@tempa\endcsname |
| 1626 |
} |
| 1627 |
% \end{macrocode} |
| 1628 |
% \end{macro} |
| 1629 |
% |
| 1630 |
% \subsubsection*{User Level Macros} |
| 1631 |
% The user level macros simple use the above defined macros on the appropriate hook. |
| 1632 |
% |
| 1633 |
% \begin{macro}{\AtBeginOfIncludes} |
| 1634 |
% \begin{macrocode} |
| 1635 |
\newcommand*\AtBeginOfIncludes{% |
| 1636 |
\filehook@append\filehook@include@@atbegin |
| 1637 |
} |
| 1638 |
% \end{macrocode} |
| 1639 |
% \end{macro} |
| 1640 |
% |
| 1641 |
% \begin{macro}{\AtEndOfIncludes} |
| 1642 |
% \begin{macrocode} |
| 1643 |
\newcommand*\AtEndOfIncludes{% |
| 1644 |
\filehook@prefix\filehook@include@@atend |
| 1645 |
} |
| 1646 |
% \end{macrocode} |
| 1647 |
% \end{macro} |
| 1648 |
% |
| 1649 |
% \begin{macro}{\AfterIncludes} |
| 1650 |
% \begin{macrocode} |
| 1651 |
\newcommand*\AfterIncludes{% |
| 1652 |
\filehook@prefix\filehook@include@@after |
| 1653 |
} |
| 1654 |
% \end{macrocode} |
| 1655 |
% \end{macro} |
| 1656 |
% |
| 1657 |
% \begin{macro}{\AtBeginOfIncludeFile} |
| 1658 |
% \begin{macrocode} |
| 1659 |
\newcommand*\AtBeginOfIncludeFile[1]{% |
| 1660 |
\filehook@addtohook\filehook@append\filehook@include@atbegin@{\filehook@ensuretex{#1}}% |
| 1661 |
} |
| 1662 |
% \end{macrocode} |
| 1663 |
% \end{macro} |
| 1664 |
% |
| 1665 |
% \begin{macro}{\AtEndOfIncludeFile} |
| 1666 |
% \begin{macrocode} |
| 1667 |
\newcommand*\AtEndOfIncludeFile[1]{% |
| 1668 |
\filehook@addtohook\filehook@prefix\filehook@include@atend@{\filehook@ensuretex{#1}}% |
| 1669 |
} |
| 1670 |
% \end{macrocode} |
| 1671 |
% \end{macro} |
| 1672 |
% |
| 1673 |
% \begin{macro}{\AfterIncludeFile} |
| 1674 |
% \begin{macrocode} |
| 1675 |
\newcommand*\AfterIncludeFile[1]{% |
| 1676 |
\filehook@addtohook\filehook@prefix\filehook@include@after@{\filehook@ensuretex{#1}}% |
| 1677 |
} |
| 1678 |
% \end{macrocode} |
| 1679 |
% \end{macro} |
| 1680 |
% |
| 1681 |
% \begin{macro}{\AtBeginOfInputs} |
| 1682 |
% \begin{macrocode} |
| 1683 |
\newcommand*\AtBeginOfInputs{% |
| 1684 |
\filehook@append\filehook@input@@atbegin |
| 1685 |
} |
| 1686 |
% \end{macrocode} |
| 1687 |
% \end{macro} |
| 1688 |
% |
| 1689 |
% \begin{macro}{\AtEndOfInputs} |
| 1690 |
% \begin{macrocode} |
| 1691 |
\newcommand*\AtEndOfInputs{% |
| 1692 |
\filehook@prefix\filehook@input@@atend |
| 1693 |
} |
| 1694 |
% \end{macrocode} |
| 1695 |
% \end{macro} |
| 1696 |
% |
| 1697 |
% \begin{macro}{\AtBeginOfInputFile} |
| 1698 |
% \begin{macrocode} |
| 1699 |
\newcommand*\AtBeginOfInputFile{% |
| 1700 |
\filehook@addtohook\filehook@append\filehook@input@atbegin@ |
| 1701 |
} |
| 1702 |
% \end{macrocode} |
| 1703 |
% \end{macro} |
| 1704 |
% |
| 1705 |
% \begin{macro}{\AtEndOfInputFile} |
| 1706 |
% \begin{macrocode} |
| 1707 |
\newcommand*\AtEndOfInputFile{% |
| 1708 |
\filehook@addtohook\filehook@prefix\filehook@input@atend@ |
| 1709 |
} |
| 1710 |
% \end{macrocode} |
| 1711 |
% \end{macro} |
| 1712 |
% |
| 1713 |
% \begin{macro}{\AtBeginOfFiles} |
| 1714 |
% \begin{macrocode} |
| 1715 |
\newcommand*\AtBeginOfFiles{% |
| 1716 |
\filehook@append\filehook@@atbegin |
| 1717 |
} |
| 1718 |
% \end{macrocode} |
| 1719 |
% \end{macro} |
| 1720 |
% |
| 1721 |
% \begin{macro}{\AtEndOfFiles} |
| 1722 |
% \begin{macrocode} |
| 1723 |
\newcommand*\AtEndOfFiles{% |
| 1724 |
\filehook@prefix\filehook@@atend |
| 1725 |
} |
| 1726 |
% \end{macrocode} |
| 1727 |
% \end{macro} |
| 1728 |
% |
| 1729 |
% \begin{macro}{\AtBeginOfEveryFile} |
| 1730 |
% \begin{macrocode} |
| 1731 |
\newcommand*\AtBeginOfEveryFile{% |
| 1732 |
\filehook@append\filehook@every@@atbegin |
| 1733 |
} |
| 1734 |
% \end{macrocode} |
| 1735 |
% \end{macro} |
| 1736 |
% |
| 1737 |
% \begin{macro}{\AtEndOfEveryFile} |
| 1738 |
% \begin{macrocode} |
| 1739 |
\newcommand*\AtEndOfEveryFile{% |
| 1740 |
\filehook@prefix\filehook@every@@atend |
| 1741 |
} |
| 1742 |
% \end{macrocode} |
| 1743 |
% \end{macro} |
| 1744 |
% |
| 1745 |
% \begin{macro}{\AtBeginOfFile} |
| 1746 |
% \begin{macrocode} |
| 1747 |
\newcommand*\AtBeginOfFile{% |
| 1748 |
\filehook@addtohook\filehook@append\filehook@atbegin@ |
| 1749 |
} |
| 1750 |
% \end{macrocode} |
| 1751 |
% \end{macro} |
| 1752 |
% |
| 1753 |
% \begin{macro}{\AtEndOfFile} |
| 1754 |
% \begin{macrocode} |
| 1755 |
\newcommand*\AtEndOfFile{% |
| 1756 |
\filehook@addtohook\filehook@prefix\filehook@atend@ |
| 1757 |
} |
| 1758 |
% \end{macrocode} |
| 1759 |
% \end{macro} |
| 1760 |
% |
| 1761 |
% |
| 1762 |
% |
| 1763 |
% \begin{macro}{\AtBeginOfClassFile} |
| 1764 |
% \begin{macrocode} |
| 1765 |
\newcommand*\AtBeginOfClassFile{% |
| 1766 |
\@ifnextchar* |
| 1767 |
{\AtBeginOfXFile@star\@clsextension}% |
| 1768 |
{\AtBeginOfXFile@normal\@clsextension}% |
| 1769 |
} |
| 1770 |
% \end{macrocode} |
| 1771 |
% \end{macro} |
| 1772 |
% |
| 1773 |
% \begin{macro}{\AtBeginOfPackageFile} |
| 1774 |
% \begin{macrocode} |
| 1775 |
\newcommand*\AtBeginOfPackageFile{% |
| 1776 |
\@ifnextchar* |
| 1777 |
{\AtBeginOfXFile@star\@pkgextension}% |
| 1778 |
{\AtBeginOfXFile@normal\@pkgextension}% |
| 1779 |
} |
| 1780 |
% \end{macrocode} |
| 1781 |
% \end{macro} |
| 1782 |
% |
| 1783 |
% \begin{macro}{\AtBeginOfXFile@star}[2]{extension}{name} |
| 1784 |
% If the class or package is already loaded the code is executed right away. |
| 1785 |
% Otherwise it is installed normally. |
| 1786 |
% \begin{macrocode} |
| 1787 |
\def\AtBeginOfXFile@star#1*#2{% |
| 1788 |
\@ifl@aded{#1}{#2}% |
| 1789 |
{\@firstofone}% |
| 1790 |
{\AtBeginOfXFile@normal{#1}{#2}}% |
| 1791 |
} |
| 1792 |
% \end{macrocode} |
| 1793 |
% \end{macro} |
| 1794 |
% |
| 1795 |
% \begin{macro}{\AtBeginOfXFile@normal}[2]{extension}{name} |
| 1796 |
% \begin{macrocode} |
| 1797 |
\def\AtBeginOfXFile@normal#1#2{% |
| 1798 |
\AtBeginOfFile{#2.#1}% |
| 1799 |
} |
| 1800 |
% \end{macrocode} |
| 1801 |
% \end{macro} |
| 1802 |
% |
| 1803 |
% |
| 1804 |
% \begin{macro}{\AtEndOfClassFile} |
| 1805 |
% \begin{macrocode} |
| 1806 |
\newcommand*\AtEndOfClassFile{% |
| 1807 |
\@ifnextchar* |
| 1808 |
{\AtEndOfXFile@star\@clsextension}% |
| 1809 |
{\AtEndOfXFile@normal\@clsextension}% |
| 1810 |
} |
| 1811 |
% \end{macrocode} |
| 1812 |
% \end{macro} |
| 1813 |
% |
| 1814 |
% \begin{macro}{\AtEndOfPackageFile} |
| 1815 |
% \begin{macrocode} |
| 1816 |
\newcommand*\AtEndOfPackageFile{% |
| 1817 |
\@ifnextchar* |
| 1818 |
{\AtEndOfXFile@star\@pkgextension}% |
| 1819 |
{\AtEndOfXFile@normal\@pkgextension}% |
| 1820 |
} |
| 1821 |
% \end{macrocode} |
| 1822 |
% \end{macro} |
| 1823 |
% |
| 1824 |
% |
| 1825 |
% \begin{macro}{\AtEndOfXFile@star}[2]{extension}{name} |
| 1826 |
% If the class or package is already loaded the code is executed right away. |
| 1827 |
% Otherwise it is installed normally. |
| 1828 |
% \begin{macrocode} |
| 1829 |
\def\AtEndOfXFile@star#1*#2{% |
| 1830 |
\@ifl@aded{#1}{#2}% |
| 1831 |
{\@firstofone}% |
| 1832 |
{\AtEndOfXFile@normal{#1}{#2}}% |
| 1833 |
} |
| 1834 |
% \end{macrocode} |
| 1835 |
% \end{macro} |
| 1836 |
% |
| 1837 |
% \begin{macro}{\AtEndOfXFile@normal}[2]{extension}{name} |
| 1838 |
% Note that \Macro\AtEndOfClass is identical to \Macro\AtEndOfPackage, so no |
| 1839 |
% differentiation between classes and packages is needed here. |
| 1840 |
% \begin{macrocode} |
| 1841 |
\long\def\AtEndOfXFile@normal#1#2#3{% |
| 1842 |
\AtEndOfFile{#2.#1}{\AtEndOfPackage{#3}}% |
| 1843 |
} |
| 1844 |
% \end{macrocode} |
| 1845 |
% \end{macro} |
| 1846 |
% |
| 1847 |
% \begin{macro}{\ClearHook} |
| 1848 |
% Clears the hook by temporary redefining the prefix and append macros |
| 1849 |
% to do a simple definition to empty. |
| 1850 |
% \begin{macrocode} |
| 1851 |
\newcommand*\ClearHook{% |
| 1852 |
\begingroup |
| 1853 |
\def\filehook@prefix##1##2{% |
| 1854 |
\gdef##1{}% |
| 1855 |
\endgroup |
| 1856 |
}% |
| 1857 |
\let\filehook@append\filehook@prefix |
| 1858 |
} |
| 1859 |
% \end{macrocode} |
| 1860 |
% \end{macro} |
| 1861 |
% |
| 1862 |
% |
| 1863 |
% |
| 1864 |
% |
| 1865 |
% \subsection{Installation of Hooks} |
| 1866 |
% The \Macro\@input@ and \Macro\@iinput macros from |latex.ltx| are redefined to install the hooks. |
| 1867 |
% |
| 1868 |
% \begin{macro}{\@input@} |
| 1869 |
% This macro is redefined for the \Macro\include file hooks. |
| 1870 |
% Checks if the next command is \Macro\clearpage which indicates that we are inside \Macro\@include. |
| 1871 |
% If so the hooks are installed, otherwise the original macro is used unchanged. |
| 1872 |
% For the `after' hook an own \Macro\clearpage is inserted and the original one is gobbled. |
| 1873 |
% |
| 1874 |
% \begin{macrocode} |
| 1875 |
\def\DEPRECATED@input@#1{% |
| 1876 |
\@ifnextchar\clearpage |
| 1877 |
{% |
| 1878 |
\filehook@every@atbegin{#1}% |
| 1879 |
\filehook@include@atbegin{#1}% |
| 1880 |
\filehook@orig@@input@{#1}% |
| 1881 |
\filehook@include@atend{#1}% |
| 1882 |
\clearpage |
| 1883 |
\filehook@include@after{#1}% |
| 1884 |
\filehook@every@atend{#1}% |
| 1885 |
\@gobble |
| 1886 |
}% |
| 1887 |
{\filehook@orig@@input@{#1}}% |
| 1888 |
} |
| 1889 |
% \end{macrocode} |
| 1890 |
% \end{macro} |
| 1891 |
% |
| 1892 |
% \begin{macro}{\@iinput} |
| 1893 |
% This macro is redefined for the \Macro\input file hooks. |
| 1894 |
% it simply surrounds the original macro with the hooks. |
| 1895 |
% \begin{macrocode} |
| 1896 |
\def\filehook@@iinput#1{% |
| 1897 |
\filehook@every@atbegin{#1}% |
| 1898 |
\filehook@input@atbegin{#1}% |
| 1899 |
\filehook@orig@@iinput{#1}% |
| 1900 |
\filehook@input@atend{#1}% |
| 1901 |
\filehook@every@atend{#1}% |
| 1902 |
} |
| 1903 |
%\let\@iinput\filehook@@iinput |
| 1904 |
% \end{macrocode} |
| 1905 |
% \end{macro} |
| 1906 |
% |
| 1907 |
% \begin{macro}{\filehook@ensureext} |
| 1908 |
% This macro ensures the existence of a file name extension. If non is given `|.tex|' is |
| 1909 |
% added. |
| 1910 |
% \begin{macrocode} |
| 1911 |
\def\filehook@ensureext#1{% |
| 1912 |
\expandafter\filehook@@ensureext#1\empty.tex\empty\empty |
| 1913 |
} |
| 1914 |
% \end{macrocode} |
| 1915 |
% \end{macro} |
| 1916 |
% |
| 1917 |
% \begin{macro}{\filehook@@ensureext} |
| 1918 |
% \begin{macrocode} |
| 1919 |
\def\filehook@@ensureext#1.#2\empty#3\empty{#1.#2} |
| 1920 |
% \end{macrocode} |
| 1921 |
% \end{macro} |
| 1922 |
% |
| 1923 |
% |
| 1924 |
% \begin{macro}{\filehook@ensuretex} |
| 1925 |
% Ensures a `|.tex|' extension, i.e. adds it if missing, even if there is a different one. |
| 1926 |
% \begin{macrocode} |
| 1927 |
\def\filehook@ensuretex#1{% |
| 1928 |
\expandafter\filehook@@ensuretex#1\empty.tex\empty\empty |
| 1929 |
} |
| 1930 |
% \end{macrocode} |
| 1931 |
% \end{macro} |
| 1932 |
% |
| 1933 |
% \begin{macro}{\filehook@@ensuretex} |
| 1934 |
% \begin{macrocode} |
| 1935 |
\def\filehook@@ensuretex#1.tex\empty#2\empty{#1.tex} |
| 1936 |
% \end{macrocode} |
| 1937 |
% \end{macro} |
| 1938 |
% |
| 1939 |
% \begin{macro}{\filehook@set@CurrentFile} |
| 1940 |
% \begin{macrocode} |
| 1941 |
\def\filehook@set@CurrentFile{% |
| 1942 |
\edef\filehook@CurrentFile{% |
| 1943 |
\ifx\CurrentFilePath\empty |
| 1944 |
\else |
| 1945 |
\CurrentFilePath/% |
| 1946 |
\fi |
| 1947 |
\CurrentFile |
| 1948 |
}% |
| 1949 |
} |
| 1950 |
% \end{macrocode} |
| 1951 |
% \end{macro} |
| 1952 |
% |
| 1953 |
% \begin{macro}{\Hook} |
| 1954 |
% \begin{macrocode} |
| 1955 |
\AddToHook{include/before}{% |
| 1956 |
\filehook@set@CurrentFile |
| 1957 |
\filehook@include@atbegin{\filehook@CurrentFile}% |
| 1958 |
} |
| 1959 |
% \end{macrocode} |
| 1960 |
% \end{macro} |
| 1961 |
% |
| 1962 |
% \begin{macro}{\Hook} |
| 1963 |
% \begin{macrocode} |
| 1964 |
\AddToHook{include/end}{% |
| 1965 |
\filehook@set@CurrentFile |
| 1966 |
\filehook@include@atend{\filehook@CurrentFile}% |
| 1967 |
} |
| 1968 |
% \end{macrocode} |
| 1969 |
% \end{macro} |
| 1970 |
% |
| 1971 |
% \begin{macro}{\Hook} |
| 1972 |
% \begin{macrocode} |
| 1973 |
\AddToHook{include/after}{% |
| 1974 |
\filehook@set@CurrentFile |
| 1975 |
\filehook@include@after{\filehook@CurrentFile}% |
| 1976 |
} |
| 1977 |
% \end{macrocode} |
| 1978 |
% \end{macro} |
| 1979 |
% |
| 1980 |
% \begin{macro}{\filehook@istexfile} |
| 1981 |
% \begin{macrocode} |
| 1982 |
\begingroup |
| 1983 |
\edef\dottex{\expandafter\expandafter\expandafter\@gobble\expandafter\string\csname.tex\endcsname} |
| 1984 |
\expandafter |
| 1985 |
\gdef\expandafter\filehook@istexfile\expandafter#\expandafter1\expandafter{% |
| 1986 |
\expandafter\expandafter\expandafter\filehook@istexfile@\expandafter#\expandafter1\expandafter\empty\dottex\empty\empty\@nil |
| 1987 |
} |
| 1988 |
% \end{macrocode} |
| 1989 |
% \end{macro} |
| 1990 |
% |
| 1991 |
% \begin{macro}{\filehook@istexfile@} |
| 1992 |
% \begin{macrocode} |
| 1993 |
\expandafter\gdef\expandafter\filehook@istexfile@\expandafter#\expandafter1\dottex\empty#2\empty#3\@nil{% |
| 1994 |
\begingroup |
| 1995 |
\def\@tempa{#2}% |
| 1996 |
\ifx\@tempa\empty |
| 1997 |
\endgroup |
| 1998 |
\expandafter\@secondoftwo |
| 1999 |
\else |
| 2000 |
\endgroup |
| 2001 |
\expandafter\@firstoftwo |
| 2002 |
\fi |
| 2003 |
} |
| 2004 |
\endgroup |
| 2005 |
% \end{macrocode} |
| 2006 |
% \end{macro} |
| 2007 |
% |
| 2008 |
% |
| 2009 |
% \begin{macro}{\Hook} |
| 2010 |
% \begin{macrocode} |
| 2011 |
\AddToHook{file/before}{% |
| 2012 |
\filehook@set@CurrentFile |
| 2013 |
\filehook@every@atbegin{\filehook@CurrentFile}% |
| 2014 |
\filehook@istexfile\filehook@CurrentFile{\filehook@input@atbegin{\filehook@CurrentFile}}{}% |
| 2015 |
\filehook@atbegin{\filehook@CurrentFile}% |
| 2016 |
} |
| 2017 |
% \end{macrocode} |
| 2018 |
% \end{macro} |
| 2019 |
% |
| 2020 |
% \begin{macro}{\Hook} |
| 2021 |
% \begin{macrocode} |
| 2022 |
\AddToHook{file/after}{% |
| 2023 |
\filehook@set@CurrentFile |
| 2024 |
\filehook@atend{\filehook@CurrentFile}% |
| 2025 |
\filehook@istexfile\filehook@CurrentFile{\filehook@input@atend{\filehook@CurrentFile}}{}% |
| 2026 |
\filehook@every@atend{\filehook@CurrentFile}% |
| 2027 |
} |
| 2028 |
% \end{macrocode} |
| 2029 |
% \end{macro} |
| 2030 |
% |
| 2031 |
% \iffalse |
| 2032 |
%</filehook-2020.sty> |
| 2033 |
% \fi |
| 2034 |
% |
| 2035 |
% \iffalse |
| 2036 |
%<*filehook-memoir.sty> |
| 2037 |
% \fi |
| 2038 |
% \begin{macrocode} |
| 2039 |
%<!COPYRIGHT> |
| 2040 |
\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 2041 |
\ProvidesPackage{filehook-memoir}[2020/02/02 v0.2 filehook patch for memoir class] |
| 2042 |
% \end{macrocode} |
| 2043 |
% |
| 2044 |
% \begin{macrocode} |
| 2045 |
\RequirePackage{filehook} |
| 2046 |
\begingroup |
| 2047 |
% \end{macrocode} |
| 2048 |
% |
| 2049 |
% \begin{macro}{\memoir@InputIfFileExists} |
| 2050 |
% The definition taken from memoir.cls. Copyright see there. |
| 2051 |
% \begin{macrocode} |
| 2052 |
\ifcsname InputIfFileExists\space\endcsname |
| 2053 |
\DeclareRobustCommand \memoir@InputIfFileExists[2]{% |
| 2054 |
\IfFileExists{#1}% |
| 2055 |
{% |
| 2056 |
\expandafter\@swaptwoargs\expandafter |
| 2057 |
{\@filef@und\m@matendf{#1}\killm@matf{#1}}{% |
| 2058 |
#2\@addtofilelist{#1}\m@matbeginf{#1}\@@input% |
| 2059 |
}% |
| 2060 |
}% |
| 2061 |
} |
| 2062 |
\else |
| 2063 |
% Old definition |
| 2064 |
\renewcommand{\memoir@InputIfFileExists}[2]{% |
| 2065 |
\IfFileExists{#1}% |
| 2066 |
{#2\@addtofilelist{#1}\m@matbeginf{#1}% |
| 2067 |
\@@input \@filef@und |
| 2068 |
\m@matendf{#1}% |
| 2069 |
\killm@matf{#1}}% |
| 2070 |
} |
| 2071 |
\fi |
| 2072 |
% \end{macrocode} |
| 2073 |
% \end{macro} |
| 2074 |
% |
| 2075 |
% \begin{macrocode} |
| 2076 |
\@tempswafalse |
| 2077 |
\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% |
| 2078 |
{\@tempswatrue}% |
| 2079 |
{% |
| 2080 |
\filehook@cmp{InputIfFileExists}{memoir@InputIfFileExists}% |
| 2081 |
{\@tempswatrue}% |
| 2082 |
{}% |
| 2083 |
}% |
| 2084 |
|
| 2085 |
\if@tempswa |
| 2086 |
\filehook@glet{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% |
| 2087 |
\filehook@glet{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% |
| 2088 |
\filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% |
| 2089 |
\filehook@appendwarg\filehook@atbegin{\m@matbeginf{#1}}% |
| 2090 |
\filehook@prefixwarg\filehook@atend{\m@matendf{#1}\killm@matf{#1}}% |
| 2091 |
\PackageInfo{filehook}{Detected 'memoir' class: the memoir hooks will be moved to the `At...OfFiles' hooks} |
| 2092 |
\else |
| 2093 |
\iffilehook@force |
| 2094 |
\filehook@glet{filehook@InputIfFileExists}{filehook@default@InputIfFileExists}% |
| 2095 |
\filehook@glet{filehook@@InputIfFileExists}{filehook@@default@InputIfFileExists}% |
| 2096 |
\filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% |
| 2097 |
\PackageWarning{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists.^^J% |
| 2098 |
The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% |
| 2099 |
\else |
| 2100 |
\PackageError{filehook}{Detected 'memoir' class with unknown definition of \string\InputIfFileExists.^^J% |
| 2101 |
Use the 'force' option of 'filehook' to overwrite it.}{}% |
| 2102 |
\fi |
| 2103 |
\fi |
| 2104 |
% \end{macrocode} |
| 2105 |
% |
| 2106 |
% \begin{macrocode} |
| 2107 |
\endgroup |
| 2108 |
% \end{macrocode} |
| 2109 |
% |
| 2110 |
% \iffalse |
| 2111 |
%</filehook-memoir.sty> |
| 2112 |
% \fi |
| 2113 |
% |
| 2114 |
% \iffalse |
| 2115 |
%<*filehook-listings.sty> |
| 2116 |
% \fi |
| 2117 |
% \begin{macrocode} |
| 2118 |
%<!COPYRIGHT> |
| 2119 |
\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 2120 |
\ProvidesPackage{filehook-listings}[2011/01/02 v0.1 Patch for listings to avoid hooks for verbatim input files] |
| 2121 |
% \end{macrocode} |
| 2122 |
% |
| 2123 |
% \begin{macrocode} |
| 2124 |
\begingroup |
| 2125 |
|
| 2126 |
\long\def\patch#1\def\lst@next#2#3\endpatch{% |
| 2127 |
\toks@{#2}% |
| 2128 |
\edef\@tempa{\the\toks@}% |
| 2129 |
\def\@tempb{\input{####1}}% |
| 2130 |
\ifx\@tempa\@tempb |
| 2131 |
\gdef\lst@InputListing##1{#1\def\lst@next{\@input{##1}}#3}% |
| 2132 |
\else |
| 2133 |
\PackageWarning{filehook-listings}{To-be-patched code in macro \string\lst@InputListing was not found!}% |
| 2134 |
\fi |
| 2135 |
} |
| 2136 |
|
| 2137 |
\@ifundefined{lst@InputListing}{% |
| 2138 |
\PackageWarning{filehook-listings}{To-be-patched Macro \string\lst@InputListing not found!}% |
| 2139 |
}{} |
| 2140 |
|
| 2141 |
\expandafter\patch\lst@InputListing{#1}\endpatch |
| 2142 |
|
| 2143 |
\endgroup |
| 2144 |
% \end{macrocode} |
| 2145 |
% |
| 2146 |
% \iffalse |
| 2147 |
%</filehook-listings.sty> |
| 2148 |
% \fi |
| 2149 |
% |
| 2150 |
% \iffalse |
| 2151 |
%<*filehook-scrlfile.sty> |
| 2152 |
% \fi |
| 2153 |
% \begin{macrocode} |
| 2154 |
%<!COPYRIGHT> |
| 2155 |
\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 2156 |
\ProvidesPackage{filehook-scrlfile}[2020/02/02 v0.2 filehook patch for scrlfile package] |
| 2157 |
\RequirePackage{filehook} |
| 2158 |
\begingroup |
| 2159 |
% \end{macrocode} |
| 2160 |
% |
| 2161 |
% \begin{macro}{\scrlfile@InputIfFileExists} |
| 2162 |
% \begin{macrocode} |
| 2163 |
\expandafter\def\expandafter\sclrfile@InputIfFileExists\expandafter{% |
| 2164 |
\expandafter\protect\csname InputIfFileExists\space\endcsname |
| 2165 |
} |
| 2166 |
\expandafter\long\expandafter\def\csname scrlfile@InputIfFileExists\space\endcsname#1#2{% |
| 2167 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 2168 |
\expandafter\ifx\csname #1-@alias\endcsname\relax |
| 2169 |
\expandafter\@secondoftwo |
| 2170 |
\else |
| 2171 |
\scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% |
| 2172 |
\expandafter\@firstoftwo |
| 2173 |
\fi |
| 2174 |
{% |
| 2175 |
\expandafter\InputIfFileExists\expandafter{\csname |
| 2176 |
#1-@alias\endcsname}{#2}% |
| 2177 |
}% |
| 2178 |
{\IfFileExists{#1}{% |
| 2179 |
\expandafter\scr@input@withhook\expandafter{\@filef@und}{#1}{#2}}% |
| 2180 |
}% |
| 2181 |
} |
| 2182 |
% \end{macrocode} |
| 2183 |
% \end{macro} |
| 2184 |
% |
| 2185 |
% |
| 2186 |
% \begin{macro}{\filehook@scrlfile@InputIfFileExists} |
| 2187 |
% \begin{macrocode} |
| 2188 |
\DeclareRobustCommand\filehook@scrlfile@InputIfFileExists[2]{% |
| 2189 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 2190 |
\expandafter\ifx\csname #1-@alias\endcsname\relax |
| 2191 |
\expandafter\@secondoftwo |
| 2192 |
\else |
| 2193 |
\scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% |
| 2194 |
\expandafter\@firstoftwo |
| 2195 |
\fi |
| 2196 |
{% |
| 2197 |
\expandafter\InputIfFileExists\expandafter{\csname |
| 2198 |
#1-@alias\endcsname}{#2}% |
| 2199 |
}% |
| 2200 |
{\IfFileExists{#1}{% |
| 2201 |
\expandafter\filehook@swap |
| 2202 |
\expandafter{\@filef@und}% |
| 2203 |
{\scr@load@hook{before}{#1}% |
| 2204 |
#2\@addtofilelist{#1}% |
| 2205 |
\filehook@every@atbegin{#1}% |
| 2206 |
\filehook@atbegin{#1}% |
| 2207 |
\@@input}% |
| 2208 |
\filehook@atend{#1}% |
| 2209 |
\filehook@every@atend{#1}% |
| 2210 |
\scr@load@hook{after}{#1}% |
| 2211 |
}}% |
| 2212 |
} |
| 2213 |
\filehook@glet{filehook@scrlfile@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% |
| 2214 |
% \end{macrocode} |
| 2215 |
% \end{macro} |
| 2216 |
% |
| 2217 |
% |
| 2218 |
% \begin{macro}{\filehook@@scrlfile@InputIfFileExists} |
| 2219 |
% \begin{macrocode} |
| 2220 |
\DeclareRobustCommand\filehook@@scrlfile@InputIfFileExists[2]{% |
| 2221 |
\filehook@let{InputIfFileExists}{filehook@InputIfFileExists}% |
| 2222 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 2223 |
\expandafter\ifx\csname #1-@alias\endcsname\relax |
| 2224 |
\expandafter\@secondoftwo |
| 2225 |
\else |
| 2226 |
\scr@replacefile@msg{\csname #1-@alias\endcsname}{#1}% |
| 2227 |
\expandafter\@firstoftwo |
| 2228 |
\fi |
| 2229 |
{% |
| 2230 |
\expandafter\InputIfFileExists\expandafter{\csname |
| 2231 |
#1-@alias\endcsname}{#2}% |
| 2232 |
}% |
| 2233 |
{\IfFileExists{#1}{% |
| 2234 |
\expandafter\filehook@swap |
| 2235 |
\expandafter{\@filef@und}% |
| 2236 |
{\scr@load@hook{before}{#1}% |
| 2237 |
#2\@addtofilelist{#1}% |
| 2238 |
\filehook@atbegin{#1}% |
| 2239 |
\@@input}% |
| 2240 |
\filehook@atend{#1}% |
| 2241 |
\scr@load@hook{after}{#1}% |
| 2242 |
}}% |
| 2243 |
} |
| 2244 |
\filehook@glet{filehook@@scrlfile@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% |
| 2245 |
% \end{macrocode} |
| 2246 |
% \end{macro} |
| 2247 |
% |
| 2248 |
% If the |scrlfile| package definition is detected the |filehook|s are added |
| 2249 |
% to that definition. Unfortunately the \Macro\scr@load@hook{before} hook is placed \emph{before} |
| 2250 |
% not after the |#2\@addtofilelist{#1}| code. Otherwise the |filehook|s could simply be added to these hooks. |
| 2251 |
% Note that this will stop working if |scrlfile| ever changes its definition of the \Macro\InputIfFileExists macro. |
| 2252 |
% \begin{macrocode} |
| 2253 |
\@tempswafalse |
| 2254 |
\filehook@cmp{InputIfFileExists}{filehook@InputIfFileExists}% |
| 2255 |
{\@tempswatrue}% |
| 2256 |
{% |
| 2257 |
\filehook@cmp{InputIfFileExists}{scrlfile@InputIfFileExists}% |
| 2258 |
{\@tempswatrue}% |
| 2259 |
{}% |
| 2260 |
}% |
| 2261 |
|
| 2262 |
\if@tempswa |
| 2263 |
\filehook@glet{filehook@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% |
| 2264 |
\filehook@glet{filehook@@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% |
| 2265 |
\filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% |
| 2266 |
\PackageInfo{filehook}{Package 'scrlfile' detected and compensated for}% |
| 2267 |
\else |
| 2268 |
\iffilehook@force |
| 2269 |
\filehook@glet{filehook@InputIfFileExists}{filehook@scrlfile@InputIfFileExists}% |
| 2270 |
\filehook@glet{filehook@@InputIfFileExists}{filehook@@scrlfile@InputIfFileExists}% |
| 2271 |
\filehook@glet{InputIfFileExists}{filehook@InputIfFileExists}% |
| 2272 |
\PackageWarning{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J% |
| 2273 |
The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% |
| 2274 |
\else |
| 2275 |
\PackageError{filehook}{Detected 'scrlfile' package with unknown definition of \string\InputIfFileExists.^^J% |
| 2276 |
Use the 'force' option of 'filehook' to overwrite it.}{}% |
| 2277 |
\fi |
| 2278 |
\fi |
| 2279 |
% \end{macrocode} |
| 2280 |
% |
| 2281 |
% \begin{macrocode} |
| 2282 |
\endgroup |
| 2283 |
% \end{macrocode} |
| 2284 |
% |
| 2285 |
% |
| 2286 |
% \iffalse |
| 2287 |
%</filehook-scrlfile.sty> |
| 2288 |
% \fi |
| 2289 |
% |
| 2290 |
% \iffalse |
| 2291 |
%<*filehook-fink.sty> |
| 2292 |
% \fi |
| 2293 |
% \begin{macrocode} |
| 2294 |
%<!COPYRIGHT> |
| 2295 |
\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 2296 |
\ProvidesPackage{filehook-fink}[011/01/03 v0.1 filehook compatibility code for fink package] |
| 2297 |
% \end{macrocode} |
| 2298 |
% |
| 2299 |
% \begin{macrocode} |
| 2300 |
\RequirePackage{filehook} |
| 2301 |
\RequirePackage{currfile}% |
| 2302 |
|
| 2303 |
\begingroup |
| 2304 |
|
| 2305 |
\long\def\fink@old@InputIfFileExists#1#2{% |
| 2306 |
\IfFileExists{#1}{% |
| 2307 |
#2\@addtofilelist{#1}% |
| 2308 |
\fink@prepare{#1}% |
| 2309 |
\expandafter\fink@input% |
| 2310 |
\expandafter\fink@restore\expandafter{\finkpath}}% |
| 2311 |
} |
| 2312 |
|
| 2313 |
\long\def\fink@new@InputIfFileExists#1#2{% |
| 2314 |
\IfFileExists{#1}{% |
| 2315 |
#2\@addtofilelist{#1}% |
| 2316 |
\edef\fink@before{\noexpand\fink@input{#1}}% |
| 2317 |
\edef\fink@after{\noexpand\fink@restore{\finkpath}}% |
| 2318 |
\expandafter\fink@before\fink@after}% |
| 2319 |
} |
| 2320 |
|
| 2321 |
\ifcase |
| 2322 |
\ifx\InputIfFileExists\filehook@InputIfFileExists 0\else |
| 2323 |
\ifx\InputIfFileExists\latex@InputIfFileExists 1\else |
| 2324 |
\ifx\InputIfFileExists\fink@new@InputIfFileExists 1\else |
| 2325 |
\ifx\InputIfFileExists\fink@old@InputIfFileExists 1\else |
| 2326 |
1% |
| 2327 |
\fi\fi\fi\fi |
| 2328 |
\relax |
| 2329 |
\or |
| 2330 |
\global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists |
| 2331 |
\global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists |
| 2332 |
\global\let\InputIfFileExists\filehook@InputIfFileExists |
| 2333 |
\PackageInfo{filehook-fink}{Package 'fink' detected and replaced by 'currfile'}% |
| 2334 |
\else |
| 2335 |
\iffilehook@force |
| 2336 |
\global\let\filehook@InputIfFileExists\filehook@default@InputIfFileExists |
| 2337 |
\global\let\filehook@@InputIfFileExists\filehook@@default@InputIfFileExists |
| 2338 |
\global\let\InputIfFileExists\filehook@InputIfFileExists |
| 2339 |
\PackageWarning{filehook-fink}{Detected 'fink' package with unknown definition of \string\InputIfFileExists.^^J% |
| 2340 |
The 'force' option of 'filehook' is in effect. Macro is overwritten with default!}% |
| 2341 |
\else |
| 2342 |
\PackageError{filehook-fink}{Detected 'fink' package with unknown definition of \string\InputIfFileExists.^^J% |
| 2343 |
Use the 'force' option of 'filehook' to overwrite it.}{}% |
| 2344 |
\fi |
| 2345 |
\fi |
| 2346 |
|
| 2347 |
\endgroup |
| 2348 |
% \end{macrocode} |
| 2349 |
% |
| 2350 |
% \iffalse |
| 2351 |
%</filehook-fink.sty> |
| 2352 |
% \fi |
| 2353 |
% |
| 2354 |
% \iffalse |
| 2355 |
%<*pgf-filehook.sty> |
| 2356 |
% \fi |
| 2357 |
% |
| 2358 |
% \subsection{Support for PGF Keys} |
| 2359 |
% |
| 2360 |
% \begin{macrocode} |
| 2361 |
\ProvidesPackage{pgf-filehook}[2010/01/07 v1.0 PGF keys for the filehook package] |
| 2362 |
\RequirePackage{filehook} |
| 2363 |
\RequirePackage{pgfkeys} |
| 2364 |
|
| 2365 |
\pgfkeys{% |
| 2366 |
/filehook/.is family, |
| 2367 |
/filehook, |
| 2368 |
% |
| 2369 |
EveryFile/.is family, |
| 2370 |
EveryFile/AtBegin/.code={\AtBeginOfEveryFile{#1}}, |
| 2371 |
EveryFile/AtBegin/.value required, |
| 2372 |
EveryFile/AtEnd/.code={\AtEndOfEveryFile{#1}}, |
| 2373 |
EveryFile/AtEnd/.value required, |
| 2374 |
% |
| 2375 |
Files/.is family, |
| 2376 |
Files/AtBegin/.code={\AtBeginOfFiles{#1}}, |
| 2377 |
Files/AtBegin/.value required, |
| 2378 |
Files/AtEnd/.code={\AtEndOfFiles{#1}}, |
| 2379 |
Files/AtEnd/.value required, |
| 2380 |
% |
| 2381 |
File/.is family, |
| 2382 |
File/AtBegin/.code 2 args={\AtBeginOfFile{#1}{#2}}, |
| 2383 |
File/AtBegin/.value required, |
| 2384 |
File/AtEnd/.code 2 args={\AtEndOfFile{#1}{#2}}, |
| 2385 |
File/AtEnd/.value required, |
| 2386 |
% |
| 2387 |
Inputs/.is family, |
| 2388 |
Inputs/AtBegin/.code={\AtBeginOfInputs{#1}}, |
| 2389 |
Inputs/AtBegin/.value required, |
| 2390 |
Inputs/AtEnd/.code={\AtEndOfInputs{#1}}, |
| 2391 |
Inputs/AtEnd/.value required, |
| 2392 |
% |
| 2393 |
InputFile/.is family, |
| 2394 |
InputFile/AtBegin/.code 2 args={\AtBeginOfInputFile{#1}{#2}}, |
| 2395 |
InputFile/AtBegin/.value required, |
| 2396 |
InputFile/AtEnd/.code 2 args={\AtEndOfInputFile{#1}{#2}}, |
| 2397 |
InputFile/AtEnd/.value required, |
| 2398 |
% |
| 2399 |
Includes/.is family, |
| 2400 |
Includes/AtBegin/.code={\AtBeginOfIncludes{#1}}, |
| 2401 |
Includes/AtBegin/.value required, |
| 2402 |
Includes/AtEnd/.code={\AtEndOfIncludes{#1}}, |
| 2403 |
Includes/AtEnd/.value required, |
| 2404 |
Includes/After/.code={\AfterIncludes{#1}}, |
| 2405 |
Includes/After/.value required, |
| 2406 |
% |
| 2407 |
IncludeFile/.is family, |
| 2408 |
IncludeFile/AtBegin/.code 2 args={\AtBeginOfIncludeFile{#1}{#2}}, |
| 2409 |
IncludeFile/AtBegin/.value required, |
| 2410 |
IncludeFile/AtEnd/.code 2 args={\AtEndOfIncludeFile{#1}{#2}}, |
| 2411 |
IncludeFile/AtEnd/.value required, |
| 2412 |
IncludeFile/After/.code 2 args={\AfterIncludeFile{#1}{#2}}, |
| 2413 |
IncludeFile/After/.value required, |
| 2414 |
% |
| 2415 |
ClassFile/.is family, |
| 2416 |
ClassFile/AtBegin/.code={\AtBeginOfClassFile#1}, |
| 2417 |
ClassFile/AtBegin/.value required, |
| 2418 |
ClassFile/AtEnd/.code={\AtEndOfClassFile#1}, |
| 2419 |
ClassFile/AtEnd/.value required, |
| 2420 |
% |
| 2421 |
PackageFile/.is family, |
| 2422 |
PackageFile/AtBegin/.code={\AtBeginOfPackageFile#1}, |
| 2423 |
PackageFile/AtBegin/.value required, |
| 2424 |
PackageFile/AtEnd/.code={\AtEndOfPackageFile#1}, |
| 2425 |
PackageFile/AtEnd/.value required, |
| 2426 |
} |
| 2427 |
|
| 2428 |
\newcommand{\pgffilehook}{\pgfqkeys{/filehook}} |
| 2429 |
|
| 2430 |
% \end{macrocode} |
| 2431 |
% |
| 2432 |
% \iffalse |
| 2433 |
%</pgf-filehook.sty> |
| 2434 |
% \fi |
| 2435 |
% |
| 2436 |
% \Finale |
| 2437 |
\endinput |