diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/revtex4/ltxutil.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/revtex4/ltxutil.dtx | 175 |
1 files changed, 147 insertions, 28 deletions
diff --git a/Master/texmf-dist/source/latex/revtex4/ltxutil.dtx b/Master/texmf-dist/source/latex/revtex4/ltxutil.dtx index 5553e3a863e..02947a6a944 100644 --- a/Master/texmf-dist/source/latex/revtex4/ltxutil.dtx +++ b/Master/texmf-dist/source/latex/revtex4/ltxutil.dtx @@ -10,17 +10,16 @@ % For the documentation and more detailed instructions for % installation, typeset this document with \LaTeX. % \fi -% \GetFileInfo{ltxutil.dtx}\CheckSum{3641} +% \GetFileInfo{ltxutil.dtx} % % \iffalse ltxdoc klootch %<*ltxutil> %%% @LaTeX-file{ %%% filename = "ltxutil.dtx", -%%% version = "1.0rc5b", -%%% date = "2001/07/31", -%%% time = "12:23:00 GMT+8", -%%% checksum = "3641", +%%% version = "1.0d", +%%% date = "2020/09/30", %%% author = "Arthur Ogawa (mailto:ogawa@teleport.com), +%%% Phelype Oleinik (mailto:phelype.oleinik at latex-project.org), %%% commissioned by the American Physical Society. %%% ", %%% copyright = "Copyright (C) 1999 Arthur Ogawa, @@ -37,7 +36,6 @@ %%% keywords = "latex, utility, kernel", %%% supported = "yes", %%% abstract = "package to add utilties to LaTeX", -%%% docstring = "The checksum field above generated by ltxdoc", %%% } %</ltxutil> % \fi @@ -121,7 +119,7 @@ % typeset documentation. % \begin{macrocode} %<*doc|ltxutil> - [2001/07/31 1.0rc5b utilities package]% \fileversion + [2020/09/30 1.0d utilities package]% \fileversion %</doc|ltxutil> % \end{macrocode} % @@ -155,9 +153,14 @@ \RequirePackage{ltxdocext}% \let\url\undefined \RequirePackage[colorlinks=true,linkcolor=blue]{hyperref}% -\expandafter\ifx\csname package@font\endcsname\@undefined\else - \expandafter\RequirePackage\expandafter{\csname package@font\endcsname}% -\fi +\pdfstringdefDisableCommands{% + \let\file\relax + \let\sc\relax +} +\makeatletter +\@ifundefined{package@font}{}% + {\expandafter\RequirePackage\expandafter{\csname package@font\endcsname}} +\makeatother \CodelineIndex\EnableCrossrefs % \end{macrocode} % @@ -679,6 +682,22 @@ in your filesystem where they will be found by \LaTeX. % \end{macro} % \end{macro} % +% \begin{macro}{\rvtx@ifformat@geq} +% Some changes in the \LaTeX{} kernel requires us to conditionally +% define some macros depending on the version of the kernel. +% \cmd\rvtx@ifformat@geq{} will check if the release date of the +% currently-running \LaTeXe{} kernel is greater or equal to the +% argument (the argument should be in the format \texttt{yyyy-mm-dd}). +% \changes{4.2d}{2020/09/17}{(PHO) Add \cs{rvtx@ifformat@geq} (from 4.2).}% +% \begin{macrocode} +\ifx\IfFormatAtLeastTF\undefined + \def\rvtx@ifformat@geq{\@ifl@t@r\fmtversion}% +\else + \let\rvtx@ifformat@geq\IfFormatAtLeastTF +\fi +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\@boolean} % \begin{macro}{\@boole@def} % In order to define \cmd\@ifx, we first must create the @@ -820,27 +839,42 @@ in your filesystem where they will be found by \LaTeX. % for deferring the decision about the page grid until \cmd\AtBeginDocument\ time. % We fix things by prepending a hook at the very beginning of \cmd\document. % -% The price we pay for this facility is to depend on the stability of this part -% of \LaTeX's kernel code (the first token of \cmd\document), -% which could change, you see. But considering that \LaTeX\ is -% at this point essentially stagnant once more, we risk it. -% % \begin{macro}{\document} % We begin by installing hooks into \cmd\document\ that % we will manage ourselves. -% First, we do as \cmd\document\ does: end the group -% begun by \cmd\begin. Last, we conclude our shenanigans by absorbing +% +% The 2020-10-01 \LaTeX{} release got a new hook management system and +% several new hooks (several previously provided by \textsf{etoolbox}). +% The one we want here is \texttt{begindocument/before}, the first thing +% executed by \cmd\document{}, right after ending the group started by +% \cmd\begin{}. +% +% Thus, if the \LaTeX{} kernel date is 2020-10-01 we just add to that +% hook, otherwise resort to the old method, patching \cmd\document: +% end the group started by \cmd\begin, apply our hook, and +% conclude our shenanigans by absorbing % the first token of the expansion of \cmd\document, which -% we assume to be \cmd\endgroup. -% \begin{macrocode} -\prepdef\document{% - \endgroup - \init@documenthook - \set@typesize@hook - \normalsize - \set@pica@hook - \true@sw{}% -}% +% we assume to be \cmd\endgroup{} (true until the aforementioned release). +% \changes{4.2d}{2020/09/17}{(PHO) Use \LaTeX's hook management system, if possible (from 4.2).}% +% \begin{macrocode} +\rvtx@ifformat@geq{2020-10-01}% + {% + \AddToHook{begindocument/before}{% + \init@documenthook + \set@typesize@hook + \normalsize + \set@pica@hook + }% + }{% + \prepdef\document{% + \endgroup + \init@documenthook + \set@typesize@hook + \normalsize + \set@pica@hook + \true@sw{}% + }% + } % \end{macrocode} % \end{macro} % @@ -890,7 +924,15 @@ in your filesystem where they will be found by \LaTeX. % We will do this to ensure that the \cmd\@mainaux\ stream is not closed until % the last page of the job is shipped out, and that can only be done by coordinating % with the output routine. +% +% \changes{4.2d}{2020/09/17}{(PHO) Only redefine \cs{enddocument} in older versions.}% +% This approach, however, will only be done for older versions of the +% \LaTeX{} kernel: % \begin{macrocode} +\rvtx@ifformat@geq{2020-10-01}{% + % <definitions for newer LaTeX later> +}{% + % <definitions for older LaTeX> \def\enddocument{% \@enddocumenthook \@checkend{document}% @@ -924,7 +966,7 @@ in your filesystem where they will be found by \LaTeX. \@if@sw\if@tempswa\fi{% \@latex@warning@no@line{% Label(s) may have changed. - Rerun to get cross-references right + Rerun to get cross-references right% }% }{}% }{% @@ -932,11 +974,88 @@ in your filesystem where they will be found by \LaTeX. }% }{}% }% +} % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % +% \changes{4.2d}{2020/09/17}{(PHO) Patch \cs{enddocument} at runtime in newer versions.}% +% \begin{macro}{\rvtx@enddocument@patch} +% For newer \LaTeX{} we'll try to be a bit more future-proof +% (no miracle though). The code for \cmd\enddocument{} +% (in pre-2020-10-01 \LaTeX) is roughly: +% \begin{verbatim} +% \def\enddocument{% +% <hooks and bookkeeping> +% \clearpage +% <read main .aux and final checks> +% \@@end +% } +% \end{verbatim} +% and the patches above replace the \cmd\clearpage{} by its own +% \cmd\clear@document, and \verb|<read main .aux and final checks>| by +% \cmd\do@check@aux, which it can later control the timing. +% +% Now we will apply the same changes, but this time without redefining +% \cmd\enddocument: we will instead replace tokens on-the-fly, when +% \cmd\enddocument{} is expanded. This will grant us a slightly safer +% approach that won't depend so much on the internals of +% \cmd\enddocument. +% +% This entire patch should work with the previous definition of +% \cmd\enddocument{} as well (except it cannot be used in the hook), +% but for now leave previous versions untouched. +% +% The entire patching will reside in the \texttt{enddocument} hook: +% \begin{macrocode} +\rvtx@ifformat@geq{2020-10-01}{% + \AddToHook{enddocument}{\rvtx@enddocument@patch{}}% +}{} +% \end{macrocode} +% +% This macro will be executed after \cmd\enddocument{} has expanded, +% so all its tokens are now exposed. Here we will assume that +% \cmd\enddocument{} contains the tokens \verb|\@checkend{document}| +% and \cmd\endgroup, and use them as delimiters: +% \begin{macrocode} +\protected\long\def\rvtx@enddocument@patch#1#2\@checkend#3{% + \begingroup + \edef\x{\detokenize{#3}}% + \edef\y{\detokenize{document}}% + \expandafter\endgroup + \ifx\x\y + \expandafter\rvtx@enddocument@patch@end + \else + \expandafter\rvtx@enddocument@patch@more + \fi + {#1#2}{#3}} +\def\rvtx@enddocument@patch@more#1#2{% + \rvtx@enddocument@patch{#1\@checkend{#2}}} +% \end{macrocode} +% +% When the \verb|\@checkend{document}| is reached, use \cmd\clearpage{} +% and \cmd\enddocument{} as delimiters for the +% \verb|<read main .aux and final checks>| part, and save it in +% \cmd\do@check@aux{}: +% \begin{macrocode} +\long\def\rvtx@enddocument@patch@end#1#2\clearpage#3\endgroup{% + \def\do@check@aux{#3\endgroup}% +% \end{macrocode} +% Then execute the code consumed in the previous step: +% \begin{macrocode} + #1% + \@checkend{#2}% +% \end{macrocode} +% Do \cmd\clear@document{} instead of \cmd\clearpage{} and +% \cmd\check@aux{} instead of the code grabbed. +% \begin{macrocode} + \clear@document + \check@aux} +\def\check@aux{\do@check@aux}% +\def\clear@document{\clearpage}% +% \end{macrocode} +% \end{macro} % % \subsection{Type Tools}% % |