Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

shortstack-like command with multiple lines?

0 views
Skip to first unread message

ivo...@gmail.com

unread,
Nov 23, 2006, 7:20:18 PM11/23/06
to

dear texperts: If I use a shortstack with three lines, the line
spacing between line #1 and line #2 is different from the spacing
between line #2 and line #3. is there a reason for it? it would seem
sense to have a general multi-line shortstack.

no problem I thought---just define it yourself. I like the narrow line
spacing. alas, this is not as obvious as I thought:

\documentclass{article}
\usepackage{setspace}
\begin{document}
\newcommand{\shortstackthree}[1]{\begin{spacing}{0.6}\begin{tabular}{l}#1\end{tabular}\end{spacing}}
ok: \shortstackthree{a\\b\\c}
fails: $\shortstackthree{a\\b\\c}$
fails: $\mbox{\shortstackthree{a\\b\\c}}$
\end{document}

how should I define this?

sincerely,

/iaw

Enrico Gregorio

unread,
Nov 24, 2006, 4:20:43 AM11/24/06
to
<"ivo...@gmail.com"> wrote:

If you need to reduce the leading between the stacked lines, you can
act on the \arraystretch parameter:

\newcommand{\newshortstack}[1]
{\begingroup\renewcommand{\arraystretch}{.8}% <- adjust to suit
\ifmmode
\begin{array}{c}#1\end{array}%
\else
\begin{tabular}{c}#1\end{tabular}%
\fi
\endgroup}

Thus you have a stack in math form when in math, in text form otherwise.

Ciao
Enrico

ivo...@gmail.com

unread,
Nov 24, 2006, 10:13:01 AM11/24/06
to

thank you, enrico. is there a reason why this is not the standard
shortstack definition?

Enrico Gregorio

unread,
Nov 24, 2006, 10:59:03 AM11/24/06
to
<"ivo...@gmail.com"> wrote:

> thank you, enrico. is there a reason why this is not the standard
> shortstack definition?

Please, don't top post.

I don't know the real reason. The \shortstack command was devised
for use in picture mode and much more optimized than the one I showed
you.

A definition more in line with the original \shortstack command
could be

\makeatletter
\def\cvb@x{$\vcenter} \def\ecvb@x{$}
\let\tvb@x\vtop \let\etvb@x\relax
\let\bvb@x\vbox \let\ebvb@x\relax
\newcommand\newshortstack[1][b]{%
\leavevmode
\csname #1vb@x\endcsname\bgroup
\baselineskip-\p@\lineskip 2\p@
\let\\\@stackcr
\@inewshortstack{#1}}
\def\@inewshortstack#1#2{\ialign{\hss\vphantom{ly}{##}\unskip\hss\cr
#2\crcr}%
\egroup\csname e#1vb@x\endcsname}
\makeatother

So you say \newshortstack{a\\b\\c} for bottom alignment,
\newshortstack[c]{a\\b\\c} for center alignment and
\newshortstack[t]{a\\b\\c} for top alignment. But you lose the
automatic recognition of math mode.

Ciao
Enrico

0 new messages