From d8386a601069ef27d6bab8afc68b78b7c81151d3 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 5 Oct 2016 21:16:56 +0000
Subject: stackengine (5oct16)

git-svn-id: svn://tug.org/texlive/trunk@42215 c570f23f-e606-0410-a88d-b1316a301751
---
 .../tex/latex/stackengine/stackengine.sty          | 56 ++++++++++------------
 1 file changed, 24 insertions(+), 32 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/stackengine/stackengine.sty')

diff --git a/Master/texmf-dist/tex/latex/stackengine/stackengine.sty b/Master/texmf-dist/tex/latex/stackengine/stackengine.sty
index 226e2ef19e2..09a6a123e0c 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{v3.26}
+\def\stackengineversionnumber{v4.00}
 \ProvidesPackage{stackengine}
-[2016/07/28 \stackengineversionnumber\ 
+[2016/10/04 \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
@@ -71,7 +71,11 @@
 % V3.25 -Default longstack gap is now \normalbaselineskip, so as to
 %        automatically work in tabular environments.
 % V3.26 -V3.25 on partially fixed the problem of \normalbaselineskip.
+% V4.00 -Incorporate listofitems package methodology for parsing, requiring
+%        some package rewrite, primarily macro \@readMANYrows.
+%       -Eliminated all uses of \protected@edef.fxf
 \RequirePackage{etoolbox}
+\RequirePackage{listofitems}% REQUIRES listofitems.sty AND listofitems.tex
 \usepackage{calc}
 
 \newtoggle{@doneROWreads}
@@ -93,34 +97,19 @@
 \lowercase{\endgroup\def\removebs#1{\if#1|\else#1\fi}}
 \newcommand{\stack@macro@name}[1]{\expandafter\removebs\string#1}
 
-%% Following 3 macros were, in V3.2, made robust with the help of
+%% Following macro was, in V3.2, made robust with the help of
 %% Prof. Enrico Gregorio.  See:
 %% http://tex.stackexchange.com/questions/137298/
 \newcommand\setstackEOL[1]{%
   \ifstrempty{#1}{\def\SEP@char{ }}{\def\SEP@char{#1}}%
-  \expandafter\define@processROW\expandafter{\SEP@char}%
-}
-\newcommand\define@processROW[1]{%
-    \def\@processROW##1#1##2||{%
-      \def\@preSEP{##1}%
-      \def\@postSEP{##2}%
-    }%
 }
+
 % FOR PROCESSING A GROUP OF STACK ROWS SEPARATED BY \SEP@char
+% EMPLOYS listofitems PACKAGE, AS OF V4.0
 \newcommand\@readMANYrows[1]{%
-  \togglefalse{@doneROWreads}%
-  \edef\@postSEP{\unexpanded{#1}\expandonce{\SEP@char}}%
-  \setcounter{ROWcellindex@}{0}%
-  \whileboolexpr{test {\nottoggle{@doneROWreads}}}{%
-    \stepcounter{ROWcellindex@}%
-      \expandafter\@processROW\@postSEP||%
-    \expandafter\ifstrempty\expandafter{\@postSEP}{%
-      \toggletrue{@doneROWreads}%
-    }{}%
-    \csedef{arg\romannumeral\theROWcellindex@}{\expandonce{\@preSEP}}%
-  }%
-% \narg GIVES HOW MANY ROWS WERE PROCESSED
-  \xdef\narg{\arabic{ROWcellindex@}}%
+  \expandafter\setsepchar\expandafter{\SEP@char}%
+  \readlist*\stack@arg{#1}%
+  \xdef\stackengine@args{\stack@arglen}%
 }
 %%%%%
 
@@ -148,7 +137,7 @@
 \newcommand{\setstackgap}[2]{\@namedef{#1stackgap}{#2}}
 \newcommand\stackgap{\@nameuse{\if S\stacktype S\else L\fi stackgap}\relax}
 \setstackgap{S}{3pt}% SHORTSTACKING GAP BETWEEN ITEMS (SAME AS \shortstack)
-\setstackgap{L}{\normalbaselineskip}% LONGSTACKING GAP BETWEEN ITEMS (def. \normalbaselineskip)
+\setstackgap{L}{\normalbaselineskip}% LONGSTACKING BASELINESKIP (\normalbaselineskip)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \fi
 \ifstackengine@usestackEOL%
@@ -262,23 +251,24 @@
 \newcommand*\Longunderstack[2][\stackalignment]{\@stack{#1}{#2}{U}{L}}
 
 \newcommand*\@stack[4]{%
+  \bgroup% SO AS NOT TO INTERFERE WITH loi's \setsepchar
   \@readMANYrows{#2}%
   \if U#3%
-    \setcounter{@stackindex}{\narg}%
+    \setcounter{@stackindex}{\stackengine@args}%
     \def\@stacksign{-}%
     \def\@stackcondition{\the@stackindex > 1}%
   \else%
     \setcounter{@stackindex}{1}%
     \def\@stacksign{}%
-    \def\@stackcondition{\the@stackindex < \narg}%
+    \def\@stackcondition{\the@stackindex < \stackengine@args}%
   \fi%
   \def\@STRT{}%
   \if T\@strutlongstacks\if L#4\def\@STRT{\strut}\fi\fi%
   \sbox{\stackedbox}{%
     \@STRT\stack@delim\ignorespaces%
-      \csname arg\romannumeral\the@stackindex\endcsname%
+      \stack@arg[\the@stackindex]%
     \unskip\stack@delim}%
-  \ifnum\narg>1%
+  \ifnum\stackengine@args>1%
     \togglefalse{stackloop@done}%
   \else%
     \toggletrue{stackloop@done}%
@@ -286,11 +276,12 @@
   \whileboolexpr{test {\nottoggle{stackloop@done}}}{%
     \addtocounter{@stackindex}{\@stacksign 1}%
     \stackengine{\csname#4stackgap\endcsname}%
-      {\ignorespaces\csname arg\romannumeral\the@stackindex\endcsname\unskip}%
+      {\stack@arg[\the@stackindex]}%
       {\usebox{\stackedbox}}{#3}{#1}{T}{\useanchorwidth}{#4}%
     \ifnum\@stackcondition\else\toggletrue{stackloop@done}\fi%
   }%
   \if F\quietstack\usebox{\stackedbox}\fi%
+  \egroup%
 }
 
 % PERHAPS THESE SIX MACROS CAN BE REPLACED BY \toplap AND \bottomlap
@@ -342,15 +333,16 @@
     \expandafter\newsavebox\expandafter{\csname\sv@name content\endcsname}%
    }{}%
   \expandafter\sbox\csname\sv@name content\endcsname{#2}%
-  \protected@edef#1{\usebox{\csname\sv@name content\endcsname}}%
+  \expandafter\def\expandafter#1\expandafter{\expandafter\usebox\expandafter%
+    {\csname\sv@name content\endcsname}}%
 }
 
 \newcommand*\addstackgap[2][\Sstackgap]{\stackengine{#1}{%
   \stackengine{#1}{#2}{}{O}{c}{\quietstack}{T}{S}}{}{U}{c}{\quietstack}{T}{S}}
 
-\newcommand*\topinset[4]{\stackinset{\stackalignment}{#4}{t}{#3}{#1}{#2}}
+\newcommand*\topinset[4]{\stackinset{\stackalignment}{#4}{t}{#3}{#1}{#2}}% DEPRECATED
 
-\newcommand*\bottominset[4]{\stackinset{\stackalignment}{#4}{b}{#3}{#1}{#2}}
+\newcommand*\bottominset[4]{\stackinset{\stackalignment}{#4}{b}{#3}{#1}{#2}}% DEPRECATED
 
 %\stackinset{l/c/r}{x}{b/c/t}{y}{inset}{anchor}
 \newcommand*\stackinset[6]{%
-- 
cgit v1.2.3

