| 1 |
\documentclass{article} |
| 2 |
\usepackage{scalerel} |
| 3 |
\usepackage{stackengine} |
| 4 |
\usepackage{verbatimbox} |
| 5 |
\usepackage{boxhandler} |
| 6 |
\parindent 0in\parskip 1em |
| 7 |
\newlength\dotscale |
| 8 |
|
| 9 |
\setlength{\dotscale}{.4ex} % DOTSIZE<---CAN CHANGE THESE |
| 10 |
\def\newdot{\scalerel*{.}{\rule[-\dotscale]{1ex}{\dotscale}}} |
| 11 |
\def\newdot{\scalerel*{.}{\rule{1ex}{\dotscale}}} |
| 12 |
|
| 13 |
% FOR CLOSE-BOXING ARGUMENTS |
| 14 |
\fboxsep=0pt\fboxrule=.6pt |
| 15 |
|
| 16 |
\def\rl{\rule[-.3pt]{2ex}{.6pt}} |
| 17 |
\def\ste{\textsf{stackengine}} |
| 18 |
\def\bs{\texttt{\char'134}} |
| 19 |
\let\vb\verb |
| 20 |
\reversemarginpar |
| 21 |
\marginparwidth 1.6in |
| 22 |
\newcommand\margtt[1]{\marginpar{\hfill\ttfamily#1}} |
| 23 |
\newcommand\margcmd[1]{\marginpar{\hfill\ttfamily\char'134#1}} |
| 24 |
\newcommand\cmd[1]{\texttt{\char'134#1}} |
| 25 |
\def\lapmark{\rule[-.3\baselineskip]{.1ex}{\baselineskip}} |
| 26 |
\def\blmark{\rl\stackengine{-.9ex}{B}{\rule{.35ex}{0pt}L}{U}{l}{F}{T}{S}\rl} |
| 27 |
|
| 28 |
\begin{document} |
| 29 |
|
| 30 |
\begin{center} |
| 31 |
\LARGE The {\ste} Package\\ |
| 32 |
\rule{0em}{.7em}\small Highly customized stacking of objects, insets, |
| 33 |
baseline changes, \textit{etc.}\\ |
| 34 |
\rule{0em}{2.7em}\large Steven B. Segletes\\ |
| 35 |
[email protected]\\ |
| 36 |
\rule{0em}{1.7em}\today\\ |
| 37 |
\stackengineversionnumber% |
| 38 |
\end{center} |
| 39 |
|
| 40 |
%\tableofcontents |
| 41 |
|
| 42 |
\sffamily% |
| 43 |
A sectional index for this package is found in \S\ref{s:index}. |
| 44 |
|
| 45 |
\rmfamily% |
| 46 |
|
| 47 |
\section{Definitions and Terms} |
| 48 |
|
| 49 |
Before I describe the various commands of this package, it is best for |
| 50 |
you to familiarize yourself with a few terms as used in this package. |
| 51 |
|
| 52 |
\subsection{Short Stacks and Long Stacks\label{s:st}} |
| 53 |
\strutshortanchors{T} |
| 54 |
\def\stacktype{L} |
| 55 |
\Huge\setstackgap{S}{.4ex} |
| 56 |
\setstackgap{L}{2.2ex}\normalsize |
| 57 |
|
| 58 |
In this package, ``Short'' refers to squeezing or growing the empty space |
| 59 |
between glyphs comprising the stack, so that the inter-item gap is solely what |
| 60 |
is set. Likewise, ``Long'' refers to a stack kept at constant |
| 61 |
inter-item baseline spacing. Let's look at the following two |
| 62 |
examples to see this clearly. |
| 63 |
|
| 64 |
Notice the consistent inter-item gap between short stack items: |
| 65 |
\Huge |
| 66 |
\Shortstack{{\fbox{t}} {\fbox{y}} {\fbox{k}} {\fbox{e}}}% |
| 67 |
{\quad\setstackgap{S}{\dimexpr.4ex+1.2pt}\Shortstack{t y k e}} |
| 68 |
\normalsize |
| 69 |
|
| 70 |
Notice the consistent inter-baseline spacing on a long stack: |
| 71 |
\Huge |
| 72 |
\Longstack{{{\rl t}} {{\rl y}} {{\rl k}} {{\rl e}}}% |
| 73 |
{\quad\Longstack{t y k e}} |
| 74 |
\normalsize\\ |
| 75 |
|
| 76 |
\begin{sloppypar} |
| 77 |
In this package, the default spacing (\textit{i.e.}, stacklength) for |
| 78 |
the long stack, saved in \vb|\Lstackgap| is the length |
| 79 |
\vb|\normalbaselineskip| (note that \vb|\normalbaselineskip| has the same |
| 80 |
value as \vb|\baselineskip|, but can be safely used inside a \vb|tabular| |
| 81 |
environment). |
| 82 |
For short stacks, the default stacklength, stored in |
| 83 |
\vb|\Sstackgap|, is 3pt, which corresponds to the same spacing found in |
| 84 |
\TeX's \vb|\shortstack| command. The default stack type constructed by |
| 85 |
this package is short, denoted by the definition of \vb|\stacktype| as |
| 86 |
``S'' (as opposed to ``L'' for long stacks). These defaults can be |
| 87 |
changed. |
| 88 |
\end{sloppypar} |
| 89 |
|
| 90 |
\subsection{Baseline} |
| 91 |
\setstackgap{L}{.8\baselineskip} |
| 92 |
\setstackgap{S}{4pt} |
| 93 |
|
| 94 |
The baseline is the horizontal line on which the current (unstacked) |
| 95 |
text is set. For non-descending letters, the bottom of the letters sit |
| 96 |
upon the baseline. In this document, we will graphically use the symbol |
| 97 |
{\blmark} to denote the current baseline of the text, as in |
| 98 |
|
| 99 |
\blmark\rl\Shortunderstack{A B C}\rl\rl text continues here |
| 100 |
|
| 101 |
\subsection{(Over)Stacks and Understacks\label{s:osus}} |
| 102 |
|
| 103 |
\setstackgap{L}{.8\baselineskip} |
| 104 |
\setstackgap{S}{4pt} |
| 105 |
In general terms, a stack is built up from the baseline, while an |
| 106 |
understack is built down from the baseline. |
| 107 |
|
| 108 |
So, for example, |
| 109 |
\Longstack{a b c} |
| 110 |
is a stack, while |
| 111 |
\Longunderstack{a b c} |
| 112 |
is an understack. |
| 113 |
|
| 114 |
With this package, both stacks and understacks can be long or short, |
| 115 |
depending on how the invocation is made. Sometimes, in this |
| 116 |
documentation, a stack will be called an ``overstack'' in order to avoid |
| 117 |
confusion with ``understack.'' |
| 118 |
|
| 119 |
\subsection{Anchors\label{s:anch}} |
| 120 |
|
| 121 |
The term ``anchor'' is used to denote an item in the stack whose |
| 122 |
baseline does not change in the course of the stacking operation. In |
| 123 |
essence, stacking is done relative to the anchor. |
| 124 |
|
| 125 |
For example, in \Shortstack{a b c}, the letter ``c'' is the anchor. |
| 126 |
|
| 127 |
In the understack \Shortunderstack{a b c}, ``a'' is the anchor. |
| 128 |
|
| 129 |
\subsection{Alignment\label{s:sal}} |
| 130 |
|
| 131 |
Anyone familiar with \LaTeX{} knows something about the horizontal |
| 132 |
alignment settings ``l'', ``c'' and ``r''. As pertains to a stack, we |
| 133 |
refer to the alignment of the various rows of the stack, as shown in the |
| 134 |
following examples. |
| 135 |
|
| 136 |
\setstackgap{S}{3pt}\setstackgap{L}{12pt}% |
| 137 |
|
| 138 |
{\centering |
| 139 |
Left: \Shortstack[l]{abcd abc ab a}~~ |
| 140 |
Center: \Shortstack[c]{abcd abc ab a}~~ |
| 141 |
Right: \Shortstack[r]{abcd abc ab a} |
| 142 |
|
| 143 |
} |
| 144 |
The default alignment within a stack may be set with the |
| 145 |
\vb|\stackalignment| definition, to possible values of \vb|l|, |
| 146 |
\vb|c|, or \vb|r|, denoting left, center, and right alignments, |
| 147 |
respectively. In addition, a number of the stacking macros provide the |
| 148 |
alignment as an argument or optional argument that can be specified at |
| 149 |
time of invocation. |
| 150 |
|
| 151 |
The {\ste} package defaults to center alignment, unless reset by way of |
| 152 |
the \vb|\stackalignment| definition. |
| 153 |
|
| 154 |
|
| 155 |
\section{Parameter Defaults, Modes, and Macros Provided by \ste} |
| 156 |
|
| 157 |
|
| 158 |
\subsection{Parameter Defaults and How to Set Them\label{s:parms}} |
| 159 |
|
| 160 |
There are several macros that serve to store package default |
| 161 |
definitions. When a stacking macro does NOT explicitly ask for one of the |
| 162 |
quantities defined by these defaults, it will use the values of these |
| 163 |
parameters to serve as the default value. However, some stacking macros |
| 164 |
may ask the user to specify an explicit value for any number of these |
| 165 |
parameters in the calling arguments. In that case, an explicit value |
| 166 |
may be provided or else the macro holding the default value may |
| 167 |
itself be provided as the argument. |
| 168 |
|
| 169 |
Let us first consider the stackgap defaults, associated with short and |
| 170 |
long stacks. Those stackgaps are actually stored in the \vb|\def|'s |
| 171 |
|
| 172 |
\vb|\Sstackgap|\\ |
| 173 |
\vb|\Lstackgap| |
| 174 |
|
| 175 |
The |
| 176 |
\margcmd{Sstackgap}% |
| 177 |
parameter \vb|\Sstackgap| is the default inter-item gap for any |
| 178 |
stacking command that builds a short stack. It defaults to 3pt. |
| 179 |
Correspondingly, |
| 180 |
\margcmd{Lstackgap} |
| 181 |
\vb|\Lstackgap| is the inter-item baselineskip for |
| 182 |
any stacking command that builds a long stack. It defaults to |
| 183 |
\vb|\normalbaselineskip|. To change these defaults, the following macro |
| 184 |
is provided: |
| 185 |
\margcmd{setstackgap} |
| 186 |
|
| 187 |
\itshape |
| 188 |
\vb|\setstackgap{S}{|inter-item stackgap\vb|}|\\ |
| 189 |
\vb|\setstackgap{L}{|inter-item baselineskip\vb|}| |
| 190 |
\upshape |
| 191 |
|
| 192 |
In \margcmd{stackgap}addition, there is the \vb|\stackgap| macro, which |
| 193 |
may be invoked by the user. This macro will look at the current value |
| 194 |
of \vb|\stacktype| and will output either \vb|\Sstackgap| or |
| 195 |
\vb|\Lstackgap|, depending on whether \vb|\stacktype| is defined as |
| 196 |
``S'' (short) or ``L'' (long). |
| 197 |
|
| 198 |
In addition to these lengths, there are several parameter definitions |
| 199 |
that define default behaviors for those stacking macros when explicit |
| 200 |
values of these settings are not requested. The parameters, each set |
| 201 |
with a \vb|\def| (or a \vb|\renewcommand|), are |
| 202 |
|
| 203 |
\itshape |
| 204 |
\vb|\def\stackalignment{l| or \vb|c| or \vb|r}|\\ |
| 205 |
\vb|\def\quietstack{T| or \vb|F}|\\ |
| 206 |
\vb|\def\useanchorwidth{T| or \vb|F}|\\ |
| 207 |
\vb|\def\stacktype{S| or \vb|L}| |
| 208 |
\upshape |
| 209 |
|
| 210 |
The parameter \vb|\stackalignment| \margcmd{stackalignment}defaults to |
| 211 |
``c'' (center) and defines the default stacking alignment. Other |
| 212 |
options include ``l'' (left) and ``r'' (right). See \S\ref{s:sal} for |
| 213 |
more discussion of this parameter. |
| 214 |
|
| 215 |
The parameter \vb|\quietstack| \margcmd{quietstack}defaults to ``F'' |
| 216 |
(false) and determines whether the result of a stacking operation is |
| 217 |
suppressed from the output. If the output is suppressed by setting this |
| 218 |
parameter to ``T'', the most recent stacking operation may be recovered |
| 219 |
with a \vb|\usebox{\stackedbox}|. See \S\ref{s:qs} for more discussion |
| 220 |
of this parameter. |
| 221 |
|
| 222 |
The parameter \vb|\useanchorwidth| \margcmd{useanchorwidth}defaults to |
| 223 |
``F'' (false) and indicates that, upon creation, the stack width should |
| 224 |
be taken as the widest element of the stack. When set to ``T'', the |
| 225 |
stack width, upon creation, is instead taken as the width of the anchor. |
| 226 |
Note that this parameter applies at the time of stack creation and |
| 227 |
cannot be used to retroactively change the characteristics of an |
| 228 |
existing stack. See \S\ref{s:uaw} for more discussion of this |
| 229 |
parameter. |
| 230 |
|
| 231 |
The parameter \vb|\stacktype| \margcmd{stacktype}defaults to ``S'' |
| 232 |
(short stack) and defines the default type of stack to build. When set |
| 233 |
to ``L'', newly created stacks are, by default, long stacks. Refer to |
| 234 |
\S\ref{s:st} for a definition of these terms. |
| 235 |
|
| 236 |
For macros that require explicit specification of some of these |
| 237 |
parameters, the parameter token itself (\textit{e.g.}, |
| 238 |
\cmd{stackalignment}, \cmd{quietstack}, \textit{etc.}) may be provided |
| 239 |
as the argument, if the default behavior is desired. |
| 240 |
|
| 241 |
\subsection{Stacking Modes\label{s:sm}} |
| 242 |
|
| 243 |
In addition to parameter definitions, there are several {\ste} mode |
| 244 |
settings: |
| 245 |
|
| 246 |
\itshape |
| 247 |
\vb|\stackMath|\qquad \textup{and}\qquad \vb|\lstackMath| |
| 248 |
\quad\textup{(global/local declaration)}\\ |
| 249 |
\vb|\stackText|\qquad \textup{and}\qquad \vb|\lstackText| |
| 250 |
\quad\textup{(global/local declaration)}\\ |
| 251 |
\vb|\strutlongstacks{T| or \vb|F}|\\ |
| 252 |
\vb|\strutshortanchors{T| or \vb|F}|\\ |
| 253 |
\vb|\setstackEOL{|end-of-line character\vb|}| |
| 254 |
\upshape |
| 255 |
|
| 256 |
By default, this package will assume that the arguments of the stacking |
| 257 |
commands are text. However, an invocation of \vb|\stackMath| |
| 258 |
\margcmd{stackMath}will |
| 259 |
change the default so that {\ste} arguments will be processed in inline |
| 260 |
math mode (so-called \vb|\textstyle| math). Likewise, an invocation |
| 261 |
of \vb|\stackText| |
| 262 |
\margcmd{stackText}will reset the default processing of arguments to |
| 263 |
text mode. Both of these modes are global in their scope, so that invocation, |
| 264 |
even within a macro, will continue to persist until later changed. If |
| 265 |
you would like to have a single application stacked in math mode, without |
| 266 |
changing the default mode setting, one could use the \vb|\ensurestackMath{}| |
| 267 |
macro (see \ref{s:esm}), or else the local versions that are scope |
| 268 |
limited, \vb|\lstackMath|\margcmd{lstackMath} and/or |
| 269 |
\vb|\lstackText|\margcmd{lstackText}. |
| 270 |
|
| 271 |
By default, stacks made by {\ste} are set in unframed boxes that are |
| 272 |
flush with the top and bottom of the stack. The \vb|\addstackgap| |
| 273 |
macro (\S\ref{s:asg}) is one way to add a buffer space above and below a stack. |
| 274 |
Such an approach makes more sense for short stacks, where a constant |
| 275 |
buffer size determines the gap between objects. But for long stacks, a |
| 276 |
method involving \vb|\strut|'s makes more sense. The mode |
| 277 |
\vb|\strutlongstacks|% |
| 278 |
\margcmd{strutlongstacks}, when set true (\vb|T|), will automatically |
| 279 |
cause {\ste} to condition each row of a long stack with a \vb|\strut| |
| 280 |
during its construction (see \S\ref{s:ag} for more details). |
| 281 |
|
| 282 |
The \vb|\strutshortanchors| |
| 283 |
\margcmd{strutshortanchors}macro (\S\ref{s:sa}) is used to set the mode of how |
| 284 |
two items may be vertically combined into a split short-stack anchor. |
| 285 |
By default true (\vb|T|), a split short-stack anchor is set so that the |
| 286 |
middle of the stack gap falls halfway up the height of the \vb|\strut|. |
| 287 |
This will give the short-stack anchor the appearance of being split |
| 288 |
relative to text that sits atop the baseline. When set false, however, |
| 289 |
any short-stack anchor that is constructed has its gap split across the |
| 290 |
baseline itself. |
| 291 |
|
| 292 |
Until V3.1 of \ste, the \vb|\Longstack|, \vb|\Shortstack|, |
| 293 |
\vb|\Longunderstack|, and \vb|\Shortunderstack| macros used, |
| 294 |
exclusively, space tokens as the end-of-line separators between |
| 295 |
rows of these stacks. Not only is such a syntax atypical of \LaTeX{}, |
| 296 |
but it can be inconvenient when the items within a stack row |
| 297 |
also contain spaces. The \vb|\setstackEOL| |
| 298 |
\margcmd{setstackEOL}macro allows the end-of-line (EOL) |
| 299 |
character to be defined to a more convenient setting, such as \vb|\\|, |
| 300 |
though any character will work. There is a package option |
| 301 |
\vb|[usestackEOL]| \margtt{[usestackEOL]\rmfamily\\\raggedleft package |
| 302 |
option} which sets the end-of-line symbol to be used when parsing stack |
| 303 |
arguments to \vb|\\|. When the stacking EOL is something other than a |
| 304 |
space token, leading and trailing spaces are ignored in the row data for |
| 305 |
the four cited stacking commands, as well as their derivatives |
| 306 |
\vb|\Centerstack| and \vb|\Vectorstack|. (Note: other stacking commands |
| 307 |
in the \vb|\stackon| / \vb|\stackunder| family will not ignore, but |
| 308 |
retain leading/trailing spaces in their arguments, since there are no |
| 309 |
EOL separators present.) |
| 310 |
|
| 311 |
Note that these five mode-setting commands are not themselves parameters |
| 312 |
to be part of a {\ste} argument, but are instead to be issued as separate |
| 313 |
declarative commands prior to the invocation of a desired stacking macro. |
| 314 |
|
| 315 |
\subsection{Stacking Macros} |
| 316 |
|
| 317 |
\subsubsection{\cmd{stackengine}\label{s:stackeng}} |
| 318 |
|
| 319 |
\begin{sloppypar} |
| 320 |
The basic (and most general) stacking macro provided by this package is |
| 321 |
\vb|\stackengine|. Nearly all other macros of this package merely |
| 322 |
provide an abbreviated invocation form of this macro, tailored for a |
| 323 |
particular application. The syntax is: |
| 324 |
\end{sloppypar} |
| 325 |
|
| 326 |
\itshape |
| 327 |
\vb|\stackengine{\Sstackgap| or |
| 328 |
\vb|\Lstackgap| or |
| 329 |
\vb|\stackgap| or stacklength% |
| 330 |
\vb|}|\\ |
| 331 |
\vb| {|anchor\vb|}|\\ |
| 332 |
\vb| {|item\vb|}|\\ |
| 333 |
\vb| {O| or \vb|U}|\\ |
| 334 |
\vb| {\stackalignment| or |
| 335 |
\vb|l| or |
| 336 |
\vb|c| or |
| 337 |
\vb|r}|\\ |
| 338 |
\vb| {\quietstack| or \vb|T| or \vb|F}|\\ |
| 339 |
\vb| {\useanchorwidth| or \vb|T| or \vb|F}|\\ |
| 340 |
\vb| {\stacktype| or \vb|S| or \vb|L}| |
| 341 |
\upshape |
| 342 |
|
| 343 |
There are no optional arguments with \vb|\stackengine|. The first |
| 344 |
item is a stacking length, which can mean different things depending on |
| 345 |
whether a short- or long-stack is being created, as discussed in |
| 346 |
\S\ref{s:st}. The second argument is the stack anchor, whose |
| 347 |
baseline does not change. The third argument is the item stacked |
| 348 |
relative to the anchor. The fourth argument is either an ``O'' (for a |
| 349 |
normal or overstack) or a ``U'' (for an understack). The fifth argument |
| 350 |
denotes a left, center, or right alignment of the stack items with the |
| 351 |
use of ``l'', ``c'', or ``r''. The sixth argument is either a ``T'' or |
| 352 |
``F'' to denote whether the resulting stack is NOT printed (``T'' |
| 353 |
denotes ``do NOT print''). The seventh argument, also a ``T'' or an |
| 354 |
``F'', denotes when ``T'' that the width of the whole stack is to be |
| 355 |
taken as the width of the anchor. Otherwise, the width of the stack |
| 356 |
conforms to the width of the widest item in the stack. The final |
| 357 |
argument is defined as either an ``S'' or an ``L'' to denote whether a |
| 358 |
short stack or a long stack is being requested. |
| 359 |
|
| 360 |
While none of the arguments to \vb|\stackengine| have default values, |
| 361 |
there are various definitions in the package that store default values. |
| 362 |
When one wishes a stack to possess certain default properties, these |
| 363 |
default definitions may be passed as the values for the respective |
| 364 |
arguments to \vb|\stackengine|. Arguments 1, 5, 6, 7, and 8 each |
| 365 |
possess a corresponding parameter containing the default variable. So, |
| 366 |
for example, |
| 367 |
|
| 368 |
\begin{verbatim} |
| 369 |
\stackengine{\stackgap}{A}{BC}{O}{\stackalignment} |
| 370 |
{\quietstack}{\useanchorwidth}{\stacktype} |
| 371 |
\end{verbatim} |
| 372 |
|
| 373 |
will stack the letters ``BC'' over ``A'' using the default values of |
| 374 |
\vb|\stackalignment|, \vb|\quietstack|, \vb|\useanchorwidth|, |
| 375 |
and \vb|\stacktype|. In addition, the stackgap will be set to |
| 376 |
\vb|\Sstackgap| if \vb|\stacktype| is ``S'' or to \vb|\Lstackgap| |
| 377 |
if \vb|\stacktype| is ``L''. Alternately, the same stack could be |
| 378 |
forced to be a long stack with right-alignment and be typeset using |
| 379 |
|
| 380 |
\begin{verbatim} |
| 381 |
\stackengine{\Lstackgap}{A}{BC}{O}{r}{F}{\useanchorwidth}{L} |
| 382 |
\end{verbatim} |
| 383 |
\vspace{-0.8ex} |
| 384 |
|
| 385 |
While the stacking macros in the following sections offer the convenience |
| 386 |
of a condensed syntax, which can be useful within your document, it may be |
| 387 |
preferable to use the \vb|\stackengine| macro to create your own |
| 388 |
stacking macros, since one can achieve the stacking result regardless of |
| 389 |
how the package defaults are set. |
| 390 |
|
| 391 |
\subsubsection{\cmd{stackon} and \cmd{stackunder}\label{s:sou}} |
| 392 |
|
| 393 |
The \vb|\stackon| and \vb|\stackunder| macros are abbreviated forms |
| 394 |
of \vb|\stackengine| in which the default values of parameters are |
| 395 |
taken. The only exception is the stacklength, which may be provided as |
| 396 |
an optional argument. |
| 397 |
|
| 398 |
\itshape |
| 399 |
\vb|\stackon[|stacklength% |
| 400 |
\vb|]{|anchor% |
| 401 |
\vb|}{|item% |
| 402 |
\vb|}|\\ |
| 403 |
\vb|\stackunder[|stacklength% |
| 404 |
\vb|]{|anchor% |
| 405 |
\vb|}{|item% |
| 406 |
\vb|}| |
| 407 |
\upshape |
| 408 |
|
| 409 |
In the case of \vb|\stackon|, an (over)stack is created, whereas an |
| 410 |
understack is created with \vb|\stackunder|. With both of these |
| 411 |
commands, the anchor is the first mandatory argument, and the item to be |
| 412 |
stacked above or below it is the second mandatory argument.\vspace{-0.8ex} |
| 413 |
|
| 414 |
\subsubsection{\cmd{Shortstack} and \cmd{Longstack}\label{s:sls}} |
| 415 |
|
| 416 |
The \vb|\Shortstack| and \vb|\Longstack| commands are stacking commands |
| 417 |
that allow more than two stacking rows to be specified at once. The |
| 418 |
items of a stack are provided, by default, in a space-separated list, as |
| 419 |
follows: |
| 420 |
|
| 421 |
\itshape |
| 422 |
\vb|\Shortstack[|alignment% |
| 423 |
\vb|]{|item % |
| 424 |
\vb|{|it em% |
| 425 |
\vb|} {\|item% |
| 426 |
\vb|} $|item% |
| 427 |
\vb|$| ... anchor% |
| 428 |
\vb|}|\\ |
| 429 |
\vb|\Longstack[|alignment% |
| 430 |
\vb|]{|item % |
| 431 |
\vb|{|it em% |
| 432 |
\vb|} {\|item% |
| 433 |
\vb|} $|item% |
| 434 |
\vb|$| ... anchor% |
| 435 |
\vb|}| |
| 436 |
\upshape |
| 437 |
|
| 438 |
The first item is at the top of the stack, farthest from the baseline, |
| 439 |
while the last item is the anchor of the stack. If an item (the |
| 440 |
contents of a single row) contains spaces, enclose the item in braces. |
| 441 |
If the item ends with a macro, enclose the item in braces. |
| 442 |
If used in a mixed text/math mode (see \S\ref{s:mm} for more |
| 443 |
details), math items may be enclosed within dollar-sign delimiters. As of |
| 444 |
V3.2, these commands have been made robust and their arguments need |
| 445 |
not be \verb|\protect|ed. |
| 446 |
|
| 447 |
The alignment may be specified as an optional argument, with other |
| 448 |
parameters taken by their defaults. The stacklength is taken as |
| 449 |
\vb|\stackgap|, which will depend on the value of \vb|\stacktype|. |
| 450 |
|
| 451 |
To give an example of the braced syntax described above, |
| 452 |
the stack\\ |
| 453 |
\vb|\Shortstack[r]{a {b c} {\P} $\beta^2$ ANCHOR}| |
| 454 |
will produce |
| 455 |
\Shortstack[r]{a {b c} {\P} $\beta^2$ ANCHOR}. Note that the use of the |
| 456 |
math delimiter (\vb|$|) in the \vb|\Shortstack| argument was needed |
| 457 |
only if the stack contains both inline math as well as text elements. |
| 458 |
If the stack is to contain only math-mode elements, then math arguments |
| 459 |
can be made the default:\\ |
| 460 |
\vb|\stackMath|% |
| 461 |
\vb|\Shortunderstack[c]{{\alpha} {\beta} {\gamma}}|\\ |
| 462 |
yielding |
| 463 |
\stackMath |
| 464 |
\Shortunderstack[c]{{\alpha} {\beta} {\gamma}}\. |
| 465 |
\stackText |
| 466 |
|
| 467 |
As of V3.1 of \ste, the user may define the the argument to |
| 468 |
\vb|\Longstack|, \vb|\Shortstack|, \vb|\Longunderstack|, and |
| 469 |
\vb|\Shortunderstack| with a row separator different than a space. |
| 470 |
The \vb|[usestackEOL]| package option will make the EOL character within |
| 471 |
these stacking commands a \vb|\\| macro instead of a space. Here |
| 472 |
is an example of equivalent stack arguments for two different EOL |
| 473 |
characters: |
| 474 |
|
| 475 |
Space EOL:~~~~\vb|{a {b c} {\P} $\beta^2$ ANCHOR}|\\ |
| 476 |
\vb|\\| EOL:~~~~~~~~\,\vb|{a \\ b c \\ \P \\ $\beta^2$ \\ ANCHOR}| |
| 477 |
|
| 478 |
Note that leading and trailing spaces surrounding the \verb|\\| are ignored |
| 479 |
for rows in the second |
| 480 |
case. The \vb|\setstackEOL| macro allows any arbitrary character to be |
| 481 |
set as the ``EOL'' character (for the purposes of parsing these |
| 482 |
stacking macros). |
| 483 |
|
| 484 |
\subsubsection{\cmd{Shortunderstack} and \cmd{Longunderstack}\label{s:slus}} |
| 485 |
|
| 486 |
The \vb|\Shortunderstack| and \vb|\Longunderstack| commands are the |
| 487 |
understacking equivalents of \vb|\Shortstack| and \vb|\Longstack|. |
| 488 |
|
| 489 |
\itshape |
| 490 |
\vb|\Shortunderstack[|alignment% |
| 491 |
\vb|]{|anchor item % |
| 492 |
\vb|{|it em% |
| 493 |
\vb|} {\|item% |
| 494 |
\vb|} $|item% |
| 495 |
\vb|$| ...% |
| 496 |
\vb|}|\\ |
| 497 |
\vb|\Longunderstack[|alignment% |
| 498 |
\vb|]{|anchor item % |
| 499 |
\vb|{|it em% |
| 500 |
\vb|} {\|item% |
| 501 |
\vb|} $|item% |
| 502 |
\vb|$| ...% |
| 503 |
\vb|}| |
| 504 |
\upshape |
| 505 |
|
| 506 |
The caveats to the specification of the space-separated list of items is |
| 507 |
the same as that mentioned above for \vb|\Shortstack| and |
| 508 |
\vb|\Longstack|. |
| 509 |
|
| 510 |
Note that the items are still specified from the top downward. |
| 511 |
In the case of understacks; however, that means that the anchor is the |
| 512 |
first item specified, while the last item in the list is farthest below |
| 513 |
the baseline. |
| 514 |
|
| 515 |
\subsubsection{Top and bottom lapping macros\label{s:lapdef}} |
| 516 |
|
| 517 |
\tclap{\smash{Top}}and \bclap{bottom}~lapping is achievable through the creation of various |
| 518 |
long stacks. The syntax is the same for all six of the macros provided. |
| 519 |
The six names differentiate whether the lap is to the top (t) or the |
| 520 |
bottom (b) of the calling point, and whether it should appear to the |
| 521 |
left (l), centered (c), or to the right (r) of the calling location. |
| 522 |
The long-stacklength may be provided as an optional argument. |
| 523 |
|
| 524 |
\itshape |
| 525 |
\vb|\tllap[|stacklength\vb|]{|item\vb|}|\\ |
| 526 |
\vb|\tclap[|stacklength\vb|]{|item\vb|}|\\ |
| 527 |
\vb|\trlap[|stacklength\vb|]{|item\vb|}|\\ |
| 528 |
\vb|\bllap[|stacklength\vb|]{|item\vb|}|\\ |
| 529 |
\vb|\bclap[|stacklength\vb|]{|item\vb|}|\\ |
| 530 |
\vb|\brlap[|stacklength\vb|]{|item\vb|}| |
| 531 |
\upshape |
| 532 |
|
| 533 |
See \S\ref{s:lap} for more information and examples of use for |
| 534 |
these lapping commands. If trying to remember the names of all these |
| 535 |
lapping commands is too tedious for you, two functionally identical |
| 536 |
macros have been introduced: |
| 537 |
|
| 538 |
\itshape |
| 539 |
\vb|\toplap[|stacklength\vb|]{|lap H-direction\vb|}{|item\vb|}|\\ |
| 540 |
\vb|\bottomlap[|stacklength\vb|]{|lap H-direction\vb|}{|item\vb|}| |
| 541 |
\upshape |
| 542 |
|
| 543 |
The names are simpler to remember, but they require, as their first |
| 544 |
mandatory argument, the horizontal direction of lapping (l, c, or r), |
| 545 |
while the material to be lapped is now in the second mandatory argument. |
| 546 |
\vspace{-0.8ex} |
| 547 |
|
| 548 |
\subsubsection{\cmd{stackanchor}\label{s:sanc}} |
| 549 |
|
| 550 |
The \vb|\stackanchor| macro is one way to create a stack where the |
| 551 |
baseline is split between two items in the stack. The syntax is |
| 552 |
|
| 553 |
\itshape |
| 554 |
\vb|\stackanchor[|stackgap% |
| 555 |
\vb|]{|top item% |
| 556 |
\vb|}{|bottom item% |
| 557 |
\vb|}| |
| 558 |
\upshape |
| 559 |
|
| 560 |
The stacking gap may be provided as an optional argument. All other |
| 561 |
parameters taken are the defaults. There are subtle differences in the |
| 562 |
way a short stack anchor versus a long stack anchor is split. |
| 563 |
One should consult \S\ref{s:sa} for a description of how the |
| 564 |
stack is constructed. |
| 565 |
|
| 566 |
If a short stack is being created with a split anchor, the |
| 567 |
\vb|\strutshortanchors{}| mode setting will determine whether the split |
| 568 |
occurs at the mid-height of the strutbox (``T'') or whether it will |
| 569 |
occur about the baseline (``F''). |
| 570 |
|
| 571 |
If a long stack is to be created with a split anchor, it is best to |
| 572 |
formulate and \vb|\savestack| both the upper portion (with a stack) |
| 573 |
and the lower portion (with an understack), and then \vb|\stackanchor| |
| 574 |
the two parts together. Alternately, one could use the |
| 575 |
\vb|\Centerstack| macro (\S\ref{s:csvs}). |
| 576 |
|
| 577 |
\subsubsection{\cmd{Centerstack} and the math variants of |
| 578 |
\cmd{Vectorstack}\label{s:csvs}} |
| 579 |
|
| 580 |
The macro \cmd{Centerstack} produces a type of \cmd{Longstack} that is |
| 581 |
vertically centered about the mid-strut above the baseline. In essence, |
| 582 |
it is like a \cmd{stackanchor} version of a \cmd{Longstack}. Additionally, |
| 583 |
it is locally processed with the mode \cmd{strutlongstacks} set as |
| 584 |
\verb|T|, so as to ensure |
| 585 |
the proper vertical centering. |
| 586 |
|
| 587 |
The \vb|\Centerstack| macro has a math-mode equivalent called |
| 588 |
\cmd{Vectorstack}, in which the stacking argument |
| 589 |
is automatically processed in math mode, regardless if whether the \cmd{stackMath} |
| 590 |
mode is currently active. |
| 591 |
|
| 592 |
The syntax is the same as \vb|\Longstack|, except that the anchor is |
| 593 |
not specified, but results naturally from the centering operation: |
| 594 |
|
| 595 |
\itshape |
| 596 |
\vb|\Centerstack[|alignment% |
| 597 |
\vb|]{|item % |
| 598 |
\vb|{|it em% |
| 599 |
\vb|} {\|item% |
| 600 |
\vb|} $|item% |
| 601 |
\vb|$| ... item% |
| 602 |
\vb|}|\\ |
| 603 |
\vb|\Vectorstack[|alignment% |
| 604 |
\vb|]{|item % |
| 605 |
\vb|{|it em% |
| 606 |
\vb|} {\|item% |
| 607 |
\vb|}| ... item% |
| 608 |
\vb|}| |
| 609 |
\upshape |
| 610 |
|
| 611 |
One of the main purposes of providing this vertically centered stack is |
| 612 |
to be compatible with mathematical bracketing commands embodied in |
| 613 |
the use of the \LaTeX{} syntax \vb|\left(...\right)|, which require |
| 614 |
vertically centered material. To this end, there |
| 615 |
are several variants of \vb|\Vectorstack| macro that are for specific |
| 616 |
use in mathmode. Here are examples of all of these macros demonstrated: |
| 617 |
|
| 618 |
{\centering |
| 619 |
\Centerstack{p q r s} |
| 620 |
\Vectorstack{p q r s} |
| 621 |
$\parenVectorstack{p q r s}$ |
| 622 |
$\bracketVectorstack{p q r s}$ |
| 623 |
$\braceVectorstack{p q r}$ |
| 624 |
$\vertVectorstack{p q r}$.\par} |
| 625 |
which are, respectively,\\ |
| 626 |
\vb|\Centerstack{p q r s}|\\ |
| 627 |
\vb|\Vectorstack{p q r s}|\\ |
| 628 |
\vb|$\parenVectorstack{p q r s}$|\\ |
| 629 |
\vb|$\bracketVectorstack{p q r s}$|\\ |
| 630 |
\vb|$\braceVectorstack{p q r}$.|\\ |
| 631 |
\vb|$\vertVectorstack{p q r}$.| |
| 632 |
|
| 633 |
|
| 634 |
\subsubsection{\cmd{ensurestackMath}\label{s:esm}} |
| 635 |
|
| 636 |
The macro \vb|\ensurestackMath{}| macro is used to force its argument |
| 637 |
(a stacking command) to be processed in math mode, without setting |
| 638 |
the global default stacking |
| 639 |
mode to math mode (accomplished via \vb|\stackMath|). Note |
| 640 |
that this macro does \textbf{not} ensure that |
| 641 |
all elements of its argument are processed in math mode (\textit{i.e.}, |
| 642 |
it does not use, nor is it a replacement for \vb|\ensuremath|), but |
| 643 |
only that stacking macros are processed in math mode. |
| 644 |
|
| 645 |
\subsubsection{\cmd{abovebaseline} and \cmd{belowbaseline}\label{s:abb}} |
| 646 |
|
| 647 |
The macros \vb|\abovebaseline| and \vb|\belowbaseline| also creates the |
| 648 |
means to shift an item's baseline. The syntax is |
| 649 |
|
| 650 |
\itshape |
| 651 |
\vb|\abovebaseline[|stackgap\vb|]{|item\vb|}|\\ |
| 652 |
\vb|\belowbaseline[|stackgap\vb|]{|item\vb|}| |
| 653 |
\upshape |
| 654 |
|
| 655 |
where the stackgap defines the stackgap distance. In a long stack, it |
| 656 |
will define the upward (for \vb|\abovebaseline|) or downward shift |
| 657 |
(for \vb|\belowbaseline|) of the baseline of the item. In a short |
| 658 |
stack, it will define the upward/downward vertical gap between the |
| 659 |
original baseline and the bottom/top of the shifted item. |
| 660 |
|
| 661 |
For long stacks, a negative stackshift for \vb|\belowbaseline| will |
| 662 |
produce the same result as the corresponding positive stackshift for |
| 663 |
\vb|\abovebaseline|. But this will not be the case for short stacks. |
| 664 |
One should consult \S\ref{s:bbl} for more details. |
| 665 |
|
| 666 |
This command can also be employed to redefine the baseline of graphical |
| 667 |
objects, which can provide a useful technique to achieve horizontal |
| 668 |
alignment with other objects. Negative stack gaps are valid (see |
| 669 |
\S\ref{s:bbl} for examples). While these macros will carry slightly |
| 670 |
more processing overhead than a simple \vb|\raisebox|, it may be the |
| 671 |
case that specifying the shift in terms of the baseline, rather than |
| 672 |
with respect to the current configuration, may make for more |
| 673 |
streamlined logic. |
| 674 |
|
| 675 |
\subsubsection{\cmd{stackinset}\label{s:iis}} |
| 676 |
|
| 677 |
The macro \vb|\stackinset| is for insetting |
| 678 |
smaller items (\textit{e.g.}, images or text) inside of a larger background |
| 679 |
items (\textit{e.g.}, images or text). The syntax is |
| 680 |
|
| 681 |
\itshape |
| 682 |
\vb|\stackinset{|H-align% |
| 683 |
\vb|}{|H-offset% |
| 684 |
\vb|}{|V-align% |
| 685 |
\vb|}{|V-offset% |
| 686 |
\vb|}{|inset item% |
| 687 |
\vb|}{|anchor item\vb|}| |
| 688 |
\upshape |
| 689 |
|
| 690 |
In addition to providing the inset and background items as the last two |
| 691 |
arguments, the inset may be vertically and horizontally offset relative |
| 692 |
to various references. The first argument \textit{H-align}, is either |
| 693 |
an \vb|l|, \vb|c|, or \vb|r|, indicating whether the horizontal offset |
| 694 |
is relative to the left, center, or right of the anchor. The second |
| 695 |
argument is a length corresponding to the actual horizontal offset, |
| 696 |
relative to the horizontal alignment. For \vb|l| and \vb|c| alignments, |
| 697 |
a positive horizontal offset is rightward, whereas it is leftward for |
| 698 |
a \vb|r| alignment. |
| 699 |
|
| 700 |
In the case of vertical measures, the third argument, \textit{V-align}, |
| 701 |
can have values of \vb|t|, \vb|c|, or \vb|b|, corresponding to top, |
| 702 |
center, and bottom, respectively. The fourth argument is a length |
| 703 |
corresponding to the vertical offset from the alignment location. |
| 704 |
For \vb|b| and \vb|c| alignments, a positive vertical offset is upward, |
| 705 |
whereas it is downward for a \vb|t| alignment. |
| 706 |
|
| 707 |
For horizontal and vertical offsets, negative lengths are allowed. |
| 708 |
However, this macro is always executed with the \vb|\usestackanchor| |
| 709 |
parameter set as true (meaning that the resultant stack will be the |
| 710 |
horizontal size of the anchor, even if the inset spills outside of it). |
| 711 |
|
| 712 |
While this command was designed with inlaid images in mind (see |
| 713 |
\S\ref{s:ii}), there is nothing that prevents its use to inlay |
| 714 |
character glyphs upon each other, as in |
| 715 |
\stackinset{c}{}{c}{-.3ex}{*}{O}, accomplished with |
| 716 |
\vb|\stackinset{c}{}{c}{-.3ex}{*}{O}|. |
| 717 |
|
| 718 |
\subsubsection{\cmd{addstackgap}\label{s:asg}} |
| 719 |
\def\stacktype{S} |
| 720 |
|
| 721 |
The \vb|\addstackgap| macro provides a user-requested feature to add a |
| 722 |
specified gap above and below an object. The syntax is |
| 723 |
|
| 724 |
\itshape |
| 725 |
\vb|\addstackgap[|% |
| 726 |
stackgap% |
| 727 |
\vb|]{|% |
| 728 |
item% |
| 729 |
\vb|}| |
| 730 |
\upshape |
| 731 |
|
| 732 |
When a stack is otherwise created, it by default will vertically extend |
| 733 |
from the top of the top-most item in the stack to the bottom of the |
| 734 |
bottom-most item in the stack, but with no extra gap applied. Depending |
| 735 |
on how the user employs that stack, there may not be enough vertical gap |
| 736 |
between the stack and its adjacent objects. This macro will apply a |
| 737 |
fixed gaplength (either specified or, by default, an amount given by |
| 738 |
\vb|\Sstackgap|) above and below the argument of the macro. Negative |
| 739 |
gaps will have no effect on the vertical extent of the item. |
| 740 |
|
| 741 |
Here's an example of a stack, before and after \vb|\addstackgap| is |
| 742 |
applied, framed for clarity: |
| 743 |
\vb|\stackon{g}{a}|: \fbox{\stackon{g}{a}} versus |
| 744 |
\vb|\addstackgap{\stackon{g}{a}}| \fbox{\addstackgap{\stackon{g}{a}}}. |
| 745 |
This macro provides a slightly different result than the |
| 746 |
\vb|\strutlongstacks| mode described in \S\ref{s:sm}. For more details |
| 747 |
of the comparison, see \S\ref{s:ag}. |
| 748 |
|
| 749 |
\subsubsection{\cmd{hsmash}\label{s:hsm}} |
| 750 |
\def\stacktype{L} |
| 751 |
|
| 752 |
The macro \vb|\hsmash| is a horizontal version of the popular |
| 753 |
\vb|\smash| macro: |
| 754 |
|
| 755 |
\itshape |
| 756 |
\vb|\hsmash{|item\vb|}| |
| 757 |
\upshape |
| 758 |
|
| 759 |
In this case, the result is centered over its zero-width anchor |
| 760 |
position. If one wanted left or right aligned versions of this macro, |
| 761 |
the existing \LaTeX{} macros \vb|\rlap| and \vb|\llap| would suffice. |
| 762 |
|
| 763 |
The primary utility of this macro is in applying \vb|\hsmash| to an |
| 764 |
object (often wider than the \vb|\textwidth|), in order to extend the |
| 765 |
object into the margins in a controllable manner, such as in the case of |
| 766 |
these items below: |
| 767 |
|
| 768 |
{\centering\hsmash{\fbox{\stackon[3pt]{% |
| 769 |
\rule{1.1\textwidth}{.1ex}}{wide object}}}\par} |
| 770 |
|
| 771 |
\hsmash{\rule{5ex}{1ex}}\hfill\hsmash{\rule{2ex}{0ex}\rule{5em}{1ex}} |
| 772 |
|
| 773 |
\subsubsection{\cmd{savestack}\label{s:ss}} |
| 774 |
|
| 775 |
The macro \vb|\savestack| provides a means to save an intermediate |
| 776 |
result (in a box that can be recalled with the specified macro) without |
| 777 |
printing it. Its syntax is |
| 778 |
|
| 779 |
\itshape |
| 780 |
\vb|\savestack{|macro token\vb|}{|stacking operation\vb|}| |
| 781 |
\upshape |
| 782 |
|
| 783 |
The macro token is a backslashed name that you can later use to recall |
| 784 |
the boxed intermediate result. The stacking operation is the |
| 785 |
intermediate result you wish to save in a box without printing. Reasons |
| 786 |
why this might be a useful macro are described in \S\ref{s:svs}. |
| 787 |
|
| 788 |
Note that while \vb|\savestack| is designed to save an intermediate |
| 789 |
stacking operation in a box, the reality is that you can use this macro |
| 790 |
to save any sequence of boxable output, even if it is not a stacking |
| 791 |
operation. So, for example, \vb|\savestack{\mymacro}{\fbox{A}}| can |
| 792 |
later be recalled with an invocation of \vb|\mymacro|, to yield |
| 793 |
\fboxsep=1pt\savestack{\mymacro}{\fbox{A}}\mymacro.\fboxsep=0pt |
| 794 |
|
| 795 |
\section{Making a Stack in Stages} |
| 796 |
|
| 797 |
There are times where one needs to make a stack in several consecutive |
| 798 |
steps. In order to do so, there are several ways, detailed below. |
| 799 |
|
| 800 |
\subsection{Suppressing Output\label{s:qs}} |
| 801 |
|
| 802 |
One can define \vb|\quietstack| as \vb|T| to suppress output. Then, the |
| 803 |
intermediate stack can be passed as an argument to the next stacking |
| 804 |
operation with a \vb|\usebox{\stackedbox}|. That same \vb|\usebox| |
| 805 |
may be used to output the final stack, as long as \vb|\quietstack| |
| 806 |
remains defined as ``T''. Otherwise, \vb|\quietstack| must again be |
| 807 |
defined ``F'' (false) to re-enable automatic output. |
| 808 |
|
| 809 |
\subsection{Saving a Stack without Printing It\label{s:svs}} |
| 810 |
|
| 811 |
Perhaps a quicker and better way is to use the package's |
| 812 |
\vb|\savestack| macro, of the form |
| 813 |
\itshape\vb|\savestack{|macro token\vb|}{|stacking operation\vb|}| |
| 814 |
\upshape. This will perform the stacking operation and place it into |
| 815 |
the supplied token (without printing it), so that the intermediate stack |
| 816 |
can be passed to the subsequent stacking operation by executing the |
| 817 |
token macro. |
| 818 |
|
| 819 |
For example, |
| 820 |
\begin{verbatim} |
| 821 |
\savestack{\pdq}{\Longstack[r]{6 5 4 {3 3}}}% |
| 822 |
\Longstack[l]{{\pdq} 2 1 0}% |
| 823 |
\end{verbatim} |
| 824 |
|
| 825 |
would first place ``\Longstack[r]{6 5 4 {3 3}}'' into \vb|\pdq|, without |
| 826 |
printing it, in a right-aligned fashion, with the ``3 3'' on the |
| 827 |
baseline. Then, the second \vb|\Longstack| would place the first stack |
| 828 |
atop of the ``2'' in a left-aligned fashion. The resulting stack would |
| 829 |
look as follows, with the ``0'' on the final baseline. |
| 830 |
|
| 831 |
\savestack{\pdq}{\Longstack[r]{6 5 4 {3 3}}}% |
| 832 |
\Longstack[l]{{\pdq} 2 1 0} |
| 833 |
\rl\rl\blmark% |
| 834 |
|
| 835 |
\section{Choosing the Anchor Element\label{s:cae}} |
| 836 |
|
| 837 |
Nearly all stacking done with the \textsf{stackengine} package has |
| 838 |
a designated anchor element. The baseline of the anchor does not |
| 839 |
change. Instead, the other items are placed relative to the anchor. |
| 840 |
By adding items at first above and then below the anchor, any |
| 841 |
arbitrary stack can be built around the anchor. |
| 842 |
|
| 843 |
\def\stackalignment{r} |
| 844 |
\setstackgap{S}{2pt}\setstackgap{L}{12pt}% |
| 845 |
Here is a Longstack/understack example: |
| 846 |
\savestack{\pdq}{\Longstack{3 2 1 0}}% |
| 847 |
\Longunderstack[r]{{\pdq} -1 -2 -3 -4 -5} |
| 848 |
that was achieved as follows: |
| 849 |
|
| 850 |
\begin{verbatim} |
| 851 |
\savestack{\pdq}{\Longstack{3 2 1 0}}% |
| 852 |
\Longunderstack[r]{{\pdq} -1 -2 -3 -4 -5} |
| 853 |
\end{verbatim} |
| 854 |
|
| 855 |
In the first stack, ``0'' is the anchor of \vb|\pdq|. In the second |
| 856 |
stack, \vb|\pdq| is the anchor (which means that ``0'' remains the |
| 857 |
anchor of the composite stack). |
| 858 |
|
| 859 |
\section{Top and Bottom Lapping\label{s:lap}} |
| 860 |
\def\stackalignment{c} |
| 861 |
\def\stacktype{L}% |
| 862 |
\setstackgap{L}{\baselineskip} |
| 863 |
Top and bottom lapping can be accomplished with a long stack, using a null |
| 864 |
item as the anchor, and \vb|\useachorwidth| set to \vb|T|. This |
| 865 |
technique is encoded in six \vb|\|\textit{xy}\vb|lap| commands, |
| 866 |
where \textit{x} can be \vb|t| or \vb|b| (for ``top'' and |
| 867 |
``bottom,'' respectively) and \textit{y} can be \vb|l|, \vb|c|, or |
| 868 |
\vb|r| (for ``left,'' ``center,'' and ``right,'' respectively). Note |
| 869 |
that this \textit{y} is not the same as the \vb|\stackalignment|, but |
| 870 |
rather refers to the direction where the lapped item is placed relative |
| 871 |
to the lap invocation. |
| 872 |
|
| 873 |
For illustration only, laps will be shown at a \textit{visible} lapmark |
| 874 |
(given by \lapmark~), defining the point of invocation. In these |
| 875 |
examples, I lap a \vb|\parbox| above or below the selected location. |
| 876 |
|
| 877 |
\begin{myverbbox}{\bll}\bllap\end{myverbbox} |
| 878 |
\begin{myverbbox}{\brl}\brlap\end{myverbbox} |
| 879 |
\begin{myverbbox}{\tll}\tllap\end{myverbbox} |
| 880 |
\begin{myverbbox}{\trl}\trlap\end{myverbbox} |
| 881 |
\begin{myverbbox}{\bcl}\bclap\end{myverbbox} |
| 882 |
\begin{myverbbox}{\tcl}\tclap\end{myverbbox} |
| 883 |
For example here\lapmark% |
| 884 |
\bllap{\parbox[t]{.7in}{this is a bottom-left lap \bll}} |
| 885 |
or el\lapmark% |
| 886 |
\brlap{\parbox[t]{.8in}{this is a bottom-right lap \brl}}% |
| 887 |
se here, or else I can put it here\lapmark% |
| 888 |
\tllap{\parbox[b]{.7in}{this is a top-left lap \tll}} |
| 889 |
or here\lapmark% |
| 890 |
\trlap{\parbox[b]{.7in}{this is a top-right lap \trl}}% |
| 891 |
.\ |
| 892 |
|
| 893 |
Of course, I can per\lapmark |
| 894 |
\bclap{\fbox{\parbox[t]{1.1in}{this is a bottom-center lap \bcl}}}% |
| 895 |
form center lapping, as we\lapmark% |
| 896 |
\tclap{\fbox{\parbox[b]{1.1in}{this is a top-center lap \tcl}}}% |
| 897 |
ll. |
| 898 |
To see, for example, how the above was achieved, the last lap in the |
| 899 |
prior sentence was achieved by invoking |
| 900 |
|
| 901 |
\vb|\tclap{\fbox{\parbox[b]{1.1in}{this is a top-center lap \tcl}}}| |
| 902 |
|
| 903 |
in the middle of the word ``well.'' (Note that \vb|\tcl| is a box |
| 904 |
containing the verbatim text ``\tcl,'' created with the |
| 905 |
\textsf{verbatimbox} package.) |
| 906 |
|
| 907 |
Note that \vb|\toplap| and \vb|\bottomlap| have also been introduced |
| 908 |
as macros that are functionally identical to these six lapping commands. |
| 909 |
While requiring an extra argument, their names may be easier for you to |
| 910 |
remember. See \S\ref{s:lapdef}.\vspace{-1ex} |
| 911 |
|
| 912 |
\section{Shifting the Anchor's Baseline} |
| 913 |
|
| 914 |
By default, the baseline of the anchor becomes the baseline of the |
| 915 |
stack. If one wanted the stack baseline to \textbf{not} conform to |
| 916 |
the baseline of any of the individual stacked items, something needs |
| 917 |
to change. If one quantitatively knows the shift desired, a simple |
| 918 |
\vb|\raisebox| could be used to vertically shift the anchor, after |
| 919 |
(or possibly prior to) stacking. There are also some other options |
| 920 |
provided by the package. |
| 921 |
|
| 922 |
\subsection{The \cmd{stackanchor} Macro for ``L'' and ``S'' Stack Types% |
| 923 |
\label{s:sa}} |
| 924 |
|
| 925 |
If one would like the anchor's baseline to be ``midway'' between two |
| 926 |
vertically arrayed items, the \vb|\stackanchor| macro attempts to |
| 927 |
provide that capability for both ``L'' and ``S'' stack types, though the |
| 928 |
definitions of ``midway'' are different for each. The macro |
| 929 |
\vb|\stackanchor| works for two-item stacks in both ``L'' and ``S'' |
| 930 |
stack types, as shown below. |
| 931 |
|
| 932 |
In the case on a long stack, what is satisfied is that the baseline of |
| 933 |
the anchor is made equidistant from the baselines of the two respective |
| 934 |
items comprising the stacked anchor. |
| 935 |
|
| 936 |
\def\stacktype{L}% |
| 937 |
|
| 938 |
\Large |
| 939 |
\def\stackalignment{r}% |
| 940 |
\setstackgap{L}{.8\baselineskip}% |
| 941 |
\blmark% |
| 942 |
\rl\rl |
| 943 |
\stackanchor{\rl\rl\rl\rl top\rl}{\rl L-bottom\rl}% |
| 944 |
\rl\rl% |
| 945 |
\blmark |
| 946 |
\normalsize |
| 947 |
|
| 948 |
In the case of a short stack, the middle of the inter-item gap is |
| 949 |
vertically located at the center of the font's \vb|\strutbox|, so that |
| 950 |
the middle of the stackgap would be at the same vertical level as the |
| 951 |
middle of parentheses, were they located on the original baseline. |
| 952 |
|
| 953 |
\Large |
| 954 |
\blmark\rl\rl% |
| 955 |
\def\rls{\rule[.5\ht\strutbox-.5\dp\strutbox]{2ex}{.1pt}}% |
| 956 |
\rls% |
| 957 |
\def\stackalignment{l}% |
| 958 |
\def\stacktype{S}\setstackgap{S}{1ex}% |
| 959 |
\savestack{\pdq}{\stackanchor{\fbox{top}}{\fbox{S-bottom}}}% |
| 960 |
\pdq% |
| 961 |
\rls% |
| 962 |
(Mid-strut)% |
| 963 |
\rl\rl\blmark |
| 964 |
\def\stackalignment{c}% |
| 965 |
\normalsize% |
| 966 |
|
| 967 |
If one does not want to have the short-stack gap split at the mid-strut |
| 968 |
height, but rather at the baseline, the \vb|\strutshortanchors{F}| mode |
| 969 |
may be set prior to the \vb|\stackanchor| invocation. |
| 970 |
|
| 971 |
\strutshortanchors{F}% |
| 972 |
\Large |
| 973 |
\blmark\rl\rl% |
| 974 |
\def\stackalignment{l}% |
| 975 |
\def\stacktype{S}% |
| 976 |
\savestack{\pdq}{\stackanchor{\fbox{top}}{\fbox{S-bottom}}}% |
| 977 |
\pdq% |
| 978 |
\rl\rl\blmark |
| 979 |
\def\stackalignment{c}% |
| 980 |
\normalsize% |
| 981 |
\strutshortanchors{T}% |
| 982 |
|
| 983 |
The \vb|\strutshortanchors| mode will only affect short stacks |
| 984 |
(\vb|\stacktype| ``S''), since long stacks do not use a strut as part |
| 985 |
of the \vb|\stackanchor| definition. |
| 986 |
|
| 987 |
For stackanchors with more than two rows, one should compose the top |
| 988 |
portion with a stack and the bottom portion with an understack, and |
| 989 |
then, finally, shift the anchor by applying \vb|\stackanchor| to these |
| 990 |
two ``substacks.'' |
| 991 |
|
| 992 |
\Large |
| 993 |
\setstackgap{S}{1ex}% |
| 994 |
\savestack{\upperstack}{\Shortstack{{over text} {\fbox{top}}}} |
| 995 |
\savestack{\lowerstack}{\Shortstack{{\fbox{S-bottom}} {under text}}} |
| 996 |
\blmark\rl\rl\rls% |
| 997 |
\stackanchor{\upperstack}{\lowerstack}% |
| 998 |
\rls(Mid-strut) |
| 999 |
\normalsize |
| 1000 |
|
| 1001 |
\subsection{\cmd{belowbaseline} for Moving the Anchor's |
| 1002 |
Baseline\label{s:bbl}} |
| 1003 |
|
| 1004 |
The command \vb|\belowbaseline| is intended to be used to set an item, |
| 1005 |
such as a stack anchor, below the baseline (this discussion is equally |
| 1006 |
valid for the macro \vb|\abovebaseline|, but in the opposite sense). |
| 1007 |
The macro accomplishes this task by stacking the item below a null |
| 1008 |
object. However, \vb|\useanchorwidth| is temporarily set to \vb|F| so |
| 1009 |
that the stacked object takes on the width of the under-placed object. |
| 1010 |
|
| 1011 |
The command can be used with both stacktypes. With \vb|\stacktype| |
| 1012 |
``S'', the optional argument will denote the stackgap below the baseline |
| 1013 |
(default \vb|\Sstackgap|), |
| 1014 |
|
| 1015 |
\Large |
| 1016 |
\setstackgap{S}{6pt}% |
| 1017 |
\def\stacktype{S}% |
| 1018 |
Short stacktype\rl\rl\belowbaseline[0pt]{\fbox{0pt below baseline}}% |
| 1019 |
\rl\belowbaseline{\fbox{6pt}}\rl\belowbaseline[-6pt]{\fbox{-6pt}}\rl\rl |
| 1020 |
\normalsize |
| 1021 |
|
| 1022 |
When used with \vb|\stacktype| ``L'', the optional length denotes |
| 1023 |
the distance to the baseline of the understacked object (default |
| 1024 |
\vb|\Lstackgap|). |
| 1025 |
|
| 1026 |
\Large |
| 1027 |
\setstackgap{L}{18pt}% |
| 1028 |
\def\stacktype{L}% |
| 1029 |
Long stacktype\rl\rl\belowbaseline[0pt]{\fbox{0pt below baseline}}% |
| 1030 |
\rl\belowbaseline{\fbox{18pt}}\rl\belowbaseline[-19pt]{\fbox{-18pt}}\rl |
| 1031 |
\normalsize |
| 1032 |
|
| 1033 |
As the above images show, there is nothing to prevent the use of |
| 1034 |
negative numbers being used to raise the the object above the baseline. |
| 1035 |
But care must be taken, since a \vb|\belowbaseline| with a negative |
| 1036 |
shift will not necessarily equal the \vb|\abovebaseline| with the |
| 1037 |
corresponding positive shift (that equality only holds for long stacks). |
| 1038 |
To better appreciate the meaning of negative baseline shifts, we |
| 1039 |
compare, below, negative shifts for \vb|\belowbaseline| to |
| 1040 |
\vb|\abovebaseline| with the corresponding positive argument. |
| 1041 |
|
| 1042 |
\Large |
| 1043 |
\def\stacktype{S}% |
| 1044 |
Short stacktype\rl\rl\belowbaseline[-6pt]{\fbox{-6pt below}}% |
| 1045 |
\rl\abovebaseline[6pt]{\fbox{6pt above}}\rl\rl\blmark% |
| 1046 |
\normalsize |
| 1047 |
|
| 1048 |
\Large |
| 1049 |
\def\stacktype{L}% |
| 1050 |
Long stacktype\rl\rl\belowbaseline[-6pt]{\fbox{-6pt below}}% |
| 1051 |
\rl\abovebaseline[6pt]{\fbox{6pt above}}\rl\rl\blmark% |
| 1052 |
\normalsize |
| 1053 |
|
| 1054 |
The \vb|\belowbaseline| command is also useful for forcing objects, |
| 1055 |
such as images, to be top-aligned. This can be a useful feature when |
| 1056 |
trying to achieve a desired horizontal alignment of disparate elements in |
| 1057 |
tabular columns. |
| 1058 |
|
| 1059 |
\vb|\def\stacktype{S}\belowbaseline[0pt]{\imgi}|\\ |
| 1060 |
\vb|\belowbaseline[-\ht\strutbox]{\imgi}|: |
| 1061 |
|
| 1062 |
\def\stacktype{S} |
| 1063 |
\def\imgi{\includegraphics[width=0.87in]{example-image}} |
| 1064 |
\rl\blmark\rl\rl\belowbaseline[0pt]{\imgi}\rl\rl |
| 1065 |
\belowbaseline[-\ht\strutbox]{\imgi}\rl\rl% |
| 1066 |
\fbox{\parbox[t]{1.8cm}{\raggedright A parbox with [t] alignment}}% |
| 1067 |
\rl\rl\blmark\rl |
| 1068 |
|
| 1069 |
\section{Negative Stack Gap\label{s:nsg}} |
| 1070 |
\def\stacktype{S} |
| 1071 |
\setstackgap{S}{-1.2pt} |
| 1072 |
\setlength{\dotscale}{1.ex} |
| 1073 |
A negative gap can be used to overlap things. For example, \newdot plus |
| 1074 |
``i'' can make, when the stack gap is suitably negative, the following: |
| 1075 |
|
| 1076 |
~\hfill\scalebox{3}{\stackon{i}{\newdot}}\hfill~ |
| 1077 |
|
| 1078 |
Note that the use of a negative stack gap for a two-item stack is |
| 1079 |
actually very similar to the \vb|\stackinset| macro described in |
| 1080 |
\S\ref{s:iis} and \S\ref{s:ii}. The issue of negative stackgaps is also |
| 1081 |
discussed in \S\ref{s:bbl}. |
| 1082 |
|
| 1083 |
\section{The {\cmd{useanchorwidth}} Option\label{s:uaw}} |
| 1084 |
\setstackgap{S}{-1.2pt} |
| 1085 |
\setlength{\dotscale}{1.ex} |
| 1086 |
|
| 1087 |
Because\newdot has width larger than the dot glyph itself (we box its |
| 1088 |
extent here: \fbox{\newdot}), stacking it could otherwise be a problem. |
| 1089 |
For example, th\stackon{i}{\newdot}s uses the whole stackwidth to set |
| 1090 |
the dotted-i in its place. |
| 1091 |
\def\useanchorwidth{T} |
| 1092 |
On the other hand, when \vb|\useanchorwidth| is defined as \vb|T|, |
| 1093 |
``th\stackon{i}{\newdot}s'' uses only the anchor width to set the stack |
| 1094 |
(where the ``i'' is the anchor). |
| 1095 |
|
| 1096 |
Below, we show an \vb|\fbox| around the dotted i, clearly |
| 1097 |
demonstrating that the dot does not influence the width of the |
| 1098 |
stack when \vb|\useanchorwidth| is defined as ``T''. |
| 1099 |
|
| 1100 |
\fboxrule=0.2pt |
| 1101 |
\hfill |
| 1102 |
\scalebox{3}{th\fbox{\stackon{i}{\newdot}}s}% |
| 1103 |
\hfill~ |
| 1104 |
\normalsize |
| 1105 |
\def\useanchorwidth{F} |
| 1106 |
\fboxrule=0.6pt |
| 1107 |
|
| 1108 |
\section{Adding Gap Above and Below a Stack\label{s:ag}} |
| 1109 |
\setstackgap{L}{\baselineskip} |
| 1110 |
|
| 1111 |
By default, a stack is vertically clipped with no gap as in these |
| 1112 |
two \vb|\Longstack| examples: |
| 1113 |
\fbox{\Longstack{A G}} |
| 1114 |
\fbox{\Longstack{a g}} |
| 1115 |
|
| 1116 |
This package provides two ways to conveniently add gaps above and below |
| 1117 |
a stack. For any type of stack (short or long), the \vb|\addstackgap| |
| 1118 |
macro (\S\ref{s:asg}) adds a fixed amount of gap above and below a |
| 1119 |
completed object. Alternately, during the construction of long stacks, |
| 1120 |
the \vb|\strutlongstacks| mode (\S\ref{s:sm}) will automatically employ |
| 1121 |
struts in each row of a long stack during its construction. However, |
| 1122 |
these two approaches are not equivalent: |
| 1123 |
|
| 1124 |
\vb|\addstackgap[3pt]{}|: |
| 1125 |
\fbox{\addstackgap[3pt]{\Longstack{A G}}} |
| 1126 |
\fbox{\addstackgap[3pt]{\Longstack{a g}}} |
| 1127 |
~~~~\vb|\strutlongstacks{T}|: |
| 1128 |
\strutlongstacks{T} |
| 1129 |
\fbox{\Longstack{A G}} |
| 1130 |
\fbox{\Longstack{a g}} |
| 1131 |
\strutlongstacks{F} |
| 1132 |
|
| 1133 |
Make sure you use the one that best applies to your situation. |
| 1134 |
|
| 1135 |
\section{Image Insets\label{s:ii}} |
| 1136 |
\setstackgap{L}{18pt}% |
| 1137 |
|
| 1138 |
The command \vb|\stackinset| allows images (or other data) to be |
| 1139 |
stacked atop one another, to produce the effect of an inset image. In |
| 1140 |
addition to specifying the two images, the effect can be tailored by |
| 1141 |
specifying the vertical and horizontal offset of the inset image. |
| 1142 |
|
| 1143 |
\def\imgi{\includegraphics[width=0.87in]{example-image}} |
| 1144 |
\def\imgii{\includegraphics[width=0.3in]{example-image}} |
| 1145 |
\savestack{\imga}{\stackinset{r}{3pt}{t}{2pt}{\imgii}{\imgi}} |
| 1146 |
\savestack{\imgb}{\stackinset{l}{3pt}{b}{2pt}{\imgii}{\imgi}} |
| 1147 |
\imga~~~~\imgb |
| 1148 |
\def\stackalignment{c} |
| 1149 |
|
| 1150 |
The last figure was obtained with |
| 1151 |
\vb|\stackinset{l}{3pt}{b}{2pt}{\imgii}{\imgi}|, |
| 1152 |
showing that \vb|\imgii| was offset 2pt from the bottom and 3pt from |
| 1153 |
the left edge of \vb|\imgi|. |
| 1154 |
|
| 1155 |
The syntax of \vb|\stackinset| allows for a convenient nesting of |
| 1156 |
figure text labels. For example, |
| 1157 |
|
| 1158 |
\begin{verbatim} |
| 1159 |
\stackinset{l}{ .1in}{b}{.2in}{Note 1}{% |
| 1160 |
\stackinset{r}{ .1in}{t}{.2in}{Note 2}{% |
| 1161 |
\stackinset{c}{-.5in}{c}{.4in}{Note 3}{% |
| 1162 |
\stackinset{r}{ .8in}{b}{.6in}{Note 4}{% |
| 1163 |
\stackinset{r}{ .1in}{c}{.0in}{\imgi}{% |
| 1164 |
\includegraphics[width=3in]{example-image}% |
| 1165 |
}}}}} |
| 1166 |
\end{verbatim} |
| 1167 |
|
| 1168 |
gives the following result:\begin{verbbox}[\small]\stackinset\end{verbbox} |
| 1169 |
|
| 1170 |
\bxfigure[ht] |
| 1171 |
{An example of \theverbbox} |
| 1172 |
{% |
| 1173 |
\stackinset{l}{ .1in}{b}{.2in}{Note 1}{% |
| 1174 |
\stackinset{r}{ .1in}{t}{.2in}{Note 2}{% |
| 1175 |
\stackinset{c}{-.5in}{c}{.4in}{Note 3}{% |
| 1176 |
\stackinset{r}{ .8in}{b}{.6in}{Note 4}{% |
| 1177 |
\stackinset{r}{ .1in}{c}{.0in}{\imgi}{% |
| 1178 |
\includegraphics[width=3.0in]{example-image}% |
| 1179 |
}}}}}% |
| 1180 |
} |
| 1181 |
|
| 1182 |
\clearpage |
| 1183 |
\section{Stacking for Subfiguring and Baseline Manipulation\label{s:bm}} |
| 1184 |
|
| 1185 |
The stacking commands provide a convenient way to underset a subfigure |
| 1186 |
notation under the corresponding image. Furthermore, because of the |
| 1187 |
flexibility of the stacking commands, the baselines of the subfigures |
| 1188 |
can be manipulated in many ways, which may come in handy depending on |
| 1189 |
how you are choosing to lay out your subfigures. |
| 1190 |
|
| 1191 |
Examples of this are shown in figure~\ref{fg:subs}. |
| 1192 |
|
| 1193 |
% |
| 1194 |
\setstackgap{S}{3pt}\def\stacktype{S}% |
| 1195 |
\begin{myverbbox}{\figa}\stackon{(a)}{\imga}\end{myverbbox}% |
| 1196 |
\begin{myverbbox}{\figb}\stackunder{\imgb}{(b)}\end{myverbbox}% |
| 1197 |
\begin{myverbbox}[\small]{\figc} |
| 1198 |
\Shortstack{{\imgi} (c1) {} {\imgi} (c2)} |
| 1199 |
\end{myverbbox}% |
| 1200 |
\begin{myverbbox}% |
| 1201 |
{\figd}\belowbaseline[0pt]{\stackunder{\imgi}{(d)}}\end{myverbbox}% |
| 1202 |
\def\CaptionJustification{\raggedright}% |
| 1203 |
\bxfigure[ht] |
| 1204 |
{Image stacking with stacktype ``S'', stack gap set to 3pt and using: |
| 1205 |
(a)~\figa, (b)~\figb, (c)~\figc, and (d)~\figd\label{fg:subs}} |
| 1206 |
{\blmark\rl\rl% |
| 1207 |
\stackon{(a)}{\imga}~~ |
| 1208 |
\stackunder{\imgb}{(b)}~~ |
| 1209 |
\Shortstack{{\imgi} (c1) {} {\imgi} (c2)}~~ |
| 1210 |
\belowbaseline[0pt]{\stackunder{\imgi}{(d)}} |
| 1211 |
}% |
| 1212 |
|
| 1213 |
\section{Nested Stacking Commands\label{s:nsc}} |
| 1214 |
|
| 1215 |
The macros \vb|\Shortstack|, \vb|\Longstack|, and the corresponding |
| 1216 |
understack macros are set up to conveniently stack multiple objects |
| 1217 |
using a space separated argument list. Because of parsing constraints |
| 1218 |
on the space-separated list, however (see \S\ref{s:mm}), there may be |
| 1219 |
times that you would prefer building stacks by way of nesting the more |
| 1220 |
primitive stacking macros. |
| 1221 |
|
| 1222 |
Nesting can be accomplished, but some care must be taken, in the case of |
| 1223 |
long stacks. But first, let us see the ways in which nesting may be |
| 1224 |
applied for short stacks:\\ |
| 1225 |
|
| 1226 |
\def\stacktype{S}\setstackgap{S}{3pt} |
| 1227 |
\vb|\stackunder{1}{\stackunder{2}{\stackunder{3}{\stackunder{4}{5}}}}|\\ |
| 1228 |
\vb|\stackunder{\stackunder{\stackunder{\stackunder{1}{2}}{3}}{4}}{5}|\\ |
| 1229 |
\vb|\stackon{1}{\stackon{2}{\stackon{3}{\stackon{4}{5}}}}|\\ |
| 1230 |
\vb|\stackon{\stackon{\stackon{\stackon{1}{2}}{3}}{4}}{5}| |
| 1231 |
|
| 1232 |
will produce the following: |
| 1233 |
\stackunder{1}{\stackunder{2}{\stackunder{3}{\stackunder{4}{5}}}} |
| 1234 |
\stackunder{\stackunder{\stackunder{\stackunder{1}{2}}{3}}{4}}{5} |
| 1235 |
\stackon{1}{\stackon{2}{\stackon{3}{\stackon{4}{5}}}} |
| 1236 |
\stackon{\stackon{\stackon{\stackon{1}{2}}{3}}{4}}{5} \blmark |
| 1237 |
|
| 1238 |
In these cases, the nesting could be applied on either the first or the |
| 1239 |
second argument of the \vb|\stackunder| or \vb|\stackon| commands, |
| 1240 |
with the same end result. |
| 1241 |
|
| 1242 |
In the case of long stacks however, employing the identical methodology |
| 1243 |
gives a different, at first unexpected, result: |
| 1244 |
\def\stacktype{L}\setstackgap{L}{\baselineskip} |
| 1245 |
\stackunder{1}{\stackunder{2}{\stackunder{3}{\stackunder{4}{5}}}} |
| 1246 |
\stackunder{\stackunder{\stackunder{\stackunder{1}{2}}{3}}{4}}{5} |
| 1247 |
\stackon{1}{\stackon{2}{\stackon{3}{\stackon{4}{5}}}} |
| 1248 |
\stackon{\stackon{\stackon{\stackon{1}{2}}{3}}{4}}{5} \blmark |
| 1249 |
|
| 1250 |
In this case, nesting the second argument works as hoped, but nesting |
| 1251 |
the first argument does not. The reason for this ``failure'' stems |
| 1252 |
not from a failure of logic, but an enforcement of it. It stems from the |
| 1253 |
very definition of a long stack, in which the baseline of the second |
| 1254 |
argument is placed \vb|\LStackgap| below or above the baseline of the |
| 1255 |
first argument. By nesting the first argument, all the second arguments |
| 1256 |
are placed \vb|\Lstackgap| from the unchanging stack baseline (thus |
| 1257 |
overlapping), and not relative to the current top or bottom of the |
| 1258 |
nested stack. |
| 1259 |
|
| 1260 |
Therefore, to nest long stacks, only the second argument of the |
| 1261 |
stackengine may be nested. |
| 1262 |
|
| 1263 |
\section{Math Mode and Mixed Mode Usage\label{s:mm}} |
| 1264 |
\def\useanchorwidth{F} |
| 1265 |
\setstackgap{S}{1pt}\def\stacktype{S} |
| 1266 |
|
| 1267 |
As of V3.0, the {\ste} package was extended to allow its arguments to be |
| 1268 |
processed, by default, using inline math-mode (\vb|\textstyle| math). |
| 1269 |
The math-mode default is brought about with an invocation of |
| 1270 |
\vb|\stackMath|, which can be later reversed via \vb|\stackText|. |
| 1271 |
|
| 1272 |
Except in circumstances that require the particular features of this |
| 1273 |
package, {\ste} may not be the best package for math mode |
| 1274 |
since there are many packages that already cater directly to the need to |
| 1275 |
stack and align mathematical objects. However, if there is a need to |
| 1276 |
use {\ste} there, because of its particular facility with |
| 1277 |
stacking gaps and alignment, there are several hints to remember. |
| 1278 |
|
| 1279 |
\textsc{Hints for use in math mode:} (operating under \vb|\stackMath|) |
| 1280 |
\stackMath |
| 1281 |
|
| 1282 |
\begin{enumerate} |
| 1283 |
|
| 1284 |
\item Arguments to stacking commands are only taken in math mode, |
| 1285 |
\textit{by default}, following the invocation of the |
| 1286 |
\vb|\stackMath| macro. |
| 1287 |
|
| 1288 |
\item The \vb|\stackMath| and \vb|\stackText| macros, as well as |
| 1289 |
their locally scoped counterparts, \vb|\lstackMath| and \vb|\lstackText|, |
| 1290 |
are not to be used within stacking arguments, but are invoked prior |
| 1291 |
to stacking, to set the manner in which stacking arguments |
| 1292 |
are subsequently processed. |
| 1293 |
|
| 1294 |
\item As described in \S\ref{s:sls}, if the math argument has spaces in |
| 1295 |
a command which uses space-separated lists, or if the argument ends in a |
| 1296 |
macro, the argument must be enclosed in braces. |
| 1297 |
|
| 1298 |
\vb|\(y = \Shortstack{{a + b} {\odot} b} x\)|:\hfill |
| 1299 |
\(y = \Shortstack{{a + b} {\odot} b} x\) |
| 1300 |
|
| 1301 |
\item In math mode, the \vb|\stackanchor| command seems to preserve |
| 1302 |
the math axis better with an ``S'' \vb|\stacktype|, rather than type |
| 1303 |
``L''. |
| 1304 |
|
| 1305 |
\end{enumerate} |
| 1306 |
|
| 1307 |
\textsc{Hints for using math in text mode:} (operating under \vb|\stackText|) |
| 1308 |
\stackText |
| 1309 |
|
| 1310 |
%SAVE FOR FUTURE USE |
| 1311 |
\begin{verbbox}[] |
| 1312 |
\savestack{\a}{\(\sqrt{a + b}\)} |
| 1313 |
\savestack{\dash}{- - - - -} |
| 1314 |
\(y = \stackunder{\stackon{\dash}{\a}}{$b$} x\) |
| 1315 |
\end{verbbox} |
| 1316 |
|
| 1317 |
\begin{enumerate} |
| 1318 |
|
| 1319 |
\item Stacking commands from this package can be used in math mode, but |
| 1320 |
will set their arguments as text, |
| 1321 |
|
| 1322 |
\vb|\( y = \stackunder{a}{+} x\)|:\hfill |
| 1323 |
\( y = \stackunder{a}{+} x\) |
| 1324 |
|
| 1325 |
\item To set an argument in math style, it must be set between math |
| 1326 |
delimiters. |
| 1327 |
|
| 1328 |
\vb|\( y = \stackunder{$a$}{+} x\)|:\hfill |
| 1329 |
\( y = \stackunder{$a$}{+} x\) |
| 1330 |
|
| 1331 |
\item To set a particular stack completely in math style, without globally setting the mode with a \verb|\stackMath|, one can use \verb|\ensurestackMath{}|. |
| 1332 |
|
| 1333 |
\item If not using \verb|\ensurestackMath|, each space-separated item of the argument to \vb|\Shortstack|, |
| 1334 |
\vb|\Longstack|, and the corresponding understacks must each be enclosed |
| 1335 |
in their own set of math delimiters (either \verb|$...$| or \verb|\(...\)|). |
| 1336 |
|
| 1337 |
\vb|\(y = \Shortstack{$a$ . $b$} x\)|:\hfill |
| 1338 |
\(y = \Shortstack{$a$ . $b$} x\) |
| 1339 |
|
| 1340 |
\item For more complex items, the \vb|\savestack| command can be used |
| 1341 |
to save an intermediate math expression (even if it isn't actually a |
| 1342 |
stack). |
| 1343 |
|
| 1344 |
\theverbbox:\hfill |
| 1345 |
\savestack{\a}{\(\sqrt{a + b}\)} |
| 1346 |
\savestack{\dash}{- - - - -} |
| 1347 |
\addvbuffer[\the\baselineskip]{\(y = \stackunder{\stackon{\dash}{\a}}{$b$} x\)} |
| 1348 |
|
| 1349 |
\end{enumerate} |
| 1350 |
|
| 1351 |
\section{Deprecated Features\label{s:df}} |
| 1352 |
|
| 1353 |
There are several definitions and macros from earlier versions of the |
| 1354 |
{\ste} package that are still fully functional, but are discouraged |
| 1355 |
because of more preferable alternatives. They have been omitted from the |
| 1356 |
current documentation, except for mention here. They are: |
| 1357 |
|
| 1358 |
\begin{itemize} |
| 1359 |
\item \vb|\bottominset| and \vb|\topinset|. These |
| 1360 |
macros are subsumed by the much more versatile \vb|\stackinset| macro. |
| 1361 |
The replacement offers insets relative to not only the top and bottom, |
| 1362 |
but also the mid-height of the anchor. It also provides the capability |
| 1363 |
to horizontally place the inset relative to the center of the anchor, |
| 1364 |
in addition to the left or the right. Most importantly, the placement |
| 1365 |
of the anchor as the last argument of \vb|\stackinset| means that the |
| 1366 |
syntax for nested insets is much more readable vis-\`a-vis the nested |
| 1367 |
syntax for \vb|\bottominset| and \vb|\topinset|. |
| 1368 |
\end{itemize} |
| 1369 |
|
| 1370 |
\section{Backward Compatibility\label{s:bc}} |
| 1371 |
|
| 1372 |
The author of this package profoundly apologizes for the fact that the |
| 1373 |
syntax of this package changed between versions 1.0 and 2.0 of this |
| 1374 |
package. |
| 1375 |
|
| 1376 |
In\margcmd{setstackgap} version 1.0 of this package, stackgaps could be |
| 1377 |
directly defined by setting the \LaTeX{} lengths \vb|\Sstackgap| and |
| 1378 |
\vb|\Lstackgap|. The problem with this approach is that, under fontsize |
| 1379 |
changes, these stackgaps were not automatically updated to reflect the |
| 1380 |
new fontsize. As of V2.0, that deficiency was remedied. The syntax |
| 1381 |
that replaces these length specifications is |
| 1382 |
|
| 1383 |
\itshape |
| 1384 |
\vb| \setstackgap{S}{|inter-item stackgap\vb|}|\\ |
| 1385 |
\vb| \setstackgap{L}{|inter-item baselineskip\vb|}| . |
| 1386 |
\upshape |
| 1387 |
|
| 1388 |
Thus, \vb|\Sstackgap| and \vb|\Lstackgap| are no longer lengths (but |
| 1389 |
instead \vb|\def|s), and cannot be set via the \vb|\Sstackgap=...| |
| 1390 |
or \vb|\setlength{\Sstackgap}{...}| syntax. It is these settings |
| 1391 |
which will need to be revised to modernize older code. |
| 1392 |
|
| 1393 |
While\margtt{[oldsyntax]} not encouraged, the V1.0 syntax may be |
| 1394 |
recovered via |
| 1395 |
|
| 1396 |
\vb| \usepackage[oldsyntax]{stackengine}| |
| 1397 |
|
| 1398 |
If you retain the ``oldsyntax'' setting, you must remember that |
| 1399 |
\textsf{stackengine} will honor your specified gap sizes |
| 1400 |
(\vb|\Sstackgap| and \vb|\Lstackgap|) at the time of their |
| 1401 |
\textbf{definition}, rather than at the time of their |
| 1402 |
\textbf{invocation}. Thus, if \vb|\Sstackgap| is specified as 0.7ex |
| 1403 |
when the text is \vb|\normalsize|, the gap length is set in a |
| 1404 |
\vb|\normalsize| font, even if the fontsize is later changed. To |
| 1405 |
overcome this behavior, the stackgap must be redefined at the new |
| 1406 |
fontsize, or better still, \vb|[oldsyntax]| usage needs to be |
| 1407 |
relegated. |
| 1408 |
|
| 1409 |
\clearpage |
| 1410 |
\section{Acknowledgements} |
| 1411 |
|
| 1412 |
I would like to thank Prof. Enrico Gregorio at tex.stackexchange for |
| 1413 |
assisting in numerous ways to make this package better: |
| 1414 |
|
| 1415 |
\begin{itemize} |
| 1416 |
|
| 1417 |
\item by providing three lines of code to strip a leading |
| 1418 |
backslash from an argument:\\ |
| 1419 |
\vb|http://tex.stackexchange.com/questions/42318/|\\ |
| 1420 |
\vb|removing-a-backslash-from-a-character-sequence| |
| 1421 |
|
| 1422 |
\item in making the |
| 1423 |
transition from the deficient V1.0 syntax as painless as possible:\\ |
| 1424 |
\vb|http://tex.stackexchange.com/questions/123443/|\\ |
| 1425 |
\vb|defining-a-length-that-scales-with-fontsize-changes/123470#123470| |
| 1426 |
|
| 1427 |
\item and in helping to make the parsing routines of this package robust:\\ |
| 1428 |
\vb|http://tex.stackexchange.com/questions/137298/|\\ |
| 1429 |
\vb|centering-breaks-fragile-command-is-there-a-fix/137314#137314| |
| 1430 |
|
| 1431 |
\end{itemize} |
| 1432 |
|
| 1433 |
Thanks also to Dr. David Carlisle for explaining the need for argument |
| 1434 |
expansion in certain situations:\\ |
| 1435 |
\vb|http://tex.stackexchange.com/questions/131581/|\\ |
| 1436 |
\vb|parsing-rows-and-tab-characters/131594#131594| |
| 1437 |
|
| 1438 |
Finally, I extend my thanks to Per Starb\"ack, for |
| 1439 |
his unsolicited but gratefully accepted edit of the V3.21 |
| 1440 |
package documentation, which corrected numerous typographical errors. |
| 1441 |
|
| 1442 |
\section{Sectional index of \textsf{stackengine} definitions, modes, |
| 1443 |
\& macros\label{s:index}} |
| 1444 |
|
| 1445 |
{\small |
| 1446 |
\begin{tabular}{lll} |
| 1447 |
Definition, Mode, or Macro & \S\ Defined & \S\ Used\\ |
| 1448 |
\hline |
| 1449 |
\cmd{abovebaseline}&\ref{s:abb}&\ref{s:bbl}\\ |
| 1450 |
\cmd{addstackgap}&\ref{s:asg}&\ref{s:sou}, \ref{s:ag}\\ |
| 1451 |
\cmd{bclap}&\ref{s:lapdef}&\ref{s:lap}\\ |
| 1452 |
\cmd{belowbaseline}&\ref{s:abb}&\ref{s:bbl}\\ |
| 1453 |
\cmd{bllap}&\ref{s:lapdef}&\ref{s:lap}\\ |
| 1454 |
\cmd{bottomlap}&\ref{s:lapdef}&\ref{s:lap}\\ |
| 1455 |
\cmd{braceVectorstack}&\ref{s:csvs}&\\ |
| 1456 |
\cmd{bracketVectorstack}&\ref{s:csvs}&\\ |
| 1457 |
\cmd{brlap}&\ref{s:lapdef}&\ref{s:lap}\\ |
| 1458 |
\cmd{Centerstack}&\ref{s:csvs}&\ref{s:sanc}\\ |
| 1459 |
\cmd{ensurestackMath}&\ref{s:esm}&\ref{s:sm}, \ref{s:mm}\\ |
| 1460 |
\cmd{hsmash}&\ref{s:hsm}&\\ |
| 1461 |
\cmd{Longstack}&\ref{s:sls}&\ref{s:st}, \ref{s:osus}, \ref{s:sm}, \ref{s:slus}, |
| 1462 |
\ref{s:csvs}, \ref{s:svs}, \ref{s:cae}, \ref{s:ag}, \ref{s:nsc}, |
| 1463 |
\ref{s:mm}\\ |
| 1464 |
\cmd{Longunderstack}&\ref{s:slus}&\ref{s:osus}, \ref{s:sm}, \ref{s:cae}, |
| 1465 |
\ref{s:nsc}, \ref{s:mm}\\ |
| 1466 |
\cmd{Lstackgap}&\ref{s:parms}&\ref{s:st}, \ref{s:stackeng}, \ref{s:bbl}, |
| 1467 |
\ref{s:nsc}, \ref{s:bc}\\ |
| 1468 |
\cmd{lstackMath}&\ref{s:sm}&\\ |
| 1469 |
\cmd{lstackText}&\ref{s:sm}&\\ |
| 1470 |
\cmd{parenVectorstack}&\ref{s:csvs}&\\ |
| 1471 |
\cmd{quietstack}&\ref{s:parms}&\ref{s:stackeng}, \ref{s:qs}\\ |
| 1472 |
\cmd{savestack}&\ref{s:ss}&\ref{s:sanc}, \ref{s:svs}, \ref{s:cae}, |
| 1473 |
\ref{s:mm}\\ |
| 1474 |
\cmd{setstackEOL}&\ref{s:sm}&\ref{s:sls}\\ |
| 1475 |
\cmd{Shortstack}&\ref{s:sls}&\ref{s:st}, \ref{s:osus}, \ref{s:anch}, |
| 1476 |
\ref{s:sal}, \ref{s:sm}, \ref{s:slus}, \ref{s:sa}, \ref{s:bm}, \ref{s:nsc}, |
| 1477 |
\ref{s:mm}\\ |
| 1478 |
\cmd{Shortunderstack}&\ref{s:slus}&\ref{s:st}, \ref{s:osus}, \ref{s:anch}, |
| 1479 |
\ref{s:sm}, \ref{s:sls}, \ref{s:nsc}, \ref{s:mm}\\ |
| 1480 |
\cmd{Sstackgap}&\ref{s:parms}&\ref{s:st}, \ref{s:stackeng}, \ref{s:asg}, |
| 1481 |
\ref{s:bbl}, \ref{s:bc}\\ |
| 1482 |
\cmd{stackalignment}&\ref{s:parms}&\ref{s:sal}, \ref{s:stackeng}, |
| 1483 |
\ref{s:cae}, \ref{s:lap}\\ |
| 1484 |
\cmd{stackanchor}&\ref{s:sanc}&\ref{s:csvs}, \ref{s:iis}, \ref{s:sa}, |
| 1485 |
\ref{s:mm}\\ |
| 1486 |
\cmd{stackengine}&\ref{s:stackeng}&\ref{s:sou}\\ |
| 1487 |
\cmd{stackgap}&\ref{s:parms}&\ref{s:stackeng}, \ref{s:sls}\\ |
| 1488 |
\cmd{stackinset}&\ref{s:iis}&\ref{s:nsg}, \ref{s:ii}, \ref{s:df}\\ |
| 1489 |
\cmd{stackMath}&\ref{s:sm}&\ref{s:sls}, \ref{s:esm}, \ref{s:mm}\\ |
| 1490 |
\cmd{stackon}&\ref{s:sou}&\ref{s:asg}, \ref{s:nsg}, \ref{s:uaw}, \ref{s:bm}, |
| 1491 |
\ref{s:nsc}, \ref{s:mm}\\ |
| 1492 |
\cmd{stackText}&\ref{s:sm}&\ref{s:mm}\\ |
| 1493 |
\cmd{stacktype}&\ref{s:parms}&\ref{s:st}, \ref{s:stackeng}, \ref{s:sls}, |
| 1494 |
\ref{s:sa}, \ref{s:bbl}, \ref{s:bm}, \ref{s:mm}\\ |
| 1495 |
\cmd{stackunder}&\ref{s:sou}&\ref{s:bm}, \ref{s:nsc}, \ref{s:mm}\\ |
| 1496 |
\cmd{strutlongstacks}&\ref{s:sm}&\ref{s:csvs}, \ref{s:asg}, \ref{s:ag}\\ |
| 1497 |
\cmd{strutshortanchors}&\ref{s:sm}&\ref{s:sanc}, \ref{s:sa}, \ref{s:df}\\ |
| 1498 |
\cmd{tclap}&\ref{s:lapdef}&\ref{s:lap}\\ |
| 1499 |
\cmd{tllap}&\ref{s:lapdef}&\ref{s:lap}\\ |
| 1500 |
\cmd{toplap}&\ref{s:lapdef}&\ref{s:lap}\\ |
| 1501 |
\cmd{trlap}&\ref{s:lapdef}&\ref{s:lap}\\ |
| 1502 |
\cmd{useanchorwidth}&\ref{s:parms}&\ref{s:stackeng}, \ref{s:bbl}, \ref{s:uaw}\\ |
| 1503 |
\cmd{Vectorstack}&\ref{s:csvs}&\\ |
| 1504 |
\cmd{vertVectorstack}&\ref{s:csvs}&\\ |
| 1505 |
\end{tabular} |
| 1506 |
} |
| 1507 |
|
| 1508 |
\section{Code Listing} |
| 1509 |
|
| 1510 |
\verbfilenobox[\footnotesize]{stackengine.sty} |
| 1511 |
|
| 1512 |
\end{document} |
| 1513 |
|
| 1514 |
|
| 1515 |
|