diff options
author | Karl Berry <karl@freefriends.org> | 2013-10-16 00:07:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-10-16 00:07:41 +0000 |
commit | 3870a2c7761dfea7de17734853592febec18777e (patch) | |
tree | c9b578822feccc01cd66a42f8c1d3b503ab26fb8 /Master | |
parent | 0e1db9a175dc6e40e5975bd72684d0caf449ed3a (diff) |
stackengine (15oct13)
git-svn-id: svn://tug.org/texlive/trunk@31912 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/stackengine/stackengine.pdf | bin | 317952 -> 347693 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/stackengine/stackengine.tex | 274 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/stackengine/stackengine.sty | 90 |
3 files changed, 274 insertions, 90 deletions
diff --git a/Master/texmf-dist/doc/latex/stackengine/stackengine.pdf b/Master/texmf-dist/doc/latex/stackengine/stackengine.pdf Binary files differindex b084e86fca2..5cec2173a35 100644 --- a/Master/texmf-dist/doc/latex/stackengine/stackengine.pdf +++ b/Master/texmf-dist/doc/latex/stackengine/stackengine.pdf diff --git a/Master/texmf-dist/doc/latex/stackengine/stackengine.tex b/Master/texmf-dist/doc/latex/stackengine/stackengine.tex index a61771b421d..89944774684 100644 --- a/Master/texmf-dist/doc/latex/stackengine/stackengine.tex +++ b/Master/texmf-dist/doc/latex/stackengine/stackengine.tex @@ -1,5 +1,4 @@ \documentclass{article} -\usepackage{fixltx2e} \usepackage{scalerel} \usepackage{stackengine} \usepackage{verbatimbox} @@ -41,6 +40,8 @@ steven.b.segletes.civ@mail.mil\\ %\tableofcontents \sffamily% +A sectional index for this package is found in \S\ref{s:index}. + Note: A syntax change in version 2.0 may require minor changes in your existing V1.0 stackengine code. See \S\ref{s:bc} for details. \rmfamily% @@ -65,13 +66,11 @@ examples to see this clearly. Notice the consistent inter-item gap on a short stack: \Huge \Shortstack{{\fbox{t}} {\fbox{y}} {\fbox{k}} {\fbox{e}}} -%\Shortstack{{\fbox{a}} {\fbox{h}} {\fbox{g}} {\fbox{b}}} \normalsize Notice the consistent inter-baseline spacing on a long stack: \Huge \Longstack{{{\rl t}} {{\rl y}} {{\rl k}} {{\rl e}}} -%\Longstack{{{\rl a}} {{\rl h}} {{\rl g}} {{\rl b}}} \normalsize\\ In this package, the default spacing (\textit{i.e.}, stacklength) for @@ -94,7 +93,7 @@ upon the baseline. In this document, we will graphically use the symbol \blmark\rl\Shortunderstack{A B C}\rl\rl text continues here -\subsection{(Over)Stacks and Understacks} +\subsection{(Over)Stacks and Understacks\label{s:osus}} \setstackgap{L}{.8\baselineskip} \setstackgap{S}{4pt} @@ -112,7 +111,7 @@ depending on how the invocation is made. Sometimes, in this documentation, a stack will be called an ``overstack'' in order to avoid confusion with ``understack.'' -\subsection{Anchors} +\subsection{Anchors\label{s:anch}} The term ``anchor'' is used to denote an item in the stack whose baseline does not change in the course of the stacking operation. In @@ -151,7 +150,7 @@ the \vb|\stackalignment| definition. \section{Parameter Defaults, Modes, and Macros Provided by \ste} -\subsection{Parameter Defaults and How to Set Them} +\subsection{Parameter Defaults and How to Set Them\label{s:parms}} There are several macros that serve to store package default definitions. When a stacking macro does NOT explicitly ask for one of the @@ -169,14 +168,16 @@ long stacks. Those stackgaps are actually stored in the \vb|\def|'s \vb|\Lstackgap| The -\margcmd{Sstackgap}\margcmd{Lstackgap}% +\margcmd{Sstackgap}% parameter \vb|\Sstackgap| is the default inter-item gap for any stacking command that builds a short stack. It defaults to 3pt. -Correspondingly, \vb|\Lstackgap| is the inter-item baselineskip for +Correspondingly, +\margcmd{Lstackgap} +\vb|\Lstackgap| is the inter-item baselineskip for any stacking command that builds a long stack. It defaults to -\vb|\baselineskip|. To change these defaults -\margcmd{setstackgap}, the following macro is -provided: +\vb|\baselineskip|. To change these defaults, the following macro +is provided: +\margcmd{setstackgap} \itshape \vb|\setstackgap{S}{|inter-item stackgap\vb|}|\\ @@ -252,7 +253,11 @@ change the default so that {\ste} arguments will be processed in inline math mode (so-called \vb|\textstyle| math). Likewise, an invocation of \vb|\stackText| \margcmd{stackText}will reset the default processing of arguments to -text mode. +text mode. Both of these modes are global in their scope, so that invocation, +even within a macro, will continue to persist until later changed. If +you would like to have a single application stacked in math mode, without +changing the default mode setting, one could use the \vb|\ensurestackMath{}| +macro (see \ref{s:esm}). By default, stacks made by {\ste} are set in unframed boxes that are flush with the top and bottom of the stack. The \vb|\addstackgap| @@ -296,7 +301,7 @@ commands prior to the invocation of a desired stacking macro. \subsection{Stacking Macros} -\subsubsection{\cmd{stackengine}} +\subsubsection{\cmd{stackengine}\label{s:stackeng}} The basic (and most general) stacking macro provided by this package is \vb|\stackengine|. Nearly all other macros of this package merely @@ -362,7 +367,13 @@ forced to be a long stack with right-alignment and be typeset using \end{verbatim} \vspace{-0.8ex} -\subsubsection{\cmd{stackon} and \cmd{stackunder}} +While the stacking macros in the following sections offer the convenience +of a condensed syntax, which can be useful within your document, it may be +preferable to use the \vb|\stackengine| macro to create your own +stacking macros, since one can achieve the stacking result without +having to modify the package defaults. + +\subsubsection{\cmd{stackon} and \cmd{stackunder}\label{s:sou}} The \vb|\stackon| and \vb|\stackunder| macros are abbreviated forms of \vb|\stackengine| in which the default values of parameters are @@ -414,12 +425,9 @@ while the last item is the anchor of the stack. If an item (the contents of a single row) contains spaces, enclose the item in braces. If the item ends with a macro, enclose the item in braces. If used in a mixed text/math mode (see \S\ref{s:mm} for more -details), math items may be enclosed within dollar-sign delimiters. -\bfseries Note that, because of the parsing algorithm, macros in the -argument of \vb|\Shortstack| and \vb|\Longstack| may need to be -\vb|\protect|'ed. \mdseries Better still, using the \textsf{fixltx2e} package -eliminates the need to protect things like \vb|\rule|, \vb|\usebox|, -\textit{etc}. +details), math items may be enclosed within dollar-sign delimiters. As of +V3.2, these commands have been made robust and their arguments need +not be \verb|\protect|ed. The alignment may be specified as an optional argument, with other parameters taken by their defaults. The stacklength is taken as @@ -438,7 +446,7 @@ can be made the default:\\ \vb|\Shortunderstack[c]{{\alpha} {\beta} {\gamma}}|\\ yielding \stackMath -\Shortunderstack[c]{{\alpha} {\beta} {\gamma}}. +\Shortunderstack[c]{{\alpha} {\beta} {\gamma}}\. \stackText As of V3.1 of \ste, the user may define the the argument to @@ -450,14 +458,15 @@ are an example of equivalent stack arguments for two different EOL characters: Space EOL:~~~~\vb|{a {b c} {\P} $\beta^2$ ANCHOR}|\\ -\vb|\\| EOL:~~~~~~~~\,\vb|{a\\b c\\ \P\\ $\beta^2$ \\ANCHOR}| +\vb|\\| EOL:~~~~~~~~\,\vb|{a \\ b c \\ \P \\ $\beta^2$ \\ ANCHOR}| -Note that leading and trailing spaces are ignored for rows in the second +Note that leading and trailing spaces surrounding the \verb|\\| are ignored +for rows in the second case. The \vb|\setstackEOL| macro allows any arbitrary character to be set as the ``EOL'' character (for the purposes of parsing these stacking macros). -\subsubsection{\cmd{Shortunderstack} and \cmd{Longunderstack}} +\subsubsection{\cmd{Shortunderstack} and \cmd{Longunderstack}\label{s:slus}} The \vb|\Shortunderstack| and \vb|\Longunderstack| commands are the understacking equivalents of \vb|\Shortstack| and \vb|\Longstack|. @@ -484,7 +493,7 @@ the same as that mentioned above for \vb|\Shortstack| and \vb|\Longstack|. Note that the items are still specified from the top downward. -In the case of understacks, however, that means that the anchor is the +In the case of understacks; however, that means that the anchor is the first item specified, while the last item in the list is farthest below the baseline. @@ -521,7 +530,7 @@ mandatory argument, the horizontal direction of lapping (l, c, or r), while the material to be lapped is now in the second mandatory argument. \vspace{-0.8ex} -\subsubsection{\cmd{stackanchor}} +\subsubsection{\cmd{stackanchor}\label{s:sanc}} The \vb|\stackanchor| macro is one way to create a stack where the baseline is split between two items in the stack. The syntax is @@ -547,9 +556,78 @@ occur about the baseline (``F''). If a long stack is to be created with a split anchor, it is best to formulate and \vb|\savestack| both the upper portion (with a stack) and the lower portion (with an understack), and then \vb|\stackanchor| -the two parts together. +the two parts together. Alternately, one could use the +\vb|\Centerstack| macro (\S\ref{s:csvs}). + +\subsubsection{\cmd{Centerstack} and the math variants of + \cmd{Vectorstack}\label{s:csvs}} + +The macro \cmd{Centerstack} produces a type of \cmd{Longstack} that is +vertically centered about the mid-strut above the baseline. In essence, +it is like a \cmd{stackanchor} version of a \cmd{Longstack}. Additionally, +it is locally processed with the mode \cmd{strutlongstacks} set as +\verb|T|, so as to ensure +the proper vertical centering. -\subsubsection{\cmd{abovebaseline} and \cmd{belowbaseline}} +The \vb|\Centerstack| macro has a math-mode equivalent called +\cmd{Vectorstack}, in which the stacking argument +is automatically processed in math mode, regardless if whether the \cmd{stackMath} +mode is currently active. + +The syntax is the same as \vb|\Longstack|, except that the anchor is +not specified, but results naturally from the centering operation: + +\itshape +\vb|\Centerstack[|alignment% + \vb|]{|item % + \vb|{|it em% + \vb|} {\|item% + \vb|} $|item% + \vb|$| ... item% + \vb|}|\\ +\vb|\Vectorstack[|alignment% + \vb|]{|item % + \vb|{|it em% + \vb|} {\|item% + \vb|}| ... item% + \vb|}| +\upshape + +One of the main purposes of providing this vertically centered stack is +to be compatible with mathematical bracketing commands embodied in +the use of the \LaTeX{} syntax \vb|\left(...\right)|, which require +vertically centered material. To this end, there +are several variants of \vb|\Vectorstack| macro that are for specific +use in mathmode. Here are examples of all of these macros demonstrated: + +{\centering +\Centerstack{p q r s} +\Vectorstack{p q r s} +$\parenVectorstack{p q r s}$ +$\bracketVectorstack{p q r s}$ +$\braceVectorstack{p q r}$ +$\vertVectorstack{p q r}$.\par} +which are, respectively,\\ +\vb|\Centerstack{p q r s}|\\ +\vb|\Vectorstack{p q r s}|\\ +\vb|$\parenVectorstack{p q r s}$|\\ +\vb|$\bracketVectorstack{p q r s}$|\\ +\vb|$\braceVectorstack{p q r}$.|\\ +\vb|$\vertVectorstack{p q r}$.| + + +\subsubsection{\cmd{ensurestackMath}\label{s:esm}} + +The macro \vb|\ensurestackMath{}| macro is used to force its argument +(a stacking command) to be processed in math mode, without setting +the global default stacking +mode to math mode (otherwise accomplished via \vb|\stackMath|). Note +that this macro does \textbf{not} ensure that +all elements of its argument are processed in math mode (\textit{i.e.}, +it does not use, nor is it a replacement for \vb|\ensuremath|), but +only that stacking macros are processed in math mode. + +\subsubsection{\cmd{abovebaseline} and \cmd{belowbaseline}\label{s:abb}} The macros \vb|\abovebaseline| and \vb|\belowbaseline| also creates the means to shift an item's baseline. The syntax is @@ -573,13 +651,17 @@ One should consult \S\ref{s:bbl} for more details. This command can also be employed to redefine the baseline of graphical objects, which can provide a useful technique to achieve horizontal alignment with other objects. Negative stack gaps are valid (see -\S\ref{s:bbl} for examples). +\S\ref{s:bbl} for examples). While these macros will carry slightly +more processing overhead than a simple \vb|\raisebox|, it may be the +case that specifying the shift in terms of the baseline, rather than +with respect to the current configuration, may make for more +streamlined logic. \subsubsection{\cmd{stackinset}\label{s:iis}} The macro \vb|\stackinset| is for insetting smaller items (\textit{e.g.}, images or text) inside of a larger background -items (\textit{e.g.}, images). The syntax is +items (\textit{e.g.}, images or text). The syntax is \itshape \vb|\stackinset{|H-align% @@ -641,15 +723,15 @@ fixed gaplength (either specified or, by default, an amount given by \vb|\Sstackgap|) above and below the argument of the macro. Negative gaps will have no effect on the vertical extent of the item. -Here's an example a stack, before and after an \vb|\addstackgap| is +Here's an example of a stack, before and after \vb|\addstackgap| is applied, framed for clarity: \vb|\stackon{g}{a}|: \fbox{\stackon{g}{a}} versus \vb|\addstackgap{\stackon{g}{a}}| \fbox{\addstackgap{\stackon{g}{a}}}. This macro provides a slightly different result than the -\vb|\strutlongstacks| mode descirbed in \S\ref{s:sm}. For more details +\vb|\strutlongstacks| mode described in \S\ref{s:sm}. For more details of the comparison, see \S\ref{s:ag}. -\subsubsection{\cmd{hsmash}} +\subsubsection{\cmd{hsmash}\label{s:hsm}} \def\stacktype{L} The macro \vb|\hsmash| is a horizontal version of the popular @@ -673,7 +755,7 @@ these items below: \hsmash{\rule{5ex}{1ex}}\hfill\hsmash{\rule{2ex}{0ex}\rule{5em}{1ex}} -\subsubsection{\cmd{savestack}} +\subsubsection{\cmd{savestack}\label{s:ss}} The macro \vb|\savestack| provides a means to save an intermediate result (in a box that can be recalled with the specified macro) without @@ -735,11 +817,11 @@ look as follows, with the ``0'' on the final baseline. \Longstack[l]{{\pdq} 2 1 0} \rl\rl\blmark% -\section{Choosing the Anchor Element} +\section{Choosing the Anchor Element\label{s:cae}} -All stacking done with the stackengine has a designated anchor element. -The baseline of the anchor does not change. Instead, the other items -are placed relative to the anchor. +Nearly all stacking done with the \textsf{stackengine} package has +a designated anchor element. The baseline of the anchor does not +change. Instead, the other items are placed relative to the anchor. By adding items at first above and then below the anchor, any arbitrary stack can be built around the anchor. @@ -969,7 +1051,7 @@ tabular columns. \fbox{\parbox[t]{1.8cm}{\raggedright A parbox with [t] alignment}}% \rl\rl\blmark\rl -\section{Negative Stack Gap} +\section{Negative Stack Gap\label{s:nsg}} \def\stacktype{S} \setstackgap{S}{-1.2pt} \setlength{\dotscale}{1.ex} @@ -1083,7 +1165,7 @@ gives the following result:\begin{verbbox}[\small]\stackinset\end{verbbox} } \clearpage -\section{Stacking for Subfiguring and Baseline Manipulation} +\section{Stacking for Subfiguring and Baseline Manipulation\label{s:bm}} The stacking commands provide a convenient way to underset a subfigure notation under the corresponding image. Furthermore, because of the @@ -1092,19 +1174,13 @@ can be manipulated in many ways, which may come in handy depending on how you are choosing to lay out your subfigures. Examples of this are shown in figure~\ref{fg:subs}. -Note from the definition used for figure~\ref{fg:subs}(c) that when a -\vb|\savestack| has been used to place a graphic into a token -(\textit{e.g.}, \vb|\imgi|) that it must be protected when used inside -a space-separated argument, such as \vb|\Shortstack|, -\vb|\Longstack|, and the corresponding understacks (If the -\textsf{fixltx2e} package is used, the need to \vb|\protect| may be -alleviated). + % \setstackgap{S}{3pt}\def\stacktype{S}% \begin{myverbbox}{\figa}\stackon{(a)}{\imga}\end{myverbbox}% \begin{myverbbox}{\figb}\stackunder{\imgb}{(b)}\end{myverbbox}% \begin{myverbbox}[\small]{\figc} -\Shortstack{{\protect\imgi} (c1) {} {\protect\imgi} (c2)} +\Shortstack{{\imgi} (c1) {} {\imgi} (c2)} \end{myverbbox}% \begin{myverbbox}% {\figd}\belowbaseline[0pt]{\stackunder{\imgi}{(d)}}\end{myverbbox}% @@ -1115,12 +1191,11 @@ alleviated). {\blmark\rl\rl% \stackon{(a)}{\imga}~~ \stackunder{\imgb}{(b)}~~ -\Shortstack{{\protect\imgi} (c1) {} {\protect\imgi} (c2)}~~ +\Shortstack{{\imgi} (c1) {} {\imgi} (c2)}~~ \belowbaseline[0pt]{\stackunder{\imgi}{(d)}} }% -\clearpage -\section{Nested Stacking Commands} +\section{Nested Stacking Commands\label{s:nsc}} The macros \vb|\Shortstack|, \vb|\Longstack|, and the corresponding understack macros are set up to conveniently stack multiple objects @@ -1236,11 +1311,11 @@ delimiters. \vb|\( y = \stackunder{$a$}{+} x\)|:\hfill \( y = \stackunder{$a$}{+} x\) -\item Each space-separated item of the argument to \vb|\Shortstack|, +\item To set a particular stack completely in math style, without globally setting the mode with a \verb|\stackMath|, one can use \verb|\ensurestackMath{}|. + +\item If not using \verb|\ensurestackMath|, each space-separated item of the argument to \vb|\Shortstack|, \vb|\Longstack|, and the corresponding understacks must each be enclosed -in their own set of dollar-sign math delimiters (Because of the way the -argument is parsed, the \vb|\(| and \vb|\)| delimiters can be used, but -only if \vb|\protect|'ed, in these space-separated argument lists). +in their own set of math delimiters (either \verb|$...$| or \verb|\(...\)|). \vb|\(y = \Shortstack{$a$ . $b$} x\)|:\hfill \(y = \Shortstack{$a$ . $b$} x\) @@ -1256,7 +1331,7 @@ stack). \end{enumerate} -\section{Deprecated Features} +\section{Deprecated Features\label{s:df}} There are several definitions and macros from earlier versions of the {\ste} package that are still fully functional, but are discouraged @@ -1284,7 +1359,7 @@ syntax for \vb|\bottominset| and \vb|\topinset|. \section{Backward Compatibility\label{s:bc}} The author of this package profoundly apologizes for the fact that the -syntax of this package has changed between versions 1.0 and 2.0 of this +syntax of this package changed between versions 1.0 and 2.0 of this package. In version 1.0 of this package, stackgaps could be directly defined by @@ -1319,21 +1394,98 @@ overcome this behavior, the stackgap must be redefined at the new fontsize, or better still, \vb|[oldsyntax]| usage needs to be relegated.\vspace{-1.5ex} +\clearpage \section{Acknowledgements} I would like to thank Prof. Enrico Gregorio at tex.stackexchange for -providing three lines of code to strip a leading backslash from an -argument:\\ +assisting in numerous ways to make this package better: + +\begin{itemize} + +\item by providing three lines of code to strip a leading +backslash from an argument:\\ \vb|http://tex.stackexchange.com/questions/42318/|\\ \vb|removing-a-backslash-from-a-character-sequence| -Furthermore, Prof. Gregorio was of great assistance in making the +\item in making the transition from the deficient V1.0 syntax as painless as possible:\\ \vb|http://tex.stackexchange.com/questions/123443/|\\ \vb|defining-a-length-that-scales-with-fontsize-changes/123470#123470| +\item and in helping to make the parsing routines of this package robust:\\ +\vb|http://tex.stackexchange.com/questions/137298/|\\ +\vb|centering-breaks-fragile-command-is-there-a-fix/137314#137314| + +\end{itemize} + Thanks also to Dr. David Carlisle for explaining the need for argument -expansion in certain situations. +expansion in certain situations:\\ +\vb|http://tex.stackexchange.com/questions/131581/|\\ +\vb|parsing-rows-and-tab-characters/131594#131594| + +\section{Sectional index of \textsf{stackengine} definitions, modes, + \& macros\label{s:index}} + +{\small +\begin{tabular}{lll} +Definition, Mode, or Macro & \S\ Defined & \S\ Used\\ +\hline +\cmd{abovebaseline}&\ref{s:abb}&\ref{s:bbl}\\ +\cmd{addstackgap}&\ref{s:asg}&\ref{s:sou}, \ref{s:ag}\\ +\cmd{bclap}&\ref{s:lapdef}&\ref{s:lap}\\ +\cmd{belowbaseline}&\ref{s:abb}&\ref{s:bbl}\\ +\cmd{bllap}&\ref{s:lapdef}&\ref{s:lap}\\ +\cmd{bottomlap}&\ref{s:lapdef}&\ref{s:lap}\\ +\cmd{braceVectorstack}&\ref{s:csvs}&\\ +\cmd{bracketVectorstack}&\ref{s:csvs}&\\ +\cmd{brlap}&\ref{s:lapdef}&\ref{s:lap}\\ +\cmd{Centerstack}&\ref{s:csvs}&\ref{s:sanc}\\ +\cmd{ensurestackMath}&\ref{s:esm}&\ref{s:sm}, \ref{s:mm}\\ +\cmd{hsmash}&\ref{s:hsm}&\\ +\cmd{Longstack}&\ref{s:sls}&\ref{s:st}, \ref{s:osus}, \ref{s:sm}, \ref{s:slus}, + \ref{s:csvs}, \ref{s:svs}, \ref{s:cae}, \ref{s:ag}, \ref{s:nsc}, + \ref{s:mm}\\ +\cmd{Longunderstack}&\ref{s:slus}&\ref{s:osus}, \ref{s:sm}, \ref{s:cae}, + \ref{s:nsc}, \ref{s:mm}\\ +\cmd{Lstackgap}&\ref{s:parms}&\ref{s:st}, \ref{s:stackeng}, \ref{s:bbl}, + \ref{s:nsc}, \ref{s:bc}\\ +\cmd{parenVectorstack}&\ref{s:csvs}&\\ +\cmd{quietstack}&\ref{s:parms}&\ref{s:stackeng}, \ref{s:qs}\\ +\cmd{savestack}&\ref{s:ss}&\ref{s:sanc}, \ref{s:svs}, \ref{s:cae}, + \ref{s:mm}\\ +\cmd{setstackEOL}&\ref{s:sm}&\ref{s:sls}\\ +\cmd{Shortstack}&\ref{s:sls}&\ref{s:st}, \ref{s:osus}, \ref{s:anch}, + \ref{s:sal}, \ref{s:sm}, \ref{s:slus}, \ref{s:sa}, \ref{s:bm}, \ref{s:nsc}, + \ref{s:mm}\\ +\cmd{Shortunderstack}&\ref{s:slus}&\ref{s:st}, \ref{s:osus}, \ref{s:anch}, + \ref{s:sm}, \ref{s:sls}, \ref{s:nsc}, \ref{s:mm}\\ +\cmd{Sstackgap}&\ref{s:parms}&\ref{s:st}, \ref{s:stackeng}, \ref{s:asg}, + \ref{s:bbl}, \ref{s:bc}\\ +\cmd{stackalignment}&\ref{s:parms}&\ref{s:sal}, \ref{s:stackeng}, + \ref{s:cae}, \ref{s:lap}\\ +\cmd{stackanchor}&\ref{s:sanc}&\ref{s:csvs}, \ref{s:iis}, \ref{s:sa}, + \ref{s:mm}\\ +\cmd{stackengine}&\ref{s:stackeng}&\ref{s:sou}\\ +\cmd{stackgap}&\ref{s:parms}&\ref{s:stackeng}, \ref{s:sls}\\ +\cmd{stackinset}&\ref{s:iis}&\ref{s:nsg}, \ref{s:ii}, \ref{s:df}\\ +\cmd{stackMath}&\ref{s:sm}&\ref{s:sls}, \ref{s:esm}, \ref{s:mm}\\ +\cmd{stackon}&\ref{s:sou}&\ref{s:asg}, \ref{s:nsg}, \ref{s:uaw}, \ref{s:bm}, + \ref{s:nsc}, \ref{s:mm}\\ +\cmd{stackText}&\ref{s:sm}&\ref{s:mm}\\ +\cmd{stacktype}&\ref{s:parms}&\ref{s:st}, \ref{s:stackeng}, \ref{s:sls}, + \ref{s:sa}, \ref{s:bbl}, \ref{s:bm}, \ref{s:mm}\\ +\cmd{stackunder}&\ref{s:sou}&\ref{s:bm}, \ref{s:nsc}, \ref{s:mm}\\ +\cmd{strutlongstacks}&\ref{s:sm}&\ref{s:csvs}, \ref{s:asg}, \ref{s:ag}\\ +\cmd{strutshortanchors}&\ref{s:sm}&\ref{s:sanc}, \ref{s:sa}, \ref{s:df}\\ +\cmd{tclap}&\ref{s:lapdef}&\ref{s:lap}\\ +\cmd{tllap}&\ref{s:lapdef}&\ref{s:lap}\\ +\cmd{toplap}&\ref{s:lapdef}&\ref{s:lap}\\ +\cmd{trlap}&\ref{s:lapdef}&\ref{s:lap}\\ +\cmd{useanchorwidth}&\ref{s:parms}&\ref{s:stackeng}, \ref{s:bbl}, \ref{s:uaw}\\ +\cmd{Vectorstack}&\ref{s:csvs}&\\ +\cmd{vertVectorstack}&\ref{s:csvs}&\\ +\end{tabular} +} \section{Code Listing} 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 |