# \shortstack with empty line

How can I force \shortstack to preserve an empty line? For example,

\shortstack[c]{hoge \\ foo \\ bar}
\shortstack[c]{hoge \\  \\ bar}


provides

. But I would like to keep the empty line in the middle.

• Do you need to use \shortstack? Why not just a tabular (which will preserve line heights and empty rows)? – Werner Jan 24 '17 at 20:22

\shortstack is really unsuitable for uniformly stacking characters, because it just takes into account the character's height and depth, adding just 3pt between them.

Look at the result with

\documentclass{article}

\begin{document}

\shortstack{a\\c\\e}
\shortstack{g\\y\\q}
\shortstack{fg\\ly\\pt}
\shortstack{l\\a\\f}

\end{document}


The result is surely not what you expected it to be. The command is only useful when its argument consists of capital letters only (without diacritics).

\documentclass{article}

\newcommand{\bettershortstack}[2][c]{%
\begin{tabular}[b]{@{}#1@{}}#2\end{tabular}%
}

\begin{document}

\bettershortstack{a\\c\\e}
\bettershortstack{g\\y\\q}
\bettershortstack{fg\\ly\\pt}
\bettershortstack{l\\a\\f}

\end{document}


\documentclass{article}

\newcommand{\bettershortstack}[2][c]{%
\begin{tabular}[b]{@{}#1@{}}#2\end{tabular}%
}

\begin{document}

\bettershortstack{hoge \\ foo \\ bar}
\bettershortstack{hoge \\  \\ bar}

\end{document}


For things to line up properly, use a \vphantom, since line heights are relative to the entry:

\documentclass{article}

\usepackage{stackengine}

\begin{document}

\shortstack[c]{hoge \\ foo \\ bar}
\shortstack[c]{hoge \\  \\ bar}
\shortstack[c]{hoge \\ \vphantom{foo} \\ bar}

\end{document}