summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/stackengine/stackengine.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/stackengine/stackengine.sty')
-rw-r--r--Master/texmf-dist/tex/latex/stackengine/stackengine.sty61
1 files changed, 36 insertions, 25 deletions
diff --git a/Master/texmf-dist/tex/latex/stackengine/stackengine.sty b/Master/texmf-dist/tex/latex/stackengine/stackengine.sty
index e7b79fb04bc..d99282df7dd 100644
--- a/Master/texmf-dist/tex/latex/stackengine/stackengine.sty
+++ b/Master/texmf-dist/tex/latex/stackengine/stackengine.sty
@@ -1,6 +1,6 @@
-\def\stackengineversionnumber{v4.01}
+\def\stackengineversionnumber{v4.1}
\ProvidesPackage{stackengine}
-[2017/02/13 \stackengineversionnumber\
+[2021/07/15 \stackengineversionnumber\
Stacking text and objects in convenient ways]
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -78,6 +78,16 @@
% \setlength, which could also cause potential problems with the
% calc package.
% -Changed \global\def to \gdef and \global\edef to \xdef.
+% V4.1 -Removed \widthof type measurements in \stackinset and
+% \stackengine, instead setting things in saveboxes from the
+% outset and using \wd, thereby only setting stacked content
+% once. This is helpful for speed and also if counters are
+% present in arguments, which are now incremented only once.
+% -Save and restore counter entering/exiting \@stack, which
+% favorably resolves issue of nesting for multi-row stacks.
+% -Introduce \lstackMath and \lstackText as local versions of
+% \stackMath and \stackText (which are global).
+% -Eliminated \usestackstrut (became internal \@usestackstrut)
\RequirePackage{etoolbox}
\RequirePackage{listofitems}% REQUIRES listofitems.sty AND listofitems.tex
\usepackage{calc}
@@ -91,6 +101,8 @@
\newlength\@stackedboxwidth
\newsavebox\@addedbox
\newsavebox\@anchorbox
+\newsavebox\@insetbox
+\newsavebox\@backgroundbox
\newsavebox\stackedbox
\newsavebox{\@centerbox}
\newcounter{ROWcellindex@}
@@ -113,7 +125,7 @@
\newcommand\@readMANYrows[1]{%
\expandafter\setsepchar\expandafter{\SEP@char}%
\readlist*\stack@arg{#1}%
- \xdef\stackengine@args{\stack@arglen}%
+ \edef\stackengine@args{\stack@arglen}%
}
%%%%%
@@ -162,18 +174,17 @@
\def\stacktype{S}% S for constant gap shortstack;
% L for constant baselineskip longstack
-% DEPRECATED USAGE \def\usestackstrut{}; INSTEAD USE \strutshortanchors{}
-%\def\usestackstrut{T}
-
%%%%% MODES
\newcommand\stackMath{\gdef\stack@delim{$}}
\newcommand\stackText{\gdef\stack@delim{}}
+\newcommand\lstackMath{\def\stack@delim{$}}
+\newcommand\lstackText{\def\stack@delim{}}
\stackText
\newcommand\strutlongstacks[1]{\def\@strutlongstacks{#1}}
\strutlongstacks{F}
-\newcommand\strutshortanchors[1]{\def\usestackstrut{#1}}
+\newcommand\strutshortanchors[1]{\def\@usestackstrut{#1}}
\strutshortanchors{T}
%%%%% MACROS
@@ -192,10 +203,10 @@
\sbox{\stackedbox}{%
\sbox{\@anchorbox}{\@STRT\stack@delim#2\stack@delim}%
\sbox{\@addedbox}{\@STRT\stack@delim#3\stack@delim}%
- \settowidth{\@stackedboxwidth}{\@STRT\stack@delim#2\stack@delim}%
+ \setlength{\@stackedboxwidth}{\wd\@anchorbox}%
\if F#7%
\ifdim\wd\@addedbox>\@stackedboxwidth%
- \settowidth{\@stackedboxwidth}{\stack@delim\@STRT#3\stack@delim}%
+ \setlength{\@stackedboxwidth}{\wd\@addedbox}%
\fi%
\fi%
\setlength{\@boxshift}{#1}%
@@ -216,14 +227,14 @@
\usebox{\@anchorbox}%
\hspace{-.5\wd\@anchorbox}%
\hspace{-.5\wd\@addedbox}%
- \raisebox{\@boxshift}{\@STRT\stack@delim#3\stack@delim}%
+ \raisebox{\@boxshift}{\usebox{\@addedbox}}%
\hspace{-.5\wd\@addedbox}%
\hspace{.5\@stackedboxwidth}%
\else%
\if l#5%
\usebox{\@anchorbox}%
\hspace{-\wd\@anchorbox}%
- \raisebox{\@boxshift}{\@STRT\stack@delim#3\stack@delim}%
+ \raisebox{\@boxshift}{\usebox{\@addedbox}}%
\hspace{-\wd\@addedbox}%
\hspace{\@stackedboxwidth}%
\else%
@@ -232,7 +243,7 @@
\hspace{-\wd\@anchorbox}%
\usebox{\@anchorbox}%
\hspace{-\wd\@addedbox}%
- \raisebox{\@boxshift}{\@STRT\stack@delim#3\stack@delim}%
+ \raisebox{\@boxshift}{\usebox{\@addedbox}}%
\fi%
\fi%
\fi%
@@ -255,6 +266,7 @@
\newcommand*\Longunderstack[2][\stackalignment]{\@stack{#1}{#2}{U}{L}}
\newcommand*\@stack[4]{%
+ \edef\sv@stackindex{\the@stackindex}%
\bgroup% SO AS NOT TO INTERFERE WITH loi's \setsepchar
\@readMANYrows{#2}%
\if U#3%
@@ -286,6 +298,7 @@
}%
\if F\quietstack\usebox{\stackedbox}\fi%
\egroup%
+ \setcounter{@stackindex}{\sv@stackindex}%
}
% PERHAPS THESE SIX MACROS CAN BE REPLACED BY \toplap AND \bottomlap
@@ -312,12 +325,12 @@
\newcommand*\stackanchor[3][\stackgap]{%
\setlength{\stack@tmplength}{#1}%
\setlength{\stack@tmplength}{.5\stack@tmplength}%
- \if T\usestackstrut%
+ \if T\@usestackstrut%
\if S\stacktype\addtolength{\stack@tmplength}%
{.5\ht\strutbox-.5\dp\strutbox}\fi%
\fi%
\stackengine{\stack@tmplength}{}{#2}{O}{\stackalignment}{T}{F}{\stacktype}%
- \if T\usestackstrut%
+ \if T\@usestackstrut%
\if S\stacktype\addtolength{\stack@tmplength}%
{-\ht\strutbox+\dp\strutbox}\fi%
\fi%
@@ -350,28 +363,26 @@
%\stackinset{l/c/r}{x}{b/c/t}{y}{inset}{anchor}
\newcommand*\stackinset[6]{%
- \def\conditioned@inset{\stack@delim#5\stack@delim}%
- \def\conditioned@anchor{\stack@delim#6\stack@delim}%
+ \sbox\@backgroundbox{\stack@delim#6\stack@delim}%
+ \sbox\@insetbox{\stack@delim#5\stack@delim}%
\ifstrequal{#4}{}%
{\setlength{\stack@tmplength}{0pt}}%
{\setlength{\stack@tmplength}{#4}}%
\if c#3%
- \setlength{\temp@stkl}{%
- \heightof{\conditioned@anchor}+\depthof{\conditioned@anchor}%
- -\heightof{\conditioned@inset}-\depthof{\conditioned@inset}}%
+ \setlength{\temp@stkl}{\ht\@backgroundbox+\dp\@backgroundbox%
+ -\ht\@insetbox-\dp\@insetbox}%
\addtolength{\stack@tmplength}{.5\temp@stkl}%
\fi%
\ifstrequal{#2}{}{\def\stack@tmp{0pt}}{\def\stack@tmp{#2}}%
\def\stack@lroffset{\rule{\stack@tmp}{0pt}}%
- \addtolength{\stack@tmplength}{%
- \heightof{\conditioned@inset}+\depthof{\conditioned@inset}}%
+ \addtolength{\stack@tmplength}{\ht\@insetbox+\dp\@insetbox}%
\if c#1%
- \def\conditioned@inset{\stack@lroffset\stack@lroffset#5}%
+ \def\conditioned@inset{\stack@lroffset\stack@lroffset\usebox{\@insetbox}}%
\else%
- \def\conditioned@inset{\stack@lroffset#5\stack@lroffset}%
+ \def\conditioned@inset{\stack@lroffset\usebox{\@insetbox}\stack@lroffset}%
\fi%
- \stackengine{-\stack@tmplength}{#6}{\conditioned@inset}%
- {\inset@valign{#3}}{#1}{\quietstack}{T}{S}%
+ \stackengine{-\stack@tmplength}{\usebox{\@backgroundbox}}%
+ {\conditioned@inset}{\inset@valign{#3}}{#1}{\quietstack}{T}{S}%
}
\def\inset@valign#1{\if t#1O\else U\fi}