diff options
Diffstat (limited to 'macros/latex-dev/base/ltclass.dtx')
-rw-r--r-- | macros/latex-dev/base/ltclass.dtx | 248 |
1 files changed, 232 insertions, 16 deletions
diff --git a/macros/latex-dev/base/ltclass.dtx b/macros/latex-dev/base/ltclass.dtx index f43e8f0c0d..dd35be9ae4 100644 --- a/macros/latex-dev/base/ltclass.dtx +++ b/macros/latex-dev/base/ltclass.dtx @@ -33,7 +33,7 @@ %<*driver> % \fi \ProvidesFile{ltclass.dtx} - [2020/03/02 v1.3j LaTeX Kernel (Class & Package Interface)] + [2020/04/24 v1.3k LaTeX Kernel (Class & Package Interface)] % \iffalse \documentclass{ltxdoc} \GetFileInfo{ltclass.dtx} @@ -620,15 +620,60 @@ % % \begin{macro}{\@ifpackagelater} % \begin{macro}{\@ifclasslater} -% |\@ifpackagelater{|\meta{name}|}{YYYY/MM/DD}| -% Checks that the package loaded is more recent than the given date. +% |\@ifpackagelater{|\meta{name}|}{YYYY/MM/DD}{|\meta{true +% code}|}{|\meta{false code}|}| +% Checks that the package loaded is more recent or equal to the +% given date. +% A better name for it would therefore been +% |\@ifpackagelaterorequal| but it is in use for more than 30 +% years, so \ldots % \begin{macrocode} \def\@ifpackagelater{\@ifl@ter\@pkgextension} \def\@ifclasslater{\@ifl@ter\@clsextension} \@onlypreamble\@ifpackagelater \@onlypreamble\@ifclasslater % \end{macrocode} +% \end{macro} +% \end{macro} +% % +% +% \begin{macro}{\IfPackageAtLeastTF} +% \begin{macro}{\IfClassAtLeastTF} +% \begin{macro}{\IfFormatAtLeastTF} +% |\IfFormatAtLeastTF{YYYY/MM/DD}{|\meta{true +% code}|}{|\meta{false code}|}| +% Test if the format is later or equal to the given date. +% \changes{v1.3k}{2020/04/07}{Macro added; also in rollback (gh/168)} +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\IfFormatAtLeastTF}{Test format date}% +\def\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} +\let\IfPackageAtLeastTF\@ifpackagelater +\let\IfClassAtLeastTF\@ifclasslater +\@onlypreamble\IfFormatAtLeastTF +\@onlypreamble\IfPackageAtLeastTF +\@onlypreamble\IfClassAtLeastTF +% \end{macrocode} +% For rollback pretend it was available since the beginning of dawn. +% \begin{macrocode} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\IfFormatAtLeastTF}{Test format date}% +%<latexrelease>\def\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} +%<latexrelease>\let\IfPackageAtLeastTF\@ifpackagelater +%<latexrelease>\let\IfClassAtLeastTF\@ifclasslater +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@ifl@ter} % \begin{macrocode} \def\@ifl@ter#1#2{% \expandafter\@ifl@t@r @@ -675,6 +720,7 @@ % \begin{macrocode} \@onlypreamble\@ifl@t@r % \end{macrocode} +% \end{macro} % % \changes{v1.1j}{2016/06/20} % {don't declare as \cs{@onlypreamble}} @@ -695,8 +741,8 @@ %</2ekernel|latexreleasefirst> %<*2ekernel> % \end{macrocode} -% \end{macro} -% \end{macro} +% +% % % \begin{macro}{\@ifpackagewith} % \begin{macro}{\@ifclasswith} @@ -1050,6 +1096,10 @@ % % The common part of |\ProcessOptions| and |\ProcessOptions*|. % \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\@process@pti@ns}{Unused options issue}% \def\@process@pti@ns{% \@for\CurrentOption:=\@curroptions\do{% \@ifundefined{ds@\CurrentOption}% @@ -1073,11 +1123,33 @@ % \end{macrocode} % \changes{v1.0r}{1995/10/17} % {Reset \cs{CurrentOption} for graphics/1873} +% \changes{v1.3k}{2020/04/07}{Use different method to ignore +% unprocessed options (gh/22)} % \begin{macrocode} \let\CurrentOption\@empty \let\@fileswith@pti@ns\@@fileswith@pti@ns - \AtEndOfPackage{\let\@unprocessedoptions\relax}} + \AtEndOfPackage{\expandafter\let + \csname unprocessedoptions-\@currname.\@currext\endcsname + \relax}} \@onlypreamble\@process@pti@ns +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\@process@pti@ns}{Unused options issue}% +%<latexrelease> +%<latexrelease>\def\@process@pti@ns{% +%<latexrelease> \@for\CurrentOption:=\@curroptions\do{% +%<latexrelease> \@ifundefined{ds@\CurrentOption}% +%<latexrelease> {\@use@ption +%<latexrelease> \default@ds}% +%<latexrelease> \@use@ption}% +%<latexrelease> \@for\CurrentOption:=\@declaredoptions\do{% +%<latexrelease> \expandafter\let\csname ds@\CurrentOption\endcsname\relax}% +%<latexrelease> \let\CurrentOption\@empty +%<latexrelease> \let\@fileswith@pti@ns\@@fileswith@pti@ns +%<latexrelease> \AtEndOfPackage{\let\@unprocessedoptions\relax}} +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> % \end{macrocode} % \end{macro} % \end{macro} @@ -1243,13 +1315,45 @@ % \changes{v1.0v}{1996/10/04}{Reset \cs{@unprocessedoptions} for /2269} % Load package `|#1|' with the current option list. % \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\RequirePackageWithOptions}{Unused options issue}% \def\RequirePackageWithOptions{% - \AtEndOfPackage{\let\@unprocessedoptions\relax}% +% \end{macrocode} +% The resetting of the unprocessed options is now done on a par package basis. +% \changes{v1.3k}{2020/04/07}{Use different method to ignore +% unprocessed options (gh/22)} +% \begin{macrocode} + \AtEndOfPackage{\expandafter\let + \csname unprocessedoptions-\@currname.\@currext\endcsname + \relax}% \@loadwithoptions\@pkgextension\RequirePackage} \@onlypreamble\RequirePackageWithOptions +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +% \end{macrocode} +% +% \begin{macrocode} +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\RequirePackageWithOptions}{Unused options issue}% +%<latexrelease> +%<latexrelease>\def\RequirePackageWithOptions{% +%<latexrelease> \AtEndOfPackage{\let\@unprocessedoptions\relax}% +%<latexrelease> \@loadwithoptions\@pkgextension\RequirePackage} +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> % \end{macrocode} % \end{macro} % +% + + + + + + +% % \begin{macro}{\usepackage} % To begin with, |\usepackage| produces an error. This is reset by % |\documentclass|. @@ -1482,6 +1586,10 @@ % \changes{v1.3d}{2019/10/18}{Initialize \cs{...-h@@k} only when loading % the package or class (gh/198)} % \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\@onefilewithoptions}{Unused options issue}% \def\@onefilewithoptions#1[#2][#3]#4{% \@pushfilename \xdef\@currname{#1}% @@ -1531,19 +1639,49 @@ {}% {\@missingfileerror\@currname\@currext}% % \end{macrocode} -% |\@unprocessedoptions| will generate an error for each specified -% option in a package unless a |\ProcessOptions| has appeared in the -% package file. +% In older versions of the code |\@unprocessedoptions| would +% generate an error for each specified +% option in a package unless a |\ProcessOptions| has appeared in the +% package file. % \changes{v0.2v}{1994/01/29} % {All options raise error if no \cs{ProcessOptions} appears} % \changes{v0.2x}{1994/02/02} -% {Only run the hook and options check if the file was loaded.} -% \begin{macrocode} - \let\@unprocessedoptions\@@unprocessedoptions +% {Only run the hook and options check if the file was +% loaded.} +% +% This has changed in 2020. We now use a separate macro per package +% to avoid interferences in case of nested packages. The whole +% code for handling this issue (GitHub 22) was provided by Hironobu +% Yamashita, thanks for that. +% \changes{v1.3k}{2020/04/07}{Use different method to ignore +% unprocessed options (gh/22)} +% \begin{macrocode} + \expandafter\let\csname unprocessedoptions-\@currname.\@currext\endcsname + \@@unprocessedoptions \csname\@currname.\@currext-h@@k\endcsname \expandafter\let\csname\@currname.\@currext-h@@k\endcsname \@undefined - \@unprocessedoptions}% +% \end{macrocode} +% Catch the case where the packages has handled the options and +% redefined \cs{@unprocessedoptions} to \cs{relax} (old interface). +% In that case no error should be produced. +% \changes{v1.3k}{2020/04/07}{Use different method to ignore +% unprocessed options (gh/22)} +% \begin{macrocode} + \ifx\@unprocessedoptions\relax + \let\@unprocessedoptions\@undefined +% \end{macrocode} +% Otherwise run the per package set of unused options. +% \begin{macrocode} + \else + \csname unprocessedoptions-\@currname.\@currext\endcsname + \fi +% \end{macrocode} +% In either case we drop the macro afterwards as it is no longer needed. +% \begin{macrocode} + \expandafter\let + \csname unprocessedoptions-\@currname.\@currext\endcsname + \@undefined}% % \end{macrocode} % % \begin{macrocode} @@ -1565,8 +1703,82 @@ \reserved@a} \@onlypreamble\@onefilewithoptions % \end{macrocode} +% +% The kernel no longer uses \cs{@unprocessedoptions} +% \begin{macrocode} +\let\@unprocessedoptions\@undefined +% \end{macrocode} +% +% \begin{macrocode} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\@onefilewithoptions}{Unused options issue}% +%<latexrelease> +% \end{macrocode} +% Because of the way \cs{@onfilewithoptions} is changed for +% rollback handling below we have to define +% \cs{load@onefilewithoptions} when rollowing back! +% \begin{macrocode} +%<latexrelease>\def\load@onefilewithoptions#1[#2][#3]#4{% +%<latexrelease> \@pushfilename +%<latexrelease> \xdef\@currname{#1}% +%<latexrelease> \global\let\@currext#4% +%<latexrelease> \let\CurrentOption\@empty +%<latexrelease> \@reset@ptions +%<latexrelease> \makeatletter +%<latexrelease> \def\reserved@a{% +%<latexrelease> \@ifl@aded\@currext{#1}% +%<latexrelease> {\@if@ptions\@currext{#1}{#2}{}% +%<latexrelease> {\@latex@error +%<latexrelease> {Option clash for \@cls@pkg\space #1}% +%<latexrelease> {The package #1 has already been loaded +%<latexrelease> with options:\MessageBreak +%<latexrelease> \space\space[\@ptionlist{#1.\@currext}]\MessageBreak +%<latexrelease> There has now been an attempt to load it +%<latexrelease> with options\MessageBreak +%<latexrelease> \space\space[#2]\MessageBreak +%<latexrelease> Adding the global options:\MessageBreak +%<latexrelease> \space\space +%<latexrelease> \@ptionlist{#1.\@currext},#2\MessageBreak +%<latexrelease> to your \noexpand\documentclass declaration may fix this.% +%<latexrelease> \MessageBreak +%<latexrelease> Try typing \space <return> \space to proceed.}}}% +%<latexrelease> {\@pass@ptions\@currext{#2}{#1}% +%<latexrelease> \global\expandafter +%<latexrelease> \let\csname ver@\@currname.\@currext\endcsname\@empty +%<latexrelease> \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty +%<latexrelease> \InputIfFileExists +%<latexrelease> {\@currname.\@currext}% +%<latexrelease> {}% +%<latexrelease> {\@missingfileerror\@currname\@currext}% +%<latexrelease> \let\@unprocessedoptions\@@unprocessedoptions +%<latexrelease> \csname\@currname.\@currext-h@@k\endcsname +%<latexrelease> \expandafter\let\csname\@currname.\@currext-h@@k\endcsname +%<latexrelease> \@undefined +%<latexrelease> \@unprocessedoptions}% +%<latexrelease> \@ifl@ter\@currext{#1}{#3}{}% +%<latexrelease> {\@latex@warning@no@line +%<latexrelease> {You have requested,\on@line, +%<latexrelease> version\MessageBreak +%<latexrelease> `#3' of \@cls@pkg\space #1,\MessageBreak +%<latexrelease> but only version\MessageBreak +%<latexrelease> `\csname ver@#1.\@currext\endcsname'\MessageBreak +%<latexrelease> is available}}% +%<latexrelease> \ifx\@currext\@clsextension\let\LoadClass\@twoloadclasserror\fi +%<latexrelease> \@popfilename +%<latexrelease> \@reset@ptions}% +%<latexrelease> \reserved@a} +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> +% \end{macrocode} % \end{macro} % +% +% +% +% +% % \begin{macro}{\@@fileswith@pti@ns} % Save the definition (for error checking). % \changes{v0.2c}{1993/11/17} @@ -1593,6 +1805,9 @@ % \end{macrocode} % \end{macro} % +% +% +% % \subsection{Hooks} % % Allow code do be saved to be executed at specific later times. @@ -1760,6 +1975,7 @@ % \end{macrocode} % \end{macro} % +% \begin{environment}{filecontents} % \begin{macro}{\filecontents} % \begin{macro}{\endfilecontents} % This environment implements inline files. @@ -1776,13 +1992,12 @@ % \changes{v1.0m}{1995/04/21} % {Close input check stream: latex/1487} % \changes{v1.0p}{1995/05/25}{Delete \cs{filec@ntents} after preamble} -% \begin{macrocode} % \changes{v1.3a}{2019/07/01}{Support UTF8 and spaces in % filecontents environment file name} % \changes{v1.3b}{2019/08/27}{Make various commands robust} % \changes{v1.3c}{2019/09/11}{Support optional argument for filecontents} % \changes{v1.3f}{2020/01/05}{Support more write streams in LuaTeX gh/238} -% +% \begin{macrocode} %</2ekernel> %<*2ekernel|latexrelease> %<latexrelease>\IncludeInRelease{2019/10/01}% @@ -2142,6 +2357,7 @@ % \end{macrocode} % \end{macro} % \end{macro} +% \end{environment} % % % |