Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh1585 allowing \fpeval in array preamble #1586

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions base/doc/ltnews41.tex
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,25 @@ \subsection{\pkg{multicol}:\ Full support for extended marks}



\subsection{\pkg{array}:\ Improve preamble setup code for \texttt{p} and friends}

While the preamble of a \env{tabular} or \env{array} is being built
the arguments to \texttt{p}, \texttt{m}, or \texttt{b} columns were
expanded several times. That is normally harmless because that
argument contains usually just a dimension. However, in a case like
\verb=p{\fpeval{15}pt}= this resulted in an error, because \cs{fpeval}
was expanded a few times, but not often enough to result in a single
number. This has now been corrected and the argument is not expanded
at all to allow for such edge cases as well as the extension available
with the \pkg{calc} package, such as \verb=p{\widthof{AAAAAA}}= (the
latter was possible before but needed to be taken into account while
the correction was implemented.
%
\githubissue{1585}




%\section{Changes to files in the \pkg{cyrillic} category}

\begin{thebibliography}{9}\frenchspacing
Expand Down
2 changes: 1 addition & 1 deletion required/latex-lab/testfiles-OR/tagging-002-longtable.pvt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
\begin{longtable}{p{3cm}}
Test\footnote{abc}\\
\end{longtable}
\end{document}
\end{document}
3 changes: 2 additions & 1 deletion required/latex-lab/update-OR-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ l3build save -cconfig-OR \
memoir-001 \
scrartcl-001 \
tlb-multicol-marks-tagged \
tagging-001
tagging-001 \
tagging-002-longtable

l3build save -cconfig-OR-luatex \
footmisc-003 \
Expand Down
34 changes: 29 additions & 5 deletions required/tools/array.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
% \begin{macrocode}
%<+package>\NeedsTeXFormat{LaTeX2e}[2024/06/01]
%<+package>\ProvidesPackage{array}
%<+package> [2024/10/17 v2.6g Tabular extension package (FMi)]
%<+package> [2024/12/17 v2.6h Tabular extension package (FMi)]
%
% \fi
%
Expand Down Expand Up @@ -2242,7 +2242,7 @@ Bug reports can be opened (category \texttt{#1}) at\\%
%
%
%
% \begin{macro}{\@startpbox}
% \begin{macro}{\@startpbox,\@startpbox@action}
% In =\@classz= the macro =\@startpbox= is used.
% The width of the \textsf{parbox} is passed as an argument.
% =\vcenter=, =\vtop= or =\vbox= are already in the
Expand Down Expand Up @@ -2286,6 +2286,19 @@ Bug reports can be opened (category \texttt{#1}) at\\%
\everypar{}}%
}
% \end{macrocode}
%
% \changes{v2.6h}{2024/12/17}{New \cs{@startpbox@action} to do the real work
% after preamble was built (gh/1585)}
% Starting with 2.6h \cs{@startpbox} is only used during the
% built-up of the preamble changing there to \cs{@startpbox@action}
% To do the real work. For an explanation of this code see
% the documentation in \cs{@mkpream}. We keep the \cs{@startpbox}
% definition on top-level in case there are tabular packages that
% built the preamble differently and expect that it contains
% \cs{@startpbox} (\pkg{longtable} at the moment).
% \begin{macrocode}
\let\@startpbox@action\@startpbox
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@endpbox}
Expand Down Expand Up @@ -3285,12 +3298,23 @@ Bug reports can be opened (category \texttt{#1}) at\\%
% simple length expression, but with the calc package involved it
% could break under an "\edef" operation, which is how the preamble
% is constructed. We now make use of "\unexpanded" here to prevent that. The
% "\expandafter" gymnastics is necessary to expand the "#1" at least
% "\expandafter" gymnastics is necessary to expand the "#1" exactly
% once (since it will get "\@nextchar" as its value and need its
% content!
% content). However, once added to the preamble, no further
% expansion should happen if the preamble is extended. Therefore we
% change from \cs{@startpbox} to \cs{@startpbox@action}. The latter
% then has a trivial definition and expands (including its
% argument) to itself while the preamble is being built. Outside of this
% preamble built-up \cs{@startpbox@action} that does the actual work.
FrankMittelbach marked this conversation as resolved.
Show resolved Hide resolved
% The definition for \cs{@startpbox} is only ever used during
% \changes{v2.6h}{2024/12/17}{Expand argument of \cs{@startpbox}
% exactly once while the preamble is built and use
% \cs{@startpbox@action} later to do the real work (gh/1585)}
FrankMittelbach marked this conversation as resolved.
Show resolved Hide resolved
% \begin{macrocode}
\def\@startpbox##1{\unexpanded\expandafter{\expandafter
\@startpbox\expandafter{##1}}}\let\@endpbox\relax
\@startpbox@action\expandafter{##1}}}%
\def\@startpbox@action##1{\unexpanded{\@startpbox@action{##1}}}%
\let\@endpbox\relax
\let\do@row@strut\relax
\let\ar@align@mcell\relax
% \end{macrocode}
Expand Down
10 changes: 10 additions & 0 deletions required/tools/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
=======================================================================

2024-12-18 Frank Mittelbach <[email protected]>

* array.dtx (section{The macros \texttt{\textbackslash @classz}):
Expand argument of \@startpbox exactly once while the preamble is built
and use \@@startpbox later to do the real work (gh/1585)

* longtable.dtx (subsection{The \env{longtable} environment}):
Initialize \@startpbox@action instead of \@startpbox
to match array change (gh/1585)

2024-11-12 Frank Mittelbach <[email protected]>
* multicol.dtx (subsection{Tagging support}):
Added another socket to support tagging.
Expand Down
7 changes: 5 additions & 2 deletions required/tools/longtable.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
%<driver> \ProvidesFile{longtable.drv}
% \fi
% \ProvidesFile{longtable.dtx}
[2024-10-27 v4.22 Multi-page Table package (DPC)]
[2024-12-18 v4.23 Multi-page Table package (DPC)]
%
% \iffalse
%<*driver>
Expand Down Expand Up @@ -1249,10 +1249,13 @@
% \package{array} V2.0h. We do not need to set "\d@llarbegin" and
% "\d@llarend" as the \package{array} package gives them the correct
% values at the top level.
% \changes{v4.23}{2024/12/17}{Initialize \cs{@startpbox@action} instead
% of \cs{@startpbox} to match array change (gh/1585)}
% \begin{macrocode}
\advance\@tempdima\extrarowheight
\col@sep\tabcolsep
\let\@startpbox\LT@startpbox\let\LT@LL@FM@cr\@arraycr
\let\@startpbox@action\LT@startpbox
\let\LT@LL@FM@cr\@arraycr
\fi
% \end{macrocode}
% The rest of this macro is mainly based on \package{array} package, but
Expand Down
27 changes: 27 additions & 0 deletions required/tools/testfiles/github-1585.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
% This should not produce errors
\documentclass{article}

\input{test2e}

\usepackage{array}

\begin{document}

\START

\typeout{This should show no errors but did!}

\newcommand\hidden{\fpeval{15}pt}

\begin{tabular}{p{\fpeval{15}pt}p{\hidden}p{\fpeval{15}pt}p{\fpeval{15}pt}}
a & b & c & d
\end{tabular}


\begin{tabular}{p{\fpeval{15}pt}lll}
a & b & c & d
\end{tabular}

\newpage
\TIMO
\end{document}
10 changes: 10 additions & 0 deletions required/tools/testfiles/github-1585.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
This should show no errors but did!
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line ....
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line ....
[1
]
(github-1585.aux)
Loading