[latex3-commits] [latex3/latex2e] gh1185: add error test for #1185 (44d1c418)

github at latex-project.org github at latex-project.org
Sun Nov 26 22:32:46 CET 2023


Repository : https://github.com/latex3/latex2e
On branch  : gh1185
Link       : https://github.com/latex3/latex2e/commit/44d1c4187fce2cbf7c2f91a84629bb22732f62ac

>---------------------------------------------------------------

commit 44d1c4187fce2cbf7c2f91a84629bb22732f62ac
Author: David Carlisle <d.p.carlisle at gmail.com>
Date:   Sun Nov 26 21:32:46 2023 +0000

    add error test for #1185


>---------------------------------------------------------------

44d1c4187fce2cbf7c2f91a84629bb22732f62ac
 base/changes.txt      |  4 ++++
 base/doc/ltnews39.tex |  7 +++++++
 base/ltclass.dtx      | 22 +++++++++++++++++++++-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/base/changes.txt b/base/changes.txt
index c1024ea9..01ec8fde 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,10 @@ to completeness or accuracy and it contains some references to files that are
 not part of the distribution.
 ================================================================================
 
+2023-11-26  David Carlisle  <David.Carlisle at latex-project.org>
+
+	* ltclass.dtx: check that \RequirePackage is at top level (gh/1185)
+
 2023-11-16  Frank Mittelbach  <Frank.Mittelbach at latex-project.org>
 	* ltpara.dtx (subsection{Providing hooks for paragraphs}):
 	Correct error message: hook left horizontal not vertical mode (gh/1182)
diff --git a/base/doc/ltnews39.tex b/base/doc/ltnews39.tex
index 3002928c..f772e666 100644
--- a/base/doc/ltnews39.tex
+++ b/base/doc/ltnews39.tex
@@ -151,6 +151,13 @@
 
 \section{Code improvements}
 
+\subsection{Loading packages at the top level}
+Packages should only be loaded with \cs{usepackage} or \cs{RequirePackage}
+at the top level, not inside a group. Previously \LaTeX\ did not check this,
+but now an error is thrown if this occurs.
+%
+\githubissue{549}
+
 \subsection{Keep track of lost glyphs}
 
 A while ago we changed the \LaTeX{} default value for
diff --git a/base/ltclass.dtx b/base/ltclass.dtx
index bb521485..cd81c896 100644
--- a/base/ltclass.dtx
+++ b/base/ltclass.dtx
@@ -33,7 +33,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{ltclass.dtx}
-             [2023/04/14 v1.5h LaTeX Kernel (Class & Package Interface)]
+             [2023/11/26 v1.5i LaTeX Kernel (Class & Package Interface)]
 % \iffalse
 \documentclass{ltxdoc}
 \GetFileInfo{ltclass.dtx}
@@ -1752,10 +1752,30 @@
 % \end{macro}
 %
 % \begin{macro}{\RequirePackage}
+% \changes{v1.5i}{2023/11/26}{Test group level}
 % Load package if not already loaded.
 %    \begin{macrocode}
+%</2ekernel>
+%<latexrelease>\IncludeInRelease{2024/06/01}%
+%<latexrelease>                 {\RequirePackage}{Check Group}%
+%<*2ekernel|latexrelease>
+%<*2ekernel|latexrelease>
 \def\RequirePackage{%
+  \ifnum\currentgrouplevel>\z@
+     \@latex at error
+      {\noexpand\RequirePackage or \noexpand\usepackage in a group}%
+      {\noexpand\RequirePackage or \noexpand\usepackage should be at the top level}%
+  \fi
   \@fileswithoptions\@pkgextension}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease>                 {\RequirePackage}{Check Group}%
+%<latexrelease>\def\RequirePackage{%
+%<latexrelease>  \@fileswithoptions\@pkgextension}
+%<*2ekernel>
+%    \end{macrocode}
+%    \begin{macrocode}
 \@onlypreamble\RequirePackage
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list.