summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/tools/array.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-12-11 22:32:49 +0000
committerKarl Berry <karl@freefriends.org>2018-12-11 22:32:49 +0000
commitb8f67cb908880c8fdf6b03eb9c4d5219d7409171 (patch)
tree87574d214a3f39e7293bc54e2b40076ae052bed3 /Master/texmf-dist/source/latex/tools/array.dtx
parent6ffd766f7627989e12bfb89d63f908de8c052c81 (diff)
latex(2e) (11dec18)
git-svn-id: svn://tug.org/texlive/trunk@49390 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/tools/array.dtx')
-rw-r--r--Master/texmf-dist/source/latex/tools/array.dtx131
1 files changed, 89 insertions, 42 deletions
diff --git a/Master/texmf-dist/source/latex/tools/array.dtx b/Master/texmf-dist/source/latex/tools/array.dtx
index d8f3687a026..ec597464c04 100644
--- a/Master/texmf-dist/source/latex/tools/array.dtx
+++ b/Master/texmf-dist/source/latex/tools/array.dtx
@@ -32,7 +32,7 @@
%<+package>\DeclareCurrentRelease{}{2018-04-30}
%<+package>
%<+package>\ProvidesPackage{array}
-%<+package> [2018/04/30 v2.4h Tabular extension package (FMi)]
+%<+package> [2018/11/13 v2.4j Tabular extension package (FMi)]
%
% \fi
%
@@ -1283,6 +1283,10 @@
% \subsection{The macro \texttt{\textbackslash @mkpream}}
%
% \begin{macro}{\@mkpream}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
% \begin{macro}{\the@toks}
% \label{@mkpream}
% Now we can define the macro which builds up the preamble for the
@@ -1290,7 +1294,7 @@
% First we initialize =\@preamble=, =\@lastchclass=
% and the boolean variable =\if@firstamp=.
% \begin{macrocode}
-\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
+%\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
% \end{macrocode}
% During the build-up of the preamble we cannot directly use the
% =#= sign; this would lead to an error message in the next
@@ -1309,7 +1313,7 @@
% macros expand in many \textsf{tokens} which would delay the
% build-up of the preamble.
% \begin{macrocode}
- \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
+% \let\@sharp\relax\let\@startpbox\relax\let\@endpbox\relax
% \end{macrocode}
% Two more are needed to deal with the code that handles struts
% for extra space after a row from =\\[<space>]=
@@ -1318,27 +1322,27 @@
% \changes{v2.4e}{2016/10/07}{Fixing SX68732}
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}}
% \begin{macrocode}
- \let\do@row@strut\relax
- \let\ar@align@mcell\relax
+% \let\do@row@strut\relax
+% \let\ar@align@mcell\relax
% \end{macrocode}
% Now we remove possible $*$-forms in the user preamble with the
% command =\@xexpast=. As we already know, this command saves
% its result in the macro =\@tempa=.
% \begin{macrocode}
- \@xexpast #1*0x\@@
+% \@xexpast #1*0x\@@
% \end{macrocode}
% Afterwards we initialize all registers and macros, that we need
% for the build-up of the preamble.
% Since we want to start with the \textsf{token} register $0$,
% =\count@= has to contain the value $-1$.
% \begin{macrocode}
- \count@\m@ne
- \let\the@toks\relax
+% \count@\m@ne
+% \let\the@toks\relax
% \end{macrocode}
% Then we call up =\prepnext@tok= in order to prepare the
% \textsf{token} register $0$ for use.
% \begin{macrocode}
- \prepnext@tok
+% \prepnext@tok
% \end{macrocode}
% To evaluate the user preamble (without stars) saved in
% =\@tempa= we use the \LaTeX--macro =\@tfor=.
@@ -1347,8 +1351,8 @@
% =\@tempa= and not the macro =\@tempa= to this
% \LaTeX--macro.
% \begin{macrocode}
- \expandafter \@tfor \expandafter \@nextchar
- \expandafter :\expandafter =\@tempa \do
+% \expandafter \@tfor \expandafter \@nextchar
+% \expandafter :\expandafter =\@tempa \do
% \end{macrocode}
% The body of this loop (the group after the =\do=)
% is executed for one \textsf{token} at a time, whereas
@@ -1359,15 +1363,15 @@
% the character number of this \textsf{token}.
% \changes{v2.0f}{1992/02/29}{\cs{@testpach} now without arg}
% \begin{macrocode}
- {\@testpach
+% {\@testpach
% \end{macrocode}
% Then we branch out depending on the value of =\@chclass= into
% different macros that extend the preamble respectively.
% \begin{macrocode}
- \ifcase \@chclass \@classz \or \@classi \or \@classii
- \or \save@decl \or \or \@classv \or \@classvi
- \or \@classvii \or \@classviii \or \@classix
- \or \@classx \fi
+% \ifcase \@chclass \@classz \or \@classi \or \@classii
+% \or \save@decl \or \or \@classv \or \@classvi
+% \or \@classvii \or \@classviii \or \@classix
+% \or \@classx \fi
% \end{macrocode}
% Two cases deserve our special attention: Since the current
% \textsf{token} cannot have the character class $4$ (start) we
@@ -1379,29 +1383,29 @@
% =\@lastchclass= to assure that this information will be available
% during the next run of the loop.
% \begin{macrocode}
- \@lastchclass\@chclass}%
+% \@lastchclass\@chclass}%
% \end{macrocode}
% After the loop has been finished space must still be added to
% the created preamble, depending on the last \textsf{token}.
% Depending on the value of =\@lastchclass= we perform
% the necessary operations.
% \begin{macrocode}
- \ifcase\@lastchclass
+% \ifcase\@lastchclass
% \end{macrocode}
% If the last class equals $0$ we add a
% =\hskip \col@sep=.
% \begin{macrocode}
- \@acol \or
+% \@acol \or
% \end{macrocode}
% If it equals $1$ we do not add any additional space so that the
% horizontal lines do not exceed the vertical ones.
% \begin{macrocode}
- \or
+% \or
% \end{macrocode}
% Class $2$ is treated like class $0$ because a =<{...}= can
% only directly follow after class $0$.
% \begin{macrocode}
- \@acol \or
+% \@acol \or
% \end{macrocode}
% Most of the other possibilities can only appear if the user
% preamble was defective. Class $3$ is not allowed since after a
@@ -1409,32 +1413,32 @@
% \texttt{r}, \texttt{p},\texttt{m} or \texttt{b}. We report an
% error and ignore the declaration given by ={..}=.
% \begin{macrocode}
- \@preamerr \thr@@ \or
+% \@preamerr \thr@@ \or
% \end{macrocode}
% If =\@lastchclass= is $4$ the user preamble has been empty.
% To continue, we insert a =#= in the preamble.
% \begin{macrocode}
- \@preamerr \tw@ \@addtopreamble\@sharp \or
+% \@preamerr \tw@ \@addtopreamble\@sharp \or
% \end{macrocode}
% Class $5$ is allowed again. In this case
% (the user preamble ends with =@{..}=) we need not
% do anything.
% \begin{macrocode}
- \or
+% \or
% \end{macrocode}
% Any other case means that the arguments to =@=, \texttt{!},
% \texttt{<}, \texttt{>}, \texttt{p}, \texttt{m} or \texttt{b} have
% been forgotten. So we report an error and ignore the last
% \textsf{token}.
% \begin{macrocode}
- \else \@preamerr \@ne \fi
+% \else \@preamerr \@ne \fi
% \end{macrocode}
% Now that the build-up of the preamble is almost finished we can
% insert the \textsf{token} registers and therefore redefine
% =\the@toks=. The actual insertion, though, is performed
% later.
% \begin{macrocode}
- \def\the@toks{\the\toks}}
+% \def\the@toks{\the\toks}}
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1593,7 +1597,6 @@
% mode. Therefore we start with a~=$=.
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}}
% \begin{macrocode}
-% $\vcenter
\setbox\ar@mcellbox\vbox
% \end{macrocode}
% The part of the templates which is the same in all three cases
@@ -1608,9 +1611,8 @@
% \changes{v2.4e}{2016/10/07}{Fixing SX68732}
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}}
% \begin{macrocode}
- \@startpbox{\@nextchar}\insert@column \@endpbox
- \ar@align@mcell
-%$
+ \@startpbox{\@nextchar}\insert@column \@endpbox
+ \ar@align@mcell
\do@row@strut \or
% \end{macrocode}
% The templates for \texttt{p} and \texttt{b} are generated in the
@@ -1691,6 +1693,11 @@
%
% \begin{macro}{\@classix}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% In case of class $9$ (\texttt{>}--\textsf{token}) we first check
% if the character class of the last
% \textsf{token} was $3$. In this case we have a
@@ -1699,28 +1706,33 @@
% So the declarations defined by the first =>{...}=
% are ignored.
% \begin{macrocode}
-\def\@classix{\ifnum \@lastchclass = \thr@@
- \@preamerr \thr@@ \fi
+%\def\@classix{\ifnum \@lastchclass = \thr@@
+% \@preamerr \thr@@ \fi
% \end{macrocode}
% Furthermore, we call up =\@class10= because afterwards always a
% new column is started by \texttt{c}, \texttt{l}, \texttt{r},
% \texttt{p}, \texttt{m} or \texttt{b}.
% \begin{macrocode}
- \@classx}
+% \@classx}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\@classviii}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% If the current \textsf{token} is a \texttt{<} the last character
% class must be $0$. In this case it is not necessary to extend the
% preamble. Otherwise we output an error message, set =\@chclass=
% to $6$ and call =\@classvi=. By doing this we achieve that
% \texttt{<} is treated like \texttt{!}.
% \begin{macrocode}
-\def\@classviii{\ifnum \@lastchclass >\z@
- \@preamerr 4\@chclass 6 \@classvi \fi}
+%\def\@classviii{\ifnum \@lastchclass >\z@
+% \@preamerr 4\@chclass 6 \@classvi \fi}
% \end{macrocode}
% \end{macro}
%
@@ -1819,11 +1831,16 @@
%
%
% \begin{macro}{\@classv}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% If the current \textsf{token} is of class $5$ then it is an
% argument of a \texttt{@} \textsf{token}. It must be stored into a
% \textsf{token} register.
% \begin{macrocode}
-\def\@classv{\save@decl
+%\def\@classv{\save@decl
% \end{macrocode}
% We extend the preamble with a command which inserts this
% \textsf{token} register into the preamble when its construction
@@ -1834,11 +1851,11 @@
% \changes{v2.0c}{1990/08/14}{\cs{relax} added to avoid problem
% `the`toks0`the`toks1.}
% \begin{macrocode}
- \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}%
+% \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}%
% \end{macrocode}
% Finally we must prepare the next \textsf{token} register.
% \begin{macrocode}
- \prepnext@tok}
+% \prepnext@tok}
% \end{macrocode}
% \end{macro}
%
@@ -1868,8 +1885,10 @@
% The width of the \textsf{parbox} is passed as an argument.
% =\vcenter=, =\vtop= or =\vbox= are already in the
% preamble. So we start with the braces for the wanted box.
+% \changes{v2.4i}{2018/09/13}{Add group to prevent color leak (gh/72)}
% \begin{macrocode}
\def\@startpbox#1{\bgroup
+ \color@begingroup
% \end{macrocode}
% The argument is the width of the box. This information has to be
% assigned to =\hsize=.
@@ -1917,8 +1936,9 @@
% =\@startpbox=.
% \changes{v2.2d}{1994/05/16}{Use \LaTeXe \cs{@finalstrut}}
% \changes{v2.3g}{1996/05/07}{Add \cs{hfil} for tools/2120}
+% \changes{v2.4i}{2018/09/13}{Add group to prevent color leak (gh/72)}
% \begin{macrocode}
-\def\@endpbox{\@finalstrut\@arstrutbox \egroup\hfil}
+\def\@endpbox{\@finalstrut\@arstrutbox \color@endgroup \egroup\hfil}
% \end{macrocode}
% \end{macro}
%
@@ -2307,10 +2327,15 @@
% \end{macro}
%
% \begin{macro}{\@tabarray}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% This macro tests for a optional bracket and then calls up
% =\@array= or =\@array[c]= (as default).
% \begin{macrocode}
-\def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}}
+%\def\@tabarray{\@ifnextchar[{\@array}{\@array[c]}}
% \end{macrocode}
% \end{macro}
%
@@ -2366,6 +2391,11 @@
% \end{macro}
%
% \begin{macro}{\endarray}
+% \emph{The code below has been replaced long time ago by an
+% extended version further down but the code and its documentation
+% was left here for reference. It is now commented out to avoid
+% confusion.}
+%
% When the processing of \textsf{array} is finished we have to
% close the =\halign=
% and afterwards the surrounding \textsf{box} selected by
@@ -2373,7 +2403,7 @@
% =\@preamble=
% because its replacement text isn't longer needed.
% \begin{macrocode}
-\def\endarray{\crcr \egroup \egroup \gdef\@preamble{}}
+%\def\endarray{\crcr \egroup \egroup \gdef\@preamble{}}
% \end{macrocode}
% \end{macro}
%
@@ -2675,6 +2705,7 @@
{\expandafter\@nextchar\the\toks\count@}}
% \end{macrocode}
% \end{macro}
+%
% \begin{macro}{\@mkpream}
% The main modification to "\@mkpream" is to replace the call to
% "\@xexpast" (which expanded $*$-forms) by a loop which expands
@@ -2683,7 +2714,23 @@
% \changes{v2.4f}{2017/11/04}{Managing m-cells without \cs{vcenter}}
% \begin{macrocode}
\def\@mkpream#1{\gdef\@preamble{}\@lastchclass 4 \@firstamptrue
- \let\@sharp\relax \let\@startpbox\relax \let\@endpbox\relax
+ \let\@sharp\relax
+% \end{macrocode}
+%
+% \changes{v2.4j}{2018/11/13}{Do not expand argument of
+% \cs{@startpbox} while building the tabular preamble (sx/459285)}
+% The "\@startpbox" (which is called for "p", "m" or "b" columns)
+% receives a user supplied argument: the width of the
+% paragraph-column. Normally that is something harmless like a length or a
+% 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
+% once (since it will get "\@nextchar" as its value and need its
+% content!
+% \begin{macrocode}
+ \def\@startpbox##1{\unexpanded\expandafter{\expandafter
+ \@startpbox\expandafter{##1}}}\let\@endpbox\relax
\let\do@row@strut\relax
\let\ar@align@mcell\relax
% \end{macrocode}