[latex3-commits] [git/LaTeX3-latex3-latex2e] gh424: fix for #424 (990b2fcb)
Frank Mittelbach
frank.mittelbach at latex-project.org
Fri Dec 11 12:22:05 CET 2020
Repository : https://github.com/latex3/latex2e
On branch : gh424
Link : https://github.com/latex3/latex2e/commit/990b2fcb47fc4edf4703b41660b3456a6b094f1f
>---------------------------------------------------------------
commit 990b2fcb47fc4edf4703b41660b3456a6b094f1f
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date: Fri Dec 11 12:22:05 2020 +0100
fix for #424
>---------------------------------------------------------------
990b2fcb47fc4edf4703b41660b3456a6b094f1f
base/changes.txt | 6 +++
base/doc/ltnews33.tex | 11 +++++
base/ltbibl.dtx | 53 +++++++++++++++++++---
.../testfiles/{github-0354.lvt => github-0424.lvt} | 19 ++++----
base/testfiles/{tlb0039.tlg => github-0424.tlg} | 29 +++++++++++-
.../tlb-latexrelease-rollback-003-often.luatex.tlg | 4 ++
.../tlb-latexrelease-rollback-003-often.tlg | 4 ++
.../tlb-latexrelease-rollback-003-often.xetex.tlg | 4 ++
base/testfiles/tlb-rollback-004-often.luatex.tlg | 2 +
base/testfiles/tlb-rollback-004-often.tlg | 2 +
base/testfiles/tlb-rollback-004-often.xetex.tlg | 2 +
11 files changed, 117 insertions(+), 19 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 6e6a82ec..2eea2e76 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,12 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2020-12-10 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
+
+ * ltbibl.dtx (section{Bibliography Generation}):
+ Delay any \cs{nocite} in the preamble instead of raising
+ an error (gh/424)
+
2020-10-26 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
* ltmiscen.dtx (subsection{Environments}):
diff --git a/base/doc/ltnews33.tex b/base/doc/ltnews33.tex
index c0b7c72b..a31f5706 100644
--- a/base/doc/ltnews33.tex
+++ b/base/doc/ltnews33.tex
@@ -128,6 +128,17 @@ it always starts out in vertical mode.
\githubissue{385}
+\subsection{Allow \cs{nocite} in preamble}
+
+A natural place for \verb=\nocite{*}= would be the preamble of the
+document, but for historical reasons \LaTeX{} issued an error message
+if it was placed there. From the new release on it is now allowed in
+the preamble.
+%
+\githubissue{424}
+
+
+
\subsection{\ldots}
%
diff --git a/base/ltbibl.dtx b/base/ltbibl.dtx
index 4957e0fd..80b90503 100644
--- a/base/ltbibl.dtx
+++ b/base/ltbibl.dtx
@@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltbibl.dtx}
- [2020/12/05 v1.1r LaTeX Kernel (Bibliography)]
+ [2020/12/10 v1.1s LaTeX Kernel (Bibliography)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltbibl.dtx}
@@ -327,6 +327,10 @@
% \changes{v1.1g}{1995/05/08}{Use \cs{@firstofone}}
% \changes{v1.1k}{1995/10/20}{Removed refundefined flag}
% \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2021/05/01}%
+%<latexrelease> {\nocite}{Allow nocite in preamble}%
\def\nocite#1{\@bsphack
% \end{macrocode}
% With the implementation designed already in \LaTeX\,2.09 the
@@ -335,10 +339,15 @@
% that point. As a result the ``reference'' will appear on the
% terminal and nothing else will happen.
%
-% This would be easy to fix, but then a document using the fix will
+% [This would be easy to fix, but then a document using the fix will
% silently fail on an older release of \LaTeX{}, missing all
% citations done with |\nocite|. Thus we do only generate an error
-% message and leave the fix for a \LaTeXe{} successor.
+% message and leave the fix for a \LaTeXe{} successor.]
+%
+% Given that we are now a quarter century into using \LaTeXe{}
+% there is no good reason any more do limit ourself to 2.09
+% conciderations. So we now simply delay the \cs{nocide} if it is
+% issued in the preamble.
%
% \changes{v1.1o}{2003/05/18}{Check if we are after \cs{document}}
% \changes{v1.1p}{2004/01/04}{Changed error message}
@@ -354,16 +363,46 @@
\@latex at warning{Citation `\@citeb' undefined}}{}}%
\else
% \end{macrocode}
-% But before |\begin{document}| we raise an error message:
+% But before |\begin{document}| we raised an error message in the
+% past but as of 2021/05 not any longer.
% \begin{macrocode}
- \@latex at error{Cannot be used in preamble}\@eha
+% \@latex at error{Cannot be used in preamble}\@eha
% \end{macrocode}
-% Without the compatibility problems we could fix the problem as follows:
+% Instead we delay the declaration to the start of the document.
+% We have to use a late hook for this, so that it comes after the
+% \texttt{.aux} file is open for writing and after
+% \cs{@preamblecmds} was executed to change the above
+% test. Therefore \cs{AtBeginDocument} would still be too early.
+% \changes{v1.1s}{2020/12/10}{Delay any \cs{nocite} in the preamble
+% instead of raising an error}
% \begin{macrocode}
- % \AtBeginDocument{\nocite{#1}}
+ \AddToHook{begindocument/end}[kernel]{\nocite{#1}}%
\fi
\@esphack}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
% \end{macrocode}
+%
+% \begin{macrocode}
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\nocite}{Allow nocite in preamble}%
+%<latexrelease>
+%<latexrelease>\def\nocite#1{\@bsphack
+%<latexrelease> \ifx\@onlypreamble\document
+%<latexrelease> \@for\@citeb:=#1\do{%
+%<latexrelease> \edef\@citeb{\expandafter\@firstofone\@citeb}%
+%<latexrelease> \if at filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
+%<latexrelease> \@ifundefined{b@\@citeb}{\G at refundefinedtrue
+%<latexrelease> \@latex at warning{Citation `\@citeb' undefined}}{}}%
+%<latexrelease> \else
+%<latexrelease> \@latex at error{Cannot be used in preamble}\@eha
+%<latexrelease> \fi
+%<latexrelease> \@esphack}
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
+% \end{macrocode}
+%
% Since |\nocite{*}| should not produce a warning about undefined
% citation keys (see PR 557), we need to set the control sequence
% `|\b@*|' to something other than |\relax|. As a result |\cite{*}|
diff --git a/base/testfiles/github-0354.lvt b/base/testfiles/github-0424.lvt
similarity index 50%
copy from base/testfiles/github-0354.lvt
copy to base/testfiles/github-0424.lvt
index 382b297d..2947dfd3 100644
--- a/base/testfiles/github-0354.lvt
+++ b/base/testfiles/github-0424.lvt
@@ -1,21 +1,20 @@
-% \begin should complain early
-
\documentclass{article}
+
\input{test2e}
-\nonstopmode
+\START
-\begin{document}
+\nocite{A,B}
-\START
+\nocite{C}
+
+\ShowHook{begindocument/end}
-\begin{quote)
-qqq
-\end{quote}
+\SHOWFILE{\jobname.aux}
-aaa
+\begin{document}
-aaa
+\cite{D}
\end{document}
diff --git a/base/testfiles/tlb0039.tlg b/base/testfiles/github-0424.tlg
similarity index 55%
copy from base/testfiles/tlb0039.tlg
copy to base/testfiles/github-0424.tlg
index 2b19b617..ed375614 100644
--- a/base/testfiles/tlb0039.tlg
+++ b/base/testfiles/github-0424.tlg
@@ -1,6 +1,26 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
-(tlb0039.aux)
+-> The hook 'begindocument/end':
+> Code chunks:
+> kernel -> \nocite {A,B}\nocite {C}
+> Extra code for next invocation:
+> ---
+> Rules:
+> ---
+> Execution order:
+> kernel.
+<recently read> }
+l. ...\ShowHook{begindocument/end}
+-------- github-0424.aux (start) ---------
+(github-0424.aux)
+\relax^^M
+\citation{A}^^M
+\citation{B}^^M
+\citation{C}^^M
+\citation{D}^^M
+\gdef \@abspage at last{1}^^M
+-------- github-0424.aux (end) -----------
+(github-0424.aux)
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line ....
LaTeX Font Info: ... okay on input line ....
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line ....
@@ -15,5 +35,10 @@ LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line ....
LaTeX Font Info: ... okay on input line ....
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line ....
LaTeX Font Info: ... okay on input line ....
+LaTeX Warning: Citation `A' undefined on input line ....
+LaTeX Warning: Citation `B' undefined on input line ....
+LaTeX Warning: Citation `C' undefined on input line ....
+LaTeX Warning: Citation `D' on page 1 undefined on input line ....
[1
-] (tlb0039.aux)
+] (github-0424.aux)
+LaTeX Warning: There were undefined references.
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
index 413a426d..792a23aa 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.luatex.tlg
@@ -172,6 +172,8 @@ Applying: [....-..-..] \textsubscript on input line ...
Skipping: [....-..-..] subscript baseline on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Skipping: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Make commands robust on input line ....
Skipping: [....-..-..] Hook management file on input line ....
@@ -630,6 +632,8 @@ Already applied: [....-..-..] \textsubscript on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
Already applied: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Applying: [....-..-..] Make commands robust on input line ....
LaTeX Info: Redefining \markboth on input line ....
LaTeX Info: Redefining \markright on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
index baef9421..185584aa 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.tlg
@@ -170,6 +170,8 @@ Applying: [....-..-..] \textsubscript on input line ...
Skipping: [....-..-..] subscript baseline on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Skipping: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Make commands robust on input line ....
Skipping: [....-..-..] Hook management file on input line ....
@@ -622,6 +624,8 @@ Already applied: [....-..-..] \textsubscript on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
Already applied: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Applying: [....-..-..] Make commands robust on input line ....
LaTeX Info: Redefining \markboth on input line ....
LaTeX Info: Redefining \markright on input line ....
diff --git a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
index 1095a886..f7851ae1 100644
--- a/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
+++ b/base/testfiles/tlb-latexrelease-rollback-003-often.xetex.tlg
@@ -170,6 +170,8 @@ Applying: [....-..-..] \textsubscript on input line ...
Skipping: [....-..-..] subscript baseline on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Skipping: [....-..-..] Make commands robust on input line ....
Applying: [....-..-..] Make commands robust on input line ....
Skipping: [....-..-..] Hook management file on input line ....
@@ -631,6 +633,8 @@ Already applied: [....-..-..] \textsubscript on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
Already applied: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Applying: [....-..-..] Make commands robust on input line ....
LaTeX Info: Redefining \markboth on input line ....
LaTeX Info: Redefining \markright on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.luatex.tlg b/base/testfiles/tlb-rollback-004-often.luatex.tlg
index 1ace5b7e..97af6b60 100644
--- a/base/testfiles/tlb-rollback-004-often.luatex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.luatex.tlg
@@ -224,6 +224,8 @@ Already applied: [....-..-..] \textsubscript on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
Already applied: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Applying: [....-..-..] Make commands robust on input line ....
LaTeX Info: Redefining \markboth on input line ....
LaTeX Info: Redefining \markright on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.tlg b/base/testfiles/tlb-rollback-004-often.tlg
index 5adb0b92..fb5f0a88 100644
--- a/base/testfiles/tlb-rollback-004-often.tlg
+++ b/base/testfiles/tlb-rollback-004-often.tlg
@@ -222,6 +222,8 @@ Already applied: [....-..-..] \textsubscript on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
Already applied: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Applying: [....-..-..] Make commands robust on input line ....
LaTeX Info: Redefining \markboth on input line ....
LaTeX Info: Redefining \markright on input line ....
diff --git a/base/testfiles/tlb-rollback-004-often.xetex.tlg b/base/testfiles/tlb-rollback-004-often.xetex.tlg
index 1af90ca7..6c3ca0a9 100644
--- a/base/testfiles/tlb-rollback-004-often.xetex.tlg
+++ b/base/testfiles/tlb-rollback-004-often.xetex.tlg
@@ -222,6 +222,8 @@ Already applied: [....-..-..] \textsubscript on input line ....
Skipping: [....-..-..] subscript baseline on input line ....
Applying: [....-..-..] subscript baseline on input line ....
Already applied: [....-..-..] subscript baseline on input line ....
+Skipping: [....-..-..] Allow nocite in preamble on input line ....
+Applying: [....-..-..] Allow nocite in preamble on input line ....
Applying: [....-..-..] Make commands robust on input line ....
LaTeX Info: Redefining \markboth on input line ....
LaTeX Info: Redefining \markright on input line ....
More information about the latex3-commits
mailing list.