summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/stackengine
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-10-16 00:07:41 +0000
committerKarl Berry <karl@freefriends.org>2013-10-16 00:07:41 +0000
commit3870a2c7761dfea7de17734853592febec18777e (patch)
treec9b578822feccc01cd66a42f8c1d3b503ab26fb8 /Master/texmf-dist/tex/latex/stackengine
parent0e1db9a175dc6e40e5975bd72684d0caf449ed3a (diff)
stackengine (15oct13)
git-svn-id: svn://tug.org/texlive/trunk@31912 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/stackengine')
-rw-r--r--Master/texmf-dist/tex/latex/stackengine/stackengine.sty90
1 files changed, 61 insertions, 29 deletions
diff --git a/Master/texmf-dist/tex/latex/stackengine/stackengine.sty b/Master/texmf-dist/tex/latex/stackengine/stackengine.sty
index 999f532132e..d974a3d91c6 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.11}
+\def\stackengineversionnumber{v3.21}
\ProvidesPackage{stackengine}
-[2013/09/25 \stackengineversionnumber\
+[2013/10/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
@@ -49,8 +49,17 @@
% \def\usestackstrut{} definition (now deprecated).
% V3.11 -Corrected bug in \stackinset which did not condition the
% anchor when using vertical centering in \stackMath mode
+% V3.2 -Incorporated changes suggested by E. Gregorio to make robust
+% the supporting macro \@readMANYrows
+% -Introduced routines: \Centerstack, \Vectorstack, \parenVectorstack
+% \bracketVectorstack, \braceVectorstack, \vertvectorstack,
+% and \ensurestackMath
+% V3.21 -Corrected a bug in \stackinset introduced in V3.11
+\RequirePackage{etoolbox}
\usepackage{calc}
-\usepackage{ifthen}
+
+\newtoggle{@doneROWreads}
+\newtoggle{stackloop@done}
\newcounter{@stackindex}
\newlength\@boxshift
\newlength\stack@tmplength
@@ -59,47 +68,45 @@
\newsavebox\@addedbox
\newsavebox\@anchorbox
\newsavebox\stackedbox
+\newsavebox{\@centerbox}
\newcounter{ROWcellindex@}
%% Following 3 lines thanks to Prof. Enrico Gregorio, from:
%% http://tex.stackexchange.com/questions/42318/
-%% removing-a-backslash-from-a-character-sequence
\begingroup\lccode`\|=`\\
\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
+%% Prof. Enrico Gregorio. See:
+%% http://tex.stackexchange.com/questions/137298/
\newcommand\setstackEOL[1]{%
- \ifthenelse{\equal{#1}{}}{\def\SEP@char{ }}{\def\SEP@char{#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||{%
- \protected@edef\@preSEP{##1}%
- \protected@edef\@postSEP{##2}%
+ \def\@preSEP{##1}%
+ \def\@postSEP{##2}%
}%
}
-
% FOR PROCESSING A GROUP OF STACK ROWS SEPARATED BY \SEP@char
\newcommand\@readMANYrows[1]{%
- \def\@doneROWreads{F}%
- \def\@postSEP{#1\SEP@char}%
+ \togglefalse{@doneROWreads}%
+ \edef\@postSEP{\unexpanded{#1}\expandonce{\SEP@char}}%
\setcounter{ROWcellindex@}{0}%
- \whiledo{\equal{\@doneROWreads}{F}}{%
+ \whileboolexpr{test {\nottoggle{@doneROWreads}}}{%
\stepcounter{ROWcellindex@}%
\expandafter\@processROW\@postSEP||%
- \ifthenelse{\equal{\@postSEP}{}}{%
- \def\@doneROWreads{T}%
+ \expandafter\ifstrempty\expandafter{\@postSEP}{%
+ \toggletrue{@doneROWreads}%
}{}%
- \ifthenelse{\equal{\SEP@char}{ }}%
- {\def\@preSEPtemp{\@preSEP}}%
- {\def\@preSEPtemp{\ignorespaces\@preSEP\unskip}}%
- \expandafter\protected@edef\csname arg\roman{ROWcellindex@}\endcsname{%
- \@preSEPtemp}%
+ \csedef{arg\roman{ROWcellindex@}}{\expandonce{\@preSEP}}%
}%
% \narg GIVES HOW MANY ROWS WERE PROCESSED
\xdef\narg{\arabic{ROWcellindex@}}%
}
+%%%%%
% PROCESS PACKAGE OPTIONS
\newif\ifstackengine@oldsyntax
@@ -138,7 +145,7 @@
\setstackEOL{ }
\fi
-% PACKAGE DEFAULT DEFINITIONS
+%%%%% PACKAGE DEFAULT DEFINITIONS
\def\useanchorwidth{F}% T= FORCE BOX WIDTH TO ANCHOR-WIDTH
\def\quietstack{F}% T = SUPPRESS OUTPUT OF ALL COMMANDS
% (USE \usebox{\stackedbox} TO RETRIEVE)
@@ -149,8 +156,6 @@
% DEPRECATED USAGE \def\usestackstrut{}; INSTEAD USE \strutshortanchors{}
%\def\usestackstrut{T}
-%MACROS
-
%%%%% MODES
\newcommand\stackMath{\global\def\stack@delim{$}}
\newcommand\stackText{\global\def\stack@delim{}}
@@ -162,7 +167,7 @@
\newcommand\strutshortanchors[1]{\def\usestackstrut{#1}}
\strutshortanchors{T}
-%%%%%
+%%%%% MACROS
%\stackengine{\Sstackgap or \Lstackgap or \stackgap or stacklength}
% {anchor}
@@ -252,12 +257,16 @@
\def\@stackcondition{\the@stackindex < \narg}%
\fi%
\sbox{\stackedbox}{%
- \stack@delim\csname arg\roman{@stackindex}\endcsname\stack@delim}%
- \whiledo{\@stackcondition}{%
+ \stack@delim\ignorespaces%
+ \csname arg\roman{@stackindex}\endcsname%
+ \unskip\stack@delim}%
+ \togglefalse{stackloop@done}%
+ \whileboolexpr{test {\nottoggle{stackloop@done}}}{%
\addtocounter{@stackindex}{\@stacksign 1}%
\stackengine{\csname#4stackgap\endcsname}%
- {\csname arg\roman{@stackindex}\endcsname}%
+ {\ignorespaces\csname arg\roman{@stackindex}\endcsname\unskip}%
{\usebox{\stackedbox}}{#3}{#1}{T}{\useanchorwidth}{#4}%
+ \ifnum\@stackcondition\else\toggletrue{stackloop@done}\fi%
}%
\if F\quietstack\usebox{\stackedbox}\fi%
}
@@ -325,7 +334,7 @@
\newcommand*\stackinset[6]{%
\def\conditioned@inset{\stack@delim#5\stack@delim}%
\def\conditioned@anchor{\stack@delim#6\stack@delim}%
- \ifthenelse{\equal{#4}{}}%
+ \ifstrequal{#4}{}%
{\setlength{\stack@tmplength}{0pt}}%
{\setlength{\stack@tmplength}{#4}}%
\if c#3%
@@ -334,7 +343,7 @@
-\heightof{\conditioned@inset}-\depthof{\conditioned@inset}}%
\addtolength{\stack@tmplength}{.5\temp@stkl}%
\fi%
- \ifthenelse{\equal{#2}{}}{\def\stack@tmp{0pt}}{\def\stack@tmp{#2}}%
+ \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}}%
@@ -343,10 +352,33 @@
\else%
\def\conditioned@inset{\stack@lroffset#5\stack@lroffset}%
\fi%
- \stackengine{-\stack@tmplength}{#6}{#5}%
+ \stackengine{-\stack@tmplength}{#6}{\conditioned@inset}%
{\inset@valign{#3}}{#1}{\quietstack}{T}{S}%
}
\def\inset@valign#1{\if t#1O\else U\fi}
+\newcommand\Centerstack[2][\stackalignment]{%
+ \sbox{\@centerbox}{\strutlongstacks{T}\Longstack[#1]{#2}}%
+ \raisebox{-.5\ht\@centerbox+.5\ht\strutbox}{\usebox{\@centerbox}}}
+
+\newcommand\Vectorstack[2][\stackalignment]{%
+ \ensurestackMath{\Centerstack[#1]{#2}}}
+
+\newcommand\parenVectorstack[2][\stackalignment]{%
+ \ensurestackMath{\left(\Centerstack[#1]{#2}\right)}}
+
+\newcommand\bracketVectorstack[2][\stackalignment]{%
+ \ensurestackMath{\left[\Centerstack[#1]{#2}\right]}}
+
+\newcommand\braceVectorstack[2][\stackalignment]{%
+ \ensurestackMath{\left\{\Centerstack[#1]{#2}\right\}}}
+
+\newcommand\vertVectorstack[2][\stackalignment]{%
+ \ensurestackMath{\left|\Centerstack[#1]{#2}\right|}}
+
+\newcommand\ensurestackMath[1]{%
+ \let\sv@stackmode\stack@delim\stackMath%
+ #1\global\let\stack@delim\sv@stackmode}
+
\endinput