| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: latex2e-first-aid-for-external-files.dtx (C) Copyright 2020-2025 |
| 4 |
%% |
| 5 |
%% The LaTeX Project and any individual authors listed elsewhere |
| 6 |
%% in this file. |
| 7 |
% |
| 8 |
% It may be distributed and/or modified under the |
| 9 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 10 |
% of this license or (at your option) any later version. |
| 11 |
% The latest version of this license is in |
| 12 |
% https://www.latex-project.org/lppl.txt |
| 13 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 14 |
% version 2008 or later. |
| 15 |
% |
| 16 |
% This file has the LPPL maintenance status "maintained". |
| 17 |
% |
| 18 |
% |
| 19 |
% |
| 20 |
%<*driver> |
| 21 |
\documentclass{ltxdoc} |
| 22 |
\EnableCrossrefs |
| 23 |
\CodelineIndex |
| 24 |
\begin{document} |
| 25 |
\DocInput{latex2e-first-aid-for-external-files.dtx} |
| 26 |
\end{document} |
| 27 |
%</driver> |
| 28 |
% |
| 29 |
% \fi |
| 30 |
% |
| 31 |
% |
| 32 |
% \providecommand\pkg[1]{\texttt{#1}} |
| 33 |
% |
| 34 |
% \title{First aid for external files and packages that need updating} |
| 35 |
% \author{Frank Mittelbach, \LaTeX{} Project} |
| 36 |
% \date{\LaTeXFirstAidDate} |
| 37 |
% |
| 38 |
% \maketitle |
| 39 |
% |
| 40 |
% |
| 41 |
% \begin{abstract} |
| 42 |
% This file contains some first aid for packages or classes that |
| 43 |
% require updates because of internal changes to \LaTeX{} but that |
| 44 |
% aren't yet reflected in the package/class code. |
| 45 |
% \end{abstract} |
| 46 |
% |
| 47 |
% \tableofcontents |
| 48 |
% |
| 49 |
% \section{Introduction} |
| 50 |
% |
| 51 |
% Over the years package writers have hooked into |
| 52 |
% various parts of internal \LaTeX{} commands (largely because |
| 53 |
% proper interfaces were missing in important places) and if |
| 54 |
% we are now gradually adding such interfaces these internal |
| 55 |
% commands do change and as a result patching into them stops |
| 56 |
% working. |
| 57 |
% |
| 58 |
% As part of making such internal changes the \LaTeX{} Project team |
| 59 |
% attempts to check for such usage in packages, alert the package |
| 60 |
% maintainers and ensures that the packages get updated alongside |
| 61 |
% the core \LaTeX{} system. However it is not always possible to |
| 62 |
% get packages that will fail with a new kernel updated in time and |
| 63 |
% if that is the case we try to provide a temporary fix in this |
| 64 |
% file for them. |
| 65 |
% Once the package gets updated the fix will then be removed again. |
| 66 |
% |
| 67 |
% For that reason, it is put into a separate bundle so that we can |
| 68 |
% update it easily without requiring the CTAN maintainers to |
| 69 |
% install a new full \LaTeX{} system just because we take out (or add) |
| 70 |
% a fix for a package here. |
| 71 |
% |
| 72 |
% In the best case scenario the file documented here should be |
| 73 |
% empty. In practice it will probably always contain one or the |
| 74 |
% other fix while we are waiting for the package to get updated. |
| 75 |
% |
| 76 |
% \begin{quote} \textbf{Important notice:} The fixes provided here |
| 77 |
% are not meant to be a permanent solution, but are only provided |
| 78 |
% to support the transition period. They are (usually) neither |
| 79 |
% complete nor necessarily the best solution! Furthermore, as they |
| 80 |
% are done from the ``outside'', they usually add some burden and |
| 81 |
% slow down \LaTeX{} processing, even if the package/class is not |
| 82 |
% used in the document. |
| 83 |
% |
| 84 |
% We will therefore remove such code as soon as possible |
| 85 |
% again. In practice this means that if some package never gets |
| 86 |
% updated/corrected, then it will eventually fail to work, because |
| 87 |
% after one or at most two \LaTeX{} releases we will take out the |
| 88 |
% transition code to ensure that this ``first aid patching'' |
| 89 |
% doesn't get out of bounds. |
| 90 |
% \end{quote} |
| 91 |
% |
| 92 |
% \subsection{Minor kernel fixes} |
| 93 |
% |
| 94 |
% If we encounter issues with the kernel code that should get fixed |
| 95 |
% before the next main release we normally generate a patch release |
| 96 |
% for \LaTeX{}. However, depending on the complexity of the fix we |
| 97 |
% might first add the fix here and generate a full patch release |
| 98 |
% only when a number of such issues have accumulated. This way we |
| 99 |
% lessen the impact on CTAN maintainers because for each tach |
| 100 |
% release we have to make and distribute also a matching |
| 101 |
% development release. |
| 102 |
% |
| 103 |
% \MaybeStop{\setlength\IndexMin{200pt} \PrintIndex } |
| 104 |
% |
| 105 |
% |
| 106 |
% \section{The Implementation} |
| 107 |
% |
| 108 |
% This file is meant to be loaded during format generation which is |
| 109 |
% why we give it the extension \texttt{.ltx}. |
| 110 |
% \begin{macrocode} |
| 111 |
%<*kernel> |
| 112 |
% \end{macrocode} |
| 113 |
% |
| 114 |
% \begin{macrocode} |
| 115 |
\def\LaTeXFirstAidDate{2025/11/03} |
| 116 |
\def\LaTeXFirstAidVersion{v1.1r} |
| 117 |
% \end{macrocode} |
| 118 |
% |
| 119 |
% \begin{macrocode} |
| 120 |
\ProvidesFile{latex2e-first-aid-for-external-files.ltx} |
| 121 |
[\LaTeXFirstAidDate\space \LaTeXFirstAidVersion\space |
| 122 |
LaTeX kernel fixes to external files and packages] |
| 123 |
% \end{macrocode} |
| 124 |
% |
| 125 |
% |
| 126 |
% \begin{macro}{\FirstAidNeededT} |
| 127 |
% This is a very simple help to ensure that we only apply first aid |
| 128 |
% to an unmodified package or class. It only works in the case the |
| 129 |
% file has already been loaded and the csname \cs{ver@\#1.\#2} got |
| 130 |
% defined (holding the current date, version, and short description |
| 131 |
% info). We then compare its content to a frozen string and make |
| 132 |
% the modification \verb=#3= only if both agree. If they differ we |
| 133 |
% assume that the package/class in question got updated by its |
| 134 |
% maintainer. |
| 135 |
% \begin{macrocode} |
| 136 |
\ExplSyntaxOn |
| 137 |
\cs_new:Npn\FirstAidNeededT#1#2#3{ |
| 138 |
\exp_args:Ncx\str_if_eq:onTF{ver@#1.#2}{#3} |
| 139 |
{ \typeout{==>~ First~ Aid~ for~ #1.#2~ applied! } } |
| 140 |
{ \typeout{==>~ First~ Aid~ for~ #1.#2~ no~ longer~ applied!^^J |
| 141 |
\@spaces Expected:^^J |
| 142 |
\@spaces\@spaces #3^^J |
| 143 |
\@spaces but~ found:^^J |
| 144 |
\@spaces\@spaces \use:c{ver@#1.#2}^^J |
| 145 |
\@spaces so~ I'm~ assuming~ it~ got~ fixed. |
| 146 |
} } |
| 147 |
\exp_args:Ncx\str_if_eq:onT{ver@#1.#2}{#3} |
| 148 |
} |
| 149 |
\ExplSyntaxOff |
| 150 |
% \end{macrocode} |
| 151 |
% \end{macro} |
| 152 |
% |
| 153 |
% \begin{macrocode} |
| 154 |
%</kernel> |
| 155 |
% \end{macrocode} |
| 156 |
% |
| 157 |
% |
| 158 |
% \subsection{The \pkg{filehook} package first aid} |
| 159 |
% |
| 160 |
% The \pkg{filehook} package implements hooks into file loading |
| 161 |
% commands. These days this is already provided by the kernel |
| 162 |
% albeit not with the same user interface. Until that package gets |
| 163 |
% updated (to use the kernel interfaces) we provide a |
| 164 |
% substitution. This does not offer all hooks from \pkg{filehook} |
| 165 |
% but all that have been used in packages available in \TeX{} Live. |
| 166 |
% |
| 167 |
% Note that this doesn't fix \pkg{currfile} because that package |
| 168 |
% uses \pkg{filehook} but relies on the internals of the old |
| 169 |
% implementation. |
| 170 |
% |
| 171 |
% The package has now got an update so we aren't activating the |
| 172 |
% first aid. However, at the moment it basically bypasses the new |
| 173 |
% hook mechanism and puts the old hooks in thereby disabling, for |
| 174 |
% example, the possibility to re-order code through rules. |
| 175 |
% |
| 176 |
% We therefore keep \texttt{filehook-ltx.sty} around as a guideline |
| 177 |
% for further updates. |
| 178 |
% |
| 179 |
% Replacing \pkg{filehook} with a leaner version would then work |
| 180 |
% like this: |
| 181 |
% \begin{macrocode} |
| 182 |
%<*kernel> |
| 183 |
%\declare@file@substitution{filehook.sty}{filehook-ltx.sty} |
| 184 |
%</kernel> |
| 185 |
% \end{macrocode} |
| 186 |
% |
| 187 |
% What follows is a simplified (partial) implementation of the \pkg{filehook} |
| 188 |
% interfaces. |
| 189 |
% Not implemented are: |
| 190 |
%\begin{verbatim} |
| 191 |
% \AtBeginOfFiles \AtEndOfFiles |
| 192 |
% \AtBeginOfInputs \AtEndOfInputs |
| 193 |
% \AtBeginOfInputFile \AtEndOfInputFile |
| 194 |
%\end{verbatim} |
| 195 |
% |
| 196 |
% \begin{macrocode} |
| 197 |
%<*filehook-ltx> |
| 198 |
% \end{macrocode} |
| 199 |
% |
| 200 |
% \begin{macrocode} |
| 201 |
\newcommand\AtBeginOfEveryFile [1] |
| 202 |
{\AddToHook{file/before}{#1}} |
| 203 |
\newcommand\AtEndOfEveryFile [1] |
| 204 |
{\AddToHook{file/after}{#1}} |
| 205 |
% \end{macrocode} |
| 206 |
% |
| 207 |
% \begin{macrocode} |
| 208 |
\newcommand\AtBeginOfIncludes [1] |
| 209 |
{\AddToHook{include/before}{#1}} |
| 210 |
\newcommand\AtEndOfIncludes [1] |
| 211 |
{\AddToHook{include/end}{#1}} |
| 212 |
\newcommand\AfterIncludes [1] |
| 213 |
{\AddToHook{include/after}{#1}} |
| 214 |
% \end{macrocode} |
| 215 |
% |
| 216 |
% \begin{macrocode} |
| 217 |
\newcommand\AtBeginOfPackages [1] |
| 218 |
{\AddToHook{package/before}{#1}} |
| 219 |
\newcommand\AtEndOfPackages [1] |
| 220 |
{\AddToHook{package/after}{#1}} |
| 221 |
% \end{macrocode} |
| 222 |
% |
| 223 |
% \begin{macrocode} |
| 224 |
\newcommand\AtBeginOfClasses [1] |
| 225 |
{\AddToHook{class/before}{#1}} |
| 226 |
\newcommand\AtEndOfClasses [1] |
| 227 |
{\AddToHook{class/after}{#1}} |
| 228 |
% \end{macrocode} |
| 229 |
% |
| 230 |
% \begin{macrocode} |
| 231 |
\newcommand\AtBeginOfFile [2] |
| 232 |
{\AddToHook{file/#1/before}{#2}} |
| 233 |
\newcommand\AtEndOfFile [2] |
| 234 |
{\AddToHook{file/#1/after}{#2}} |
| 235 |
% \end{macrocode} |
| 236 |
% |
| 237 |
% Some commands offered a starred form |
| 238 |
% \begin{macrocode} |
| 239 |
\DeclareDocumentCommand \AtBeginOfPackageFile {smm} |
| 240 |
{\IfBooleanTF{#1}% |
| 241 |
{\@ifpackageloaded{#2}% |
| 242 |
{#3}% |
| 243 |
{\AddToHook{package/#2/before}{#3}}}% |
| 244 |
{\AddToHook{package/#2/before}{#3}}% |
| 245 |
} |
| 246 |
% \end{macrocode} |
| 247 |
% |
| 248 |
% \begin{macrocode} |
| 249 |
\DeclareDocumentCommand \AtEndOfPackageFile {smm} |
| 250 |
{\IfBooleanTF{#1}% |
| 251 |
{\@ifpackageloaded{#2}% |
| 252 |
{#3}% |
| 253 |
{\AddToHook{package/#2/after}{#3}}}% |
| 254 |
{\AddToHook{package/#2/after}{#3}}% |
| 255 |
} |
| 256 |
% \end{macrocode} |
| 257 |
% |
| 258 |
% Are the * forms here of any use? I know they are use 3--4 times |
| 259 |
% on CTAN but I wonder if those are real or mistaken usages. |
| 260 |
% \begin{macrocode} |
| 261 |
\DeclareDocumentCommand \AtBeginOfClassFile {smm} |
| 262 |
{\IfBooleanTF{#1}% |
| 263 |
{\@ifclassloaded{#2}% |
| 264 |
{#3}% |
| 265 |
{\AddToHook{class/#2/before}{#3}}}% |
| 266 |
{\AddToHook{class/#2/before}{#3}}% |
| 267 |
} |
| 268 |
\DeclareDocumentCommand \AtEndOfClassFile {smm} |
| 269 |
{\IfBooleanTF{#1}% |
| 270 |
{\@ifclassloaded{#2}% |
| 271 |
{#3}% |
| 272 |
{\AddToHook{class/#2/after}{#3}}}% |
| 273 |
{\AddToHook{class/#2/after}{#3}}% |
| 274 |
} |
| 275 |
% \end{macrocode} |
| 276 |
% |
| 277 |
% \begin{macrocode} |
| 278 |
\newcommand\AtBeginOfIncludeFile [2] |
| 279 |
{\AddToHook{include/#1/before}{#2}} |
| 280 |
\newcommand\AtEndOfIncludeFile [2] |
| 281 |
{\AddToHook{include/#1/end}{#2}} |
| 282 |
\newcommand\AfterIncludeFile [2] |
| 283 |
{\AddToHook{include/#1/after}{#2}} |
| 284 |
% \end{macrocode} |
| 285 |
% |
| 286 |
% \begin{macrocode} |
| 287 |
%</filehook-ltx> |
| 288 |
% \end{macrocode} |
| 289 |
% |
| 290 |
% \begin{macrocode} |
| 291 |
%<*kernel> |
| 292 |
% \end{macrocode} |
| 293 |
% |
| 294 |
% \subsection{The \pkg{dinbrief} class first aid} |
| 295 |
% |
| 296 |
% Again a case of a no longer correct \cs{endgroup} in document. |
| 297 |
% Here the fix is simply though. |
| 298 |
% \begin{macrocode} |
| 299 |
\AddToHook{file/dinbrief.cls/after}[firstaid]{% |
| 300 |
\FirstAidNeededT{dinbrief}{cls}{2000/03/02 LaTeX2e class}% |
| 301 |
{\AddToHook{env/document/begin}{\begingroup}}% |
| 302 |
} |
| 303 |
% \end{macrocode} |
| 304 |
% |
| 305 |
% |
| 306 |
% \subsection{The \pkg{unicode-math} package first aid} |
| 307 |
% |
| 308 |
% If \pkg{unicode-math} is used together with \pkg{doc} there is a |
| 309 |
% problem because it changes the mathcodes without adjusting the |
| 310 |
% use in \pkg{doc} that assume standard settings. Could be fixed on |
| 311 |
% either side, but as \pkg{unicode-math} is derivating from the |
| 312 |
% standard, the right place is probably a fix in this package. For |
| 313 |
% now we do it here. See github/820. |
| 314 |
% \begin{macrocode} |
| 315 |
\AddToHook{package/unicode-math/after}{% |
| 316 |
\AddToHook{cmd/mod@math@codes/after}{\mathcode`\|=28796 }} |
| 317 |
% \end{macrocode} |
| 318 |
% |
| 319 |
% |
| 320 |
% |
| 321 |
% |
| 322 |
% \subsection{The \pkg{pgfpages} and \pkg{pgfmorepages} first aid} |
| 323 |
% |
| 324 |
% \pkg{pgfpages} alters the \cs{shipout} primitive to support |
| 325 |
% multiple page up scenarios. If used together with \pkg{atbegshi} |
| 326 |
% that worked because the alterations done by \pkg{atbegshi} came |
| 327 |
% later and so used the new definition provide by |
| 328 |
% \pkg{pgfpages}. Now that the code from \pkg{atbegshi} is already |
| 329 |
% in the kernel this further redefinition doesn't happen with the |
| 330 |
% result that the change to \cs{shipout} comes to late and |
| 331 |
% breaks the kernel processes. |
| 332 |
% |
| 333 |
% \begin{macrocode} |
| 334 |
\ExplSyntaxOn |
| 335 |
\AddToHook{file/pgfpages.sty/after}[firstaid]{ |
| 336 |
% \end{macrocode} |
| 337 |
% Undo overwriting \cs{shipout}: |
| 338 |
% \begin{macrocode} |
| 339 |
\cs_gset_eq:NN \shipout \pgfpages@originalshipout |
| 340 |
% \end{macrocode} |
| 341 |
% Instead overwrite the L3 programming layer name of the |
| 342 |
% primitive. This is really an absolute no-go, but for now the |
| 343 |
% simplest solution to keep the original code running. |
| 344 |
% |
| 345 |
% It will be replaced when the ``configuration points'' interface |
| 346 |
% for \LaTeX{} becomes available. At that point the package will be |
| 347 |
% able to set up a different strategy for doing shipouts and |
| 348 |
% without the need to overwrite a primitive (which it did in the |
| 349 |
% past and which we do below) and then this code here can be taken |
| 350 |
% out again. |
| 351 |
% \begin{macrocode} |
| 352 |
\cs_set_eq:NN \pgfpages@originalshipout \tex_shipout:D |
| 353 |
\cs_set_eq:NN \tex_shipout:D \pgfpages@interceptshipout |
| 354 |
} |
| 355 |
\ExplSyntaxOff |
| 356 |
% \end{macrocode} |
| 357 |
% |
| 358 |
% Same issue with \pkg{pgfmorepages} but slightly different implementation (sigh). |
| 359 |
% |
| 360 |
% \begin{macrocode} |
| 361 |
\ExplSyntaxOn |
| 362 |
\AddToHook{file/pgfmorepages.sty/after}[firstaid]{ |
| 363 |
\cs_set_nopar:Npn \pgfhookintoshipout { |
| 364 |
\cs_set_eq:NN \pgfpages@originalshipout \tex_shipout:D |
| 365 |
\cs_set_eq:NN \tex_shipout:D \pgfpages@interceptshipout |
| 366 |
} |
| 367 |
} |
| 368 |
\ExplSyntaxOff |
| 369 |
% \end{macrocode} |
| 370 |
% |
| 371 |
% \subsection{The \pkg{babel} package} |
| 372 |
% |
| 373 |
% Turn off the \pkg{babel} hack. |
| 374 |
% \begin{macrocode} |
| 375 |
\AddToHook{file/babel.sty/before}[firstaid]{\def\BabelCaseHack{}} |
| 376 |
% \end{macrocode} |
| 377 |
% |
| 378 |
% |
| 379 |
% \subsection{The \pkg{songs} package first aid} |
| 380 |
% |
| 381 |
% The songs package uses \cs{obeylines} and redefines \cs{par} for special effect. |
| 382 |
% this no longer works in \LaTeX{} 2022-06-01 (gh issue 367). The following |
| 383 |
% fixes at least one failure. |
| 384 |
% \begin{macrocode} |
| 385 |
\AddToHook{file/songs.sty/after}[firstaid]{% |
| 386 |
\FirstAidNeededT{songs}{sty}{2018/09/12 v3.1 Songs package}% |
| 387 |
{% |
| 388 |
\renewcommand\SB@obeylines{% |
| 389 |
\let\obeyedline\SB@par% |
| 390 |
\obeylines% |
| 391 |
\let\@par\SB@@par% |
| 392 |
}}% |
| 393 |
} |
| 394 |
% \end{macrocode} |
| 395 |
% |
| 396 |
% \subsection{The \pkg{crop} package first aid} |
| 397 |
% |
| 398 |
% The crop packages fails currently due to two \LaTeX{} changes: |
| 399 |
% It doesn't know that \cs{stockheight} and \cs{stockwidth} |
| 400 |
% are now defined, and doesn't take into account that \cs{rlap} |
| 401 |
% is robust (https://github.com/rrthomas/crop/issues/2). |
| 402 |
% The first is addressed by setting the dimension if they are zero or |
| 403 |
% negative. For the second we locally change the meaning of \cs{protect} |
| 404 |
% |
| 405 |
% \begin{macrocode} |
| 406 |
\AddToHook{file/crop.sty/after}[firstaid]{% |
| 407 |
\FirstAidNeededT{crop}{sty}{2017/11/19 1.10 crop marks (mf)}% |
| 408 |
{% |
| 409 |
\ifdim\stockwidth > 0pt \else \stockwidth\paperwidth \fi |
| 410 |
\ifdim\stockheight > 0pt \else \stockheight\paperheight \fi |
| 411 |
\renewcommand*\CROP@genreflect[1]{% |
| 412 |
\leavevmode |
| 413 |
\dimen0\CROP@horigin |
| 414 |
\kern2\dimen0 |
| 415 |
\begingroup |
| 416 |
\set@typeset@protect %change protect |
| 417 |
\reflectbox{% |
| 418 |
\hb@xt@\paperwidth{% |
| 419 |
\vbox to\paperheight{% |
| 420 |
#1% |
| 421 |
\vss |
| 422 |
}% |
| 423 |
\hss |
| 424 |
}% |
| 425 |
}% |
| 426 |
\endgroup |
| 427 |
} |
| 428 |
}% |
| 429 |
} |
| 430 |
% \end{macrocode} |
| 431 |
% |
| 432 |
% |
| 433 |
% |
| 434 |
% \subsection{The \pkg{bigfoot} first aid} |
| 435 |
% |
| 436 |
% The \pkg{bigfoot} packages makes the assumption that two |
| 437 |
% \cs{newinsert} allocations have a recognisable order in their |
| 438 |
% numbers, the second one has a lower number. This was correct in |
| 439 |
% the classic \TeX{} implementation but with the extended |
| 440 |
% allocation possibilities of all modern engines is no longer the |
| 441 |
% case and there is a point where the allocations take a ``jump'' |
| 442 |
% breaking the ordering assumption. These days we are fairly close |
| 443 |
% to that point and depending on how many packages are loaded |
| 444 |
% before \pkg{bigfoot} the package breaks. |
| 445 |
% |
| 446 |
% This firstaid therefore jumps over the problematical point by |
| 447 |
% pushing the count allocation to a safe value if necessary. |
| 448 |
% \begin{macrocode} |
| 449 |
\AddToHook{file/bigfoot.sty/after}{% |
| 450 |
\ifnum\count10<\insc@unt |
| 451 |
\global\count10=\insc@unt |
| 452 |
\fi |
| 453 |
% \end{macrocode} |
| 454 |
% We also correct a bug that \pkg{bigfoot} tries to shift mark |
| 455 |
% registers, but in \LaTeX{} (at least since 2015) the allocation |
| 456 |
% number is not 266, so it does that to a random number of mark |
| 457 |
% registers (which sometimes blows up depending on the value in 266). |
| 458 |
% \begin{macrocode} |
| 459 |
\def\FN@allmarks#1{\@elt{#1}% |
| 460 |
\ifnum#1<\count256 %<--- problem: 266 isn't the counter for marks |
| 461 |
\expandafter\FN@allmarks\expandafter{\number\numexpr#1+\@ne}% |
| 462 |
\fi}% |
| 463 |
} |
| 464 |
% \end{macrocode} |
| 465 |
% |
| 466 |
% |
| 467 |
% |
| 468 |
% |
| 469 |
% \subsection{\pkg{marginfix} first aid} |
| 470 |
% |
| 471 |
% The \pkg{marginfix} package tries to patch \cs{@combinefloats} but |
| 472 |
% with 2025-06 the kernel doesn't use this any longer but uses |
| 473 |
% \cs{@outputbox@attachfloats} instead. |
| 474 |
% \begin{macrocode} |
| 475 |
\AddToHook{file/marginfix.sty/after}[firstaid]{% |
| 476 |
\FirstAidNeededT{marginfix}{sty}% |
| 477 |
{2020/05/06 v1.2 Fix Margin Paragraphs}% |
| 478 |
{\let \@outputbox@attachfloats \@combinefloats}% |
| 479 |
} |
| 480 |
% \end{macrocode} |
| 481 |
% |
| 482 |
% |
| 483 |
% |
| 484 |
% |
| 485 |
% \subsection{\pkg{ulem} first aid} |
| 486 |
% |
| 487 |
% In 2020 we fixed various kernel commands to accept \pkg{calc} |
| 488 |
% syntax. The \pkg{ulem} package redefines some internals and that |
| 489 |
% now conflicts with the new definitions as they involve an extra |
| 490 |
% group. So we alter the definition of \cs{@hspace} if \pkg{ulem} |
| 491 |
% was loaded. This is not perfect, obviously, so it will go out the |
| 492 |
% moment \pkg{ulem} gets adjusted. |
| 493 |
% |
| 494 |
% \begin{macrocode} |
| 495 |
\AddToHook{file/ulem.sty/after}[firstaid]{% |
| 496 |
\def\@hspace#1{\begingroup\setlength\skip@{#1}% |
| 497 |
\edef\x{\endgroup\hskip\the\skip@\relax}\x}% |
| 498 |
} |
| 499 |
% \end{macrocode} |
| 500 |
% |
| 501 |
% |
| 502 |
% \subsection{\pkg{varwidth} first aid} |
| 503 |
% |
| 504 |
% The \pkg{varwidth} package does a lot of low-level paragraph |
| 505 |
% manipulation assuming traditional \TeX{} paragraphs. However, with |
| 506 |
% the paragraph hooks we end up with one extra glue 0pt item on the |
| 507 |
% vertical list and if that isn't removed then the package doesn't |
| 508 |
% find its penalties. |
| 509 |
% |
| 510 |
% So this needs to be removed as well by adding an additional |
| 511 |
% \cs{unskip}. |
| 512 |
% |
| 513 |
% \begin{macrocode} |
| 514 |
\AddToHook{file/varwidth.sty/after}[firstaid]{% |
| 515 |
\FirstAidNeededT{varwidth}{sty}% |
| 516 |
{2009/03/30 ver 0.92; \space Variable-width minipages}% |
| 517 |
{% |
| 518 |
\def\@vwid@sift{% |
| 519 |
\skip@\lastskip\unskip |
| 520 |
\ifdim\lastskip=\z@\unskip\fi % <---- the first aid here (not just unskip) |
| 521 |
\dimen@\lastkern\unkern |
| 522 |
\count@\lastpenalty\unpenalty |
| 523 |
\setbox\z@\lastbox |
| 524 |
\ifvoid\z@ \advance\sift@deathcycles\@ne \else \sift@deathcycles\z@ \fi |
| 525 |
\ifnum\sift@deathcycles>33 |
| 526 |
\let\@vwid@sift\relax |
| 527 |
\PackageWarning{varwidth}{Failed to reprocess entire contents}% |
| 528 |
\fi |
| 529 |
\ifnum\count@=\@vwid@preeqp \@vwid@eqmodefalse\fi |
| 530 |
\ifnum\count@=\@vwid@posteqp \@vwid@eqmodetrue\fi |
| 531 |
\ifnum\count@=\@vwid@toppen % finished |
| 532 |
\let\@vwid@sift\relax |
| 533 |
\else\ifnum\count@=\@vwid@offsets |
| 534 |
\@vwid@setoffsets |
| 535 |
\else |
| 536 |
\ifnum\count@=\@vwid@postw |
| 537 |
\else |
| 538 |
\@vwid@resetb % reset box \z@ or measure it |
| 539 |
\fi |
| 540 |
\@vwid@append |
| 541 |
\fi\fi |
| 542 |
\@vwid@sift}% |
| 543 |
}% |
| 544 |
} |
| 545 |
% \end{macrocode} |
| 546 |
% |
| 547 |
% \subsection{The \pkg{german} class first aid} |
| 548 |
% |
| 549 |
% Handling of \cs{protected} UTF-8 |
| 550 |
% \begin{macrocode} |
| 551 |
\AddToHook{file/german.sty/after}[firstaid]{% |
| 552 |
\FirstAidNeededT{german}{sty}{1998/07/08 v2.5e Support for writing german texts (br)} |
| 553 |
{% |
| 554 |
\let\grmn@active@dq@\@active@dq |
| 555 |
\def\@active@dq{\protect\grmn@active@dq@}% |
| 556 |
\germanTeX |
| 557 |
}% |
| 558 |
} |
| 559 |
% \end{macrocode} |
| 560 |
% |
| 561 |
% \begin{macrocode} |
| 562 |
\AddToHook{file/ngerman.sty/after}[firstaid]{% |
| 563 |
\FirstAidNeededT{ngerman}{sty}{1998/07/08 v2.5e Support for writing german texts (br)} |
| 564 |
{% |
| 565 |
\let\grmn@active@dq@\@active@dq |
| 566 |
\def\@active@dq{\protect\grmn@active@dq@}% |
| 567 |
\ngermanTeX |
| 568 |
}% |
| 569 |
} |
| 570 |
% \end{macrocode} |
| 571 |
% |
| 572 |
% \begin{macrocode} |
| 573 |
%</kernel> |
| 574 |
% \end{macrocode} |
| 575 |
% \subsection{The \pkg{underscore} first aid} |
| 576 |
% |
| 577 |
% The \pkg{underscore} package makes the underscore active. This means that the |
| 578 |
% underscore can not be used in label and references unless the package option \texttt{strings} is used |
| 579 |
% (which patches a selection of problematic commands like \cs{label} and \cs{ref}) |
| 580 |
% or \pkg{babel} is used which redefines\footnote{unless the recommended option \texttt{safe=none} is used} |
| 581 |
% a selection of problematic commands like \cs{@testdef} or \cs{@newl@bel}. |
| 582 |
% |
| 583 |
% With the new property commands the work-around do not work. We therefore make the |
| 584 |
% underscore protected and use \cs{ifincsname} to allow its use in csnames. |
| 585 |
% |
| 586 |
% \begin{macrocode} |
| 587 |
%<*underscore-ltx> |
| 588 |
\ProvidesPackage{underscore-ltx}[2023/09/20 LaTeX firstaid to make underscore protected ] |
| 589 |
\begingroup |
| 590 |
\catcode`\_=\active |
| 591 |
\protected\gdef _{% |
| 592 |
\ifincsname % |
| 593 |
\string_% |
| 594 |
\else |
| 595 |
\ifx\protect\@typeset@protect |
| 596 |
\ifmmode \sb \else \BreakableUnderscore \fi |
| 597 |
\else |
| 598 |
\ifx\protect\@unexpandable@protect \noexpand_% |
| 599 |
\else \protect_% |
| 600 |
\fi\fi |
| 601 |
\fi |
| 602 |
} |
| 603 |
\global\let\ActiveUnderscore=_ |
| 604 |
\endgroup |
| 605 |
%</underscore-ltx> |
| 606 |
% \end{macrocode} |
| 607 |
% \begin{macrocode} |
| 608 |
%<*kernel> |
| 609 |
\AddToHook{file/underscore.sty/after}[firstaid]{% |
| 610 |
\FirstAidNeededT{underscore}{sty}{2006/09/13}{\RequirePackage{underscore-ltx}}} |
| 611 |
%</kernel> |
| 612 |
% \end{macrocode} |
| 613 |
% |
| 614 |
% \begin{macrocode} |
| 615 |
%<*kernel> |
| 616 |
% \end{macrocode} |
| 617 |
% |
| 618 |
% \subsection{The \pkg{acro} package first aid} |
| 619 |
% |
| 620 |
% The package does not declare a \texttt{prop}, which causes an issue with newer |
| 621 |
% routines in \pkg{expl3}. |
| 622 |
% \begin{macrocode} |
| 623 |
\AddToHook{package/acro/after}[firstaid]{% |
| 624 |
\FirstAidNeededT{acro}{sty}{2022/04/01 v3.8 typeset acronyms |
| 625 |
and other abbreviations (CN)} |
| 626 |
{\UseName{prop_new:c}{l__acro_tmpa_prop}% |
| 627 |
% \end{macrocode} |
| 628 |
% With the 2024 June release of \LaTeX{} it will also fail to patch |
| 629 |
% \cs{endlongtable} and therefore errors when loading. However, the |
| 630 |
% patch it tries never worked (because it was setting a local |
| 631 |
% boolean at a point where it was more or less immediately |
| 632 |
% reset). Thus, rather than fixing the patch approach (which |
| 633 |
% requires to surround the patch with \cs{ExplSyntaxOn} |
| 634 |
% \verb*/\catcode`\ =10 / and \cs{ExplSyntaxOff}) we simply disable |
| 635 |
% the patch for now. |
| 636 |
% \begin{macrocode} |
| 637 |
\acsetup{patch/longtable=false}% |
| 638 |
}% |
| 639 |
} |
| 640 |
% \end{macrocode} |
| 641 |
% |
| 642 |
% \subsection{The \pkg{chemformula} package first aid} |
| 643 |
% |
| 644 |
% Package \pkg{chemformula} uses \pkg{l3keys2e} for option processing. |
| 645 |
% This used to be made available as \pkg{chemformula} also loads |
| 646 |
% \pkg{xfrac}, which loaded \pkg{l3keys2e}. However, \pkg{xfrac} has now |
| 647 |
% been updated to use the newer kernel method if available, so loading |
| 648 |
% \pkg{chemformula} fails. |
| 649 |
% \begin{macrocode} |
| 650 |
\AddToHook{package/chemformula/before}[firstaid]{% |
| 651 |
\RequirePackage{l3keys2e}% |
| 652 |
} |
| 653 |
% \end{macrocode} |
| 654 |
% |
| 655 |
% \subsection{The \pkg{chemnum} package first aid} |
| 656 |
% |
| 657 |
% The package does not declare a \texttt{prop}, which causes an issue with newer |
| 658 |
% routines in \pkg{expl3}. |
| 659 |
% \begin{macrocode} |
| 660 |
\AddToHook{package/chemnum/after}[firstaid]{% |
| 661 |
\FirstAidNeededT{chemnum}{sty}{2021/01/21 v1.3a a comprehensive |
| 662 |
approach for the numbering of chemical compounds (CN)} |
| 663 |
{\UseName{prop_new:c}{l__chemnum_tmpa_prop}}% |
| 664 |
} |
| 665 |
% \end{macrocode} |
| 666 |
% |
| 667 |
% \subsection{The \pkg{cleveref} package first aid} |
| 668 |
% |
| 669 |
% The \pkg{cleveref} package expects only two data containers |
| 670 |
% for its internal \cs{newlabel} command. This fails if |
| 671 |
% \pkg{xr-hyper} is used which expands every \cs{newlabel} to |
| 672 |
% five data container and puts the file name into the last one. |
| 673 |
% \begin{macrocode} |
| 674 |
\AddToHook{package/cleveref/after}[firstaid]{% |
| 675 |
\FirstAidNeededT{cleveref}{sty}{2018/03/27 v0.21.4 Intelligent cross-referencing} |
| 676 |
{% |
| 677 |
% \end{macrocode} |
| 678 |
% This are the two commands which retrieve the data from the label info. |
| 679 |
% We change them to expect five arguments. |
| 680 |
% \begin{macrocode} |
| 681 |
\def\cref@getref#1#2{% |
| 682 |
\expandafter\let\expandafter#2\csname r@#1@cref\endcsname% |
| 683 |
\expandafter\expandafter\expandafter\def% |
| 684 |
\expandafter\expandafter\expandafter#2% |
| 685 |
\expandafter\expandafter\expandafter{% |
| 686 |
\expandafter\@firstoffive#2}}% <-------- five |
| 687 |
\def\cpageref@getref#1#2{% |
| 688 |
\expandafter\let\expandafter#2\csname r@#1@cref\endcsname% |
| 689 |
\expandafter\expandafter\expandafter\def% |
| 690 |
\expandafter\expandafter\expandafter#2% |
| 691 |
\expandafter\expandafter\expandafter{% |
| 692 |
\expandafter\@secondoffive#2}}% <----------- five |
| 693 |
% \end{macrocode} |
| 694 |
% We also need to redefine the internal label commands of cleveref. |
| 695 |
% This must be done after \pkg{cleveref} has made its changes |
| 696 |
% in \texttt{begindocument} so we add it to the same hook using |
| 697 |
% the hook label used by \pkg{cleveref}. |
| 698 |
% This way it is guaranteed to overwrite the definitions. |
| 699 |
% \begin{macrocode} |
| 700 |
\AddToHook{begindocument}[cleveref]{% |
| 701 |
\def\label@noarg#1{% |
| 702 |
\cref@old@label{#1}% |
| 703 |
\@bsphack% |
| 704 |
\protected@edef\@tempa{{page}{\the\c@page}}% <--- should be protected |
| 705 |
\setcounter{page}{1}% |
| 706 |
\protected@edef\@tempb{\thepage}% <--- should be protected |
| 707 |
\expandafter\setcounter\@tempa% |
| 708 |
\cref@constructprefix{page}{\cref@result}% |
| 709 |
\protected@write\@auxout{}% |
| 710 |
{\string\newlabel{#1@cref}{{\cref@currentlabel}% |
| 711 |
{[\@tempb][\arabic{page}][\cref@result]\thepage}{}{}{}}}% <----- five |
| 712 |
\@esphack}% |
| 713 |
\def\label@optarg[#1]#2{% |
| 714 |
\cref@old@label{#2}% |
| 715 |
\@bsphack% |
| 716 |
\protected@edef\@tempa{{page}{\the\c@page}}% <--- should be protected |
| 717 |
\setcounter{page}{1}% |
| 718 |
\protected@edef\@tempb{\thepage}% <--- should be protected |
| 719 |
\expandafter\setcounter\@tempa% |
| 720 |
\cref@constructprefix{page}{\cref@result}% |
| 721 |
\protected@edef\cref@currentlabel{% |
| 722 |
\expandafter\cref@override@label@type% |
| 723 |
\cref@currentlabel\@nil{#1}}% |
| 724 |
\protected@write\@auxout{}% |
| 725 |
{\string\newlabel{#2@cref}{{\cref@currentlabel}% |
| 726 |
{[\@tempb][\arabic{page}][\cref@result]\thepage}{}{}{}}}% <------- five |
| 727 |
\@esphack}% |
| 728 |
} |
| 729 |
% \end{macrocode} |
| 730 |
% \changes{v1.1g}{2024/10/16}{update cleveref data in label hook} |
| 731 |
% \changes{v1.1i}{2024/11/08}{add expandafter, issue \#1544} |
| 732 |
% cleveref patches and redefines \cs{refstepcounter} so that a call updates its data. |
| 733 |
% This fails if like e.g. in \pkg{longtable} the counter is stepped with |
| 734 |
% \cs{@kernel@refstepcounter}. We therefore move the data setup into the label hook. |
| 735 |
% As the hook is in a group we have to smuggle the data out of it. |
| 736 |
% \url{https://tex.stackexchange.com/a/722909/2388} and issue \#1393 |
| 737 |
% \begin{macrocode} |
| 738 |
\newcommand\firstaid@cref@smugglelabel{\let\cref@currentlabel\cref@gcurrentlabel@temp} |
| 739 |
\newcommand\firstaid@cref@updatelabeldata[1]{% |
| 740 |
\cref@constructprefix{#1}{\cref@result}% |
| 741 |
\@ifundefined{cref@#1@alias}% |
| 742 |
{\def\@tempa{#1}}% |
| 743 |
{\def\@tempa{\csname cref@#1@alias\endcsname}}% |
| 744 |
\protected@xdef\cref@gcurrentlabel@temp{% |
| 745 |
[\@tempa][\arabic{#1}][\cref@result]% |
| 746 |
\csname p@#1\expandafter\endcsname\csname the#1\endcsname}% |
| 747 |
\aftergroup\firstaid@cref@smugglelabel |
| 748 |
} |
| 749 |
% \end{macrocode} |
| 750 |
% we test if \cs{@currentcounter} is empty for unnumbered sections |
| 751 |
% \changes{v1.1h}{2024/11/01}{fix spurious space} |
| 752 |
% \changes{v1.1j}{2024/11/24}{add \cs{iftag@} test, issue \#1560} |
| 753 |
% \begin{macrocode} |
| 754 |
\newif\iftag@ |
| 755 |
\AddToHook{label}[firstaid/cleveref] |
| 756 |
{\ifx |
| 757 |
\@currentcounter\@empty |
| 758 |
\else |
| 759 |
\iftag@\else |
| 760 |
\firstaid@cref@updatelabeldata{\@currentcounter}% |
| 761 |
\fi |
| 762 |
\fi} |
| 763 |
% \end{macrocode} |
| 764 |
% Due to a bug correction in amsmath a patch in cleveref fails in LaTeX 2025-06-01, |
| 765 |
% see gh 1684 |
| 766 |
% \changes{v1.1p}{2025/06/05}{adapt to new amsmath \#1560} |
| 767 |
% \begin{macrocode} |
| 768 |
\AddToHook{begindocument}[cleveref] |
| 769 |
{ |
| 770 |
\IfPackageAtLeastT{amsmath}{2025-05-18} |
| 771 |
{ |
| 772 |
\def\ltx@label#1{\cref@label{#1}} |
| 773 |
\def\label@in@display@noarg#1{\cref@old@label@in@display{#1}} |
| 774 |
\def\label@in@mmeasure@noarg#1{% |
| 775 |
\begingroup |
| 776 |
\measuring@false% |
| 777 |
\cref@old@label@in@display{#1}% |
| 778 |
\endgroup}% |
| 779 |
} |
| 780 |
} |
| 781 |
}% |
| 782 |
} |
| 783 |
% \end{macrocode} |
| 784 |
% |
| 785 |
% \subsection{The \pkg{arydshln} package first aid} |
| 786 |
% |
| 787 |
% Making two internal commands robust to avoid expansion while constructing the array preamble. |
| 788 |
% \begin{macrocode} |
| 789 |
\AddToHook{package/arydshln/after}[firstaid]{% |
| 790 |
\FirstAidNeededT{arydshln}{sty}{2019/02/21 v1.76 } |
| 791 |
{% |
| 792 |
% add \protected |
| 793 |
\protected\def\adl@@vlineL#1#2#3#4{\adl@ivline#4\@nil{#1}{#2}% |
| 794 |
\xdef\adl@colsL{\adl@colsL |
| 795 |
\@elt{#3}{\number\@tempcnta}{\number\@tempcntb}% |
| 796 |
{\adl@dashcolor}{\adl@gapcolor}}}% |
| 797 |
\protected\def\adl@@vlineR#1#2#3#4{\adl@ivline#4\@nil{#1}{#2}% |
| 798 |
\xdef\adl@colsR{% |
| 799 |
\@elt{#3}{\number\@tempcnta}{\number\@tempcntb}% |
| 800 |
{\adl@dashcolor}{\adl@gapcolor}% |
| 801 |
\adl@colsR}}% |
| 802 |
\let\adl@act@@vlineL\adl@@vlineL |
| 803 |
\let\adl@act@@vlineR\adl@@vlineR |
| 804 |
}% |
| 805 |
} |
| 806 |
% \end{macrocode} |
| 807 |
% |
| 808 |
% |
| 809 |
% \subsection{The \pkg{calc} package first aid} |
| 810 |
% |
| 811 |
% The \pkg{calc} is not an external package, but for now we are |
| 812 |
% removing a newly introduced incompatibility with \pkg{zref-perpage} |
| 813 |
% here. At some point \pkg{amstext}, \pkg{zref-perpage}, \pkg{calc}, |
| 814 |
% \ldots{} all need to be synced so that they do not overwrite the |
| 815 |
% \cs{stepcounter} definition but safely hook into the kernel |
| 816 |
% code. But that requires suitable hooks there, so has to wait. |
| 817 |
% \begin{macrocode} |
| 818 |
\AddToHook{begindocument}[calc-noop]{} |
| 819 |
\DeclareHookRule{begindocument}{calc-noop}{voids}{calc} |
| 820 |
% \end{macrocode} |
| 821 |
% |
| 822 |
% |
| 823 |
% |
| 824 |
% \subsection{First aid after retiring the legacy mark mechanism} |
| 825 |
% |
| 826 |
% \changes{v1.1o}{2025/05/14}{First aid to help with retiring legacy |
| 827 |
% mark mechanism (gh/1724)} |
| 828 |
% |
| 829 |
% With the June 2025 release of \LaTeX{} the legacy mark mechanism |
| 830 |
% using \cs{@themark} with exactly two mark components has been removed |
| 831 |
% and replaced by a more general mechanism. This affects a few |
| 832 |
% packages and classes that had patched into the legacy code to extend |
| 833 |
% it or to completely replace it. For now we do our best to keep that |
| 834 |
% working, but mid-term all packages have to update to the new |
| 835 |
% mechanism (and avoid low-level patching) in order to remain |
| 836 |
% compatible with future adjustments. |
| 837 |
% |
| 838 |
% For an analysis of the current situation see the github issues 1724 |
| 839 |
% at \url{https://github.com/latex3/latex2e/issues/1724}. |
| 840 |
% |
| 841 |
% We provide a dummy definition for \cs{@themark} because some classes |
| 842 |
% expect it to be around. This prevents low-level errors but only |
| 843 |
% helps if the class in question otherwise fully implement its own |
| 844 |
% mark interface (as for example the AMS classes do). |
| 845 |
% \begin{macrocode} |
| 846 |
\def\@themark{{}{}} |
| 847 |
% \end{macrocode} |
| 848 |
% |
| 849 |
% \begin{macrocode} |
| 850 |
\AddToHook{class/smfart/after}[firstaid]{% |
| 851 |
\FirstAidNeededT{smfart}{cls}{2021/03/28 v1.6 |
| 852 |
Classe LaTeX pour les articles publies par la SMF} |
| 853 |
{% |
| 854 |
\def\leftmark{\expandafter\@leftmark\botmark\@empty\@empty}% |
| 855 |
\def\rightmark{\expandafter\@rightmark\firstmark\@empty\@empty}% |
| 856 |
}} |
| 857 |
% \end{macrocode} |
| 858 |
% |
| 859 |
% \begin{macrocode} |
| 860 |
\AddToHook{class/smfbook/after}[firstaid]{% |
| 861 |
\FirstAidNeededT{smfbook}{cls}{2021/03/28 v1.6 |
| 862 |
Classe LaTeX pour les monographies editees par la SMF} |
| 863 |
{% |
| 864 |
\def\leftmark{\expandafter\@leftmark\botmark\@empty\@empty}% |
| 865 |
\def\rightmark{\expandafter\@rightmark\firstmark\@empty\@empty}% |
| 866 |
}} |
| 867 |
% \end{macrocode} |
| 868 |
% |
| 869 |
% |
| 870 |
% |
| 871 |
% \subsection{First aid for \pkg{morewrites}} |
| 872 |
% |
| 873 |
% \changes{v1.1o}{2025/05/14}{First aid to avoid breaking the |
| 874 |
% morewrites package} |
| 875 |
% |
| 876 |
% A recent change in \LaTeX{} breaks the \pkg{morewrites} |
| 877 |
% package. Below is a possible fix for this. This may not be the final |
| 878 |
% version which is why it is currently placed here (largely to avoid |
| 879 |
% to distribute another full \texttt{dev} release for no good reason). |
| 880 |
% \begin{macrocode} |
| 881 |
\ExplSyntaxOn |
| 882 |
\cs_set:Npn \__shipout_force_immediate_writes: { |
| 883 |
\cs_gset_eq:NN \iow_shipout:Nn \iow_now:Nn |
| 884 |
\cs_gset_eq:NN \lua_shipout:n \lua_now:n |
| 885 |
\cs_gset_eq:NN \__kernel_write_saved: \write |
| 886 |
\cs_gset:Npn \write {\immediate \__kernel_write_saved:} |
| 887 |
\global\advance\c@page\m@ne |
| 888 |
} |
| 889 |
\ExplSyntaxOff |
| 890 |
% \end{macrocode} |
| 891 |
% |
| 892 |
% |
| 893 |
% |
| 894 |
% \subsection{First aid for AMS classes} |
| 895 |
% |
| 896 |
% Some time ago \LaTeX{} fully switched to the new mark |
| 897 |
% mechanism. However, the AMS classes still overwrite some, but not |
| 898 |
% all, of the mark commands, i.e., \cs{leftmark}, \cs{rightmark}, and |
| 899 |
% \cs{markboth}, assuming the old mechanism, and this way leaving it in an |
| 900 |
% inconsistent state. We therefore switch the definitions back. The |
| 901 |
% classes should simply stop making these redefinitions (which for a |
| 902 |
% long time serve no purpose). |
| 903 |
% \changes{v1.1q}{2025/10/21}{Fix AMS classes with respect to marks (gh/1887)} |
| 904 |
% \begin{macrocode} |
| 905 |
\ExplSyntaxOn |
| 906 |
\AddToHook{class/amsart/after}{ |
| 907 |
\DeclareRobustCommand*\markboth[2]{% |
| 908 |
\mark_insert:nn{2e-left}{#1} |
| 909 |
\mark_insert:nn{2e-right}{#2} |
| 910 |
\tl_if_empty:nF{#2}{ \mark_insert:nn{2e-right-nonempty}{#2} } |
| 911 |
} |
| 912 |
\cs_set:Npn \leftmark {\mark_use_last:nn{page}{2e-left}} |
| 913 |
\cs_set:Npn \rightmark {\mark_use_first:nn{page}{2e-right}} |
| 914 |
} |
| 915 |
\AddToHook{class/amsproc/after}{ |
| 916 |
\DeclareRobustCommand*\markboth[2]{% |
| 917 |
\mark_insert:nn{2e-left}{#1} |
| 918 |
\mark_insert:nn{2e-right}{#2} |
| 919 |
\tl_if_empty:nF{#2}{ \mark_insert:nn{2e-right-nonempty}{#2} } |
| 920 |
} |
| 921 |
\cs_set:Npn \leftmark {\mark_use_last:nn{page}{2e-left}} |
| 922 |
\cs_set:Npn \rightmark {\mark_use_first:nn{page}{2e-right}} |
| 923 |
} |
| 924 |
% \end{macrocode} |
| 925 |
% The \texttt{amsbook} class would require different adjustments |
| 926 |
% (\cs{@secmark} would need to use the new mechanism) but with this |
| 927 |
% class the overwriting still more or less works so we leave it |
| 928 |
% alone for now. |
| 929 |
% \begin{macrocode} |
| 930 |
\ExplSyntaxOff |
| 931 |
% \end{macrocode} |
| 932 |
% |
| 933 |
% \subsection{The \pkg{listings} package first aid} |
| 934 |
% |
| 935 |
% Adjust an internal kernel overwrite that \pkg{listings} is doing |
| 936 |
% because that no longer works in 2025/11 kernel. |
| 937 |
% \changes{v1.1r}{2025/11/03}{Fix an internal kernel overwrite in |
| 938 |
% listings to work with 2025/11 kernel (sx/754347)} |
| 939 |
% \begin{macrocode} |
| 940 |
\AddToHook{package/listings/after}[firstaid]{% |
| 941 |
\FirstAidNeededT{listings}{sty}{2024/09/23 1.10c (Carsten Heinz)} |
| 942 |
{% |
| 943 |
\def\@tempa#1#2#3{% |
| 944 |
\gdef\lstnewenvironment@##1##2##3##4##5{% |
| 945 |
\begingroup |
| 946 |
\global\@namedef{end##2}{\lstenv@Error{##2}}% |
| 947 |
\global\@namedef{##2}{\def\lstenv@name{##2}% |
| 948 |
\begingroup \lst@setcatcodes \catcode\active=\active |
| 949 |
\csname##2@\endcsname}% |
| 950 |
\let\l@ngrel@x\global %<---- |
| 951 |
% The above was a bit of a hack in listings, making a command that |
| 952 |
% was supposed to be either \long or \relax suddenly applying \global |
| 953 |
% |
| 954 |
% Since this doesn't any longer work with 2025/11 |
| 955 |
% let's replace it by an equally dubious hack :-() in this situation |
| 956 |
\let\pr@tectedrel@x\global |
| 957 |
% In order to work with both 2025/11 and earlier we keep both settings! |
| 958 |
% |
| 959 |
\let\@xargdef\lstenv@xargdef |
| 960 |
\expandafter\new@command\csname##2@\endcsname##3% |
| 961 |
{\lsthk@PreSet ##4% |
| 962 |
\ifx\@currenvir\lstenv@name |
| 963 |
\def\lstenv@endstring{#1#2##1#3}% |
| 964 |
\else |
| 965 |
\def\lstenv@endstring{#1##1}% |
| 966 |
\fi |
| 967 |
\@namedef{end##2}{\lst@DeInit ##5\endgroup |
| 968 |
\lst@doendpe \@ignoretrue}% |
| 969 |
\lsthk@DisplayStyle |
| 970 |
\let\lst@EndProcessListing\lstenv@SkipToEnd |
| 971 |
\lst@Init\lstenv@backslash |
| 972 |
\lst@ifprint |
| 973 |
\expandafter\expandafter\expandafter\lstenv@Process |
| 974 |
\else |
| 975 |
\expandafter\lstenv@SkipToEnd |
| 976 |
\fi |
| 977 |
\lst@insertargs}% |
| 978 |
\endgroup}% |
| 979 |
} |
| 980 |
\let\lst@arg\@empty \lst@XConvert{end}\{\}\@nil |
| 981 |
\expandafter\@tempa\lst@arg |
| 982 |
}% |
| 983 |
} |
| 984 |
% \end{macrocode} |
| 985 |
% \begin{macrocode} |
| 986 |
%</kernel> |
| 987 |
% \end{macrocode} |
| 988 |
% |
| 989 |
% \Finale |
| 990 |
% |