From e1b87798fe834d8a4ab1a5d8e2451405c36c62fb Mon Sep 17 00:00:00 2001 From: Frank Mittelbach Date: Wed, 18 Sep 2024 18:33:34 +0000 Subject: [PATCH 1/2] fix for #1468 --- base/doc/ltnews40.tex | 12 ++++++++++ required/tools/array.dtx | 13 ++++++++--- required/tools/changes.txt | 20 +++++++++++------ required/tools/testfiles/github-1468.lvt | 28 ++++++++++++++++++++++++ required/tools/testfiles/github-1468.tlg | 4 ++++ 5 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 required/tools/testfiles/github-1468.lvt create mode 100644 required/tools/testfiles/github-1468.tlg diff --git a/base/doc/ltnews40.tex b/base/doc/ltnews40.tex index 146a147c7..22f23dae3 100644 --- a/base/doc/ltnews40.tex +++ b/base/doc/ltnews40.tex @@ -458,6 +458,18 @@ \subsection{\pkg{longtable}: Extend caption type} {\endlongtable} \end{verbatim} + +\subsection{\pkg{array}: Improve \texttt{>\{...\}} specifier} + +If the argument of \texttt{>\{...\}} ended with a command accepting a +trailing optional argument, e.g., defined for example with +\verb=\NewDocumentCommand\foo{o}{...}=, one could get low-level +parsing errors. This has now been corrected. +% +\githubissue{1468} + + + %\section{Changes to files in the \pkg{cyrillic} category} \begin{thebibliography}{9}\frenchspacing diff --git a/required/tools/array.dtx b/required/tools/array.dtx index ca5e991be..c75bcd936 100644 --- a/required/tools/array.dtx +++ b/required/tools/array.dtx @@ -39,7 +39,7 @@ % \begin{macrocode} %<+package>\NeedsTeXFormat{LaTeX2e}[2024/06/01] %<+package>\ProvidesPackage{array} -%<+package> [2024/07/13 v2.6e Tabular extension package (FMi)] +%<+package> [2024/09/17 v2.6f Tabular extension package (FMi)] % % \fi % @@ -1387,8 +1387,12 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \end{macrocode} % Here, we assume that the \textsf{count} register % =\@tempcnta= has saved the value $=\count@= - 1$. +% +% We end with \cs{relax} to stop any parsing for optional +% arguments out of \verb=>{...}= at this point. +% \changes{v2.6f}{2024/09/13}{Stop parsing for optional argument (gh/1468)} % \begin{macrocode} - \the@toks \the \@tempcnta + \the@toks \the \@tempcnta \relax % \end{macrocode} % Next follows the =#= sign which specifies the place % where the text of the column shall be inserted. To avoid @@ -1442,7 +1446,10 @@ Bug reports can be opened (category \texttt{#1}) at\\% % \begin{macrocode} \def\insert@pcolumn{% \UseTaggingSocket{tbl/pcell/begin}% - \the@toks \the \@tempcnta +% \end{macrocode} +% \changes{v2.6f}{2024/09/13}{Stop parsing for optional argument (gh/1468)} +% \begin{macrocode} + \the@toks \the \@tempcnta \relax \ignorespaces \@sharp \unskip \the@toks \the \count@ \relax \UseTaggingSocket{tbl/pcell/end}% diff --git a/required/tools/changes.txt b/required/tools/changes.txt index 4f4c60d7b..05c455cb0 100644 --- a/required/tools/changes.txt +++ b/required/tools/changes.txt @@ -1,3 +1,16 @@ +======================================================================= +This file lists changes to the LaTeX2e files in reverse chronological order. +It is provided for convenience only. It therefore makes no claims to +completeness or accuracy and it contains some references to files that +are not part of the distribution. +======================================================================= + +2024-09-18 Frank Mittelbach + + * array.dtx (section{The insertion of declarations): + Stop parsing too far for an optional argument if >{...} ends in a command + with a trailing optional arg(gh/1468) + 2024-09-12 David Carlisle * build.lua, tools.ins: @@ -16,13 +29,6 @@ * array.dtx (subsection{Handling \cs{cline}}): Support for tagging \cline (tagging/134) -======================================================================= -This file lists changes to the LaTeX2e files in reverse chronological order. -It is provided for convenience only. It therefore makes no claims to -completeness or accuracy and it contains some references to files that -are not part of the distribution. -======================================================================= - 2024-07-04 Ulrike Fischer * longtable.dtx: diff --git a/required/tools/testfiles/github-1468.lvt b/required/tools/testfiles/github-1468.lvt new file mode 100644 index 000000000..3bff2eb4e --- /dev/null +++ b/required/tools/testfiles/github-1468.lvt @@ -0,0 +1,28 @@ +% https://github.com/latex3/latex2e/issues/1468 + +\documentclass{article} +\usepackage{array} + +\input{test2e} + + +\begin{document} + +$x$ % init fonts + +\START + +\newcommand\foo[1][]{x} + +\begin{tabular}{>{\foo}l<{\foo}>{\foo}p{2cm}<{\foo}} + Foo & Bar \\ +\end{tabular} + +\RenewDocumentCommand\foo{o}{x} + +\begin{tabular}{>{\foo}l<{\foo}>{\foo}p{2cm}<{\foo}} + Foo & Bar \\ +\end{tabular} + +\end{document} + diff --git a/required/tools/testfiles/github-1468.tlg b/required/tools/testfiles/github-1468.tlg new file mode 100644 index 000000000..736c84e45 --- /dev/null +++ b/required/tools/testfiles/github-1468.tlg @@ -0,0 +1,4 @@ +This is a generated file for the LaTeX2e validation system. +Don't change this file in any respect. +[1 +] (github-1468.aux) From 10c907f201bdd24be952c3a842617fe0767a2a57 Mon Sep 17 00:00:00 2001 From: Frank Mittelbach Date: Wed, 18 Sep 2024 22:45:15 +0200 Subject: [PATCH 2/2] Update required/tools/changes.txt Co-authored-by: Yukai Chou --- required/tools/changes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/required/tools/changes.txt b/required/tools/changes.txt index 05c455cb0..81130768e 100644 --- a/required/tools/changes.txt +++ b/required/tools/changes.txt @@ -7,9 +7,9 @@ are not part of the distribution. 2024-09-18 Frank Mittelbach - * array.dtx (section{The insertion of declarations): + * array.dtx (section{The insertion of declarations ...}): Stop parsing too far for an optional argument if >{...} ends in a command - with a trailing optional arg(gh/1468) + with a trailing optional arg (gh/1468) 2024-09-12 David Carlisle