W3cubDocs

/LaTeX

\shortstack

Synopsis:

\shortstack[position]{line 1 \\ ... }

Produce a vertical stack of objects.

This labels the y axis.

\put(0,0){\vector(1,0){4}}   % x axis
\put(0,0){\vector(0,1){2}}   % y
\put(-0.25,2){\makebox[0][r]{\shortstack[r]{$y$\\ axis}}}

For a short stack, the reference point is the lower left of the stack. In the above example the \mbox & \makebox puts the stack flush right in a zero width box so in total the short stack sits slightly to the left of the y axis.

The valid positions are:

r

Make objects flush right

l

Make objects flush left

c

Center objects (default)

Separate objects into lines with \\. These stacks are short in that, unlike in a tabular or array environment, here the rows are not spaced out to be of even heights. Thus, in \shortstack{X\\o\\o\\X} the first and last rows are taller than the middle two. You can adjust row heights either by putting in the usual interline spacing with \shortstack{X\\ \strut o\\o\\X}, or by hand, via an explicit zero-width box \shortstack{X \\ \rule{0pt}{12pt} o\\o\\X} or by using \\’s optional argument \shortstack{X\\[2pt] o\\o\\X}.

The \shortstack command is also available outside the picture environment.

© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/_005cshortstack.html