# Make standalone class without tikz look like a cropped article [duplicate]

How can I force the standalone class to put things on top of eath other instead of next to each other?

\documentclass{standalone}
\begin{document}
test

test

test

\end{document}


## marked as duplicate by Mico, barbara beeton, egreg, Andrew, Paul GaboritJun 30 '16 at 23:23

There are several ways. As daleif points out, there is a varwidth option that allows paragraph breaks. The default \textwdith is 390pt in this configuration:

\documentclass[12pt,varwidth]{standalone}
\begin{document}
test

test

test
\end{document}


Without varwidth, one can still proceed. Here is a way:

\documentclass[12pt]{standalone}
\usepackage{calc}
\begin{document}
\parbox{\widthof{test}}{%
test

test

test
}
\end{document}


If you want paragraphs of a fixed width, then replace \widthof{test} with a fixed length, as in

\documentclass[12pt]{standalone}
\usepackage{lipsum}
\begin{document}
\parbox{7in}{\parindent 1em\relax%
\lipsum[1-3]
}
\end{document}


Here is another way, useful if the items being stacked are not free-flowing text but individual entities:

\documentclass[12pt]{standalone}
\usepackage{stackengine}
\begin{document}
\Longstack{%
test
test
test}
\end{document}


or, for a more complex case,

\documentclass[12pt]{standalone}
\usepackage{stackengine}
\setstackEOL{\\}
\begin{document}
\renewcommand\stackalignment{r}
\stackunder[10pt]{\Longstack[c]{
Happy birthday to you,\\
Happy birthday to you,\\
Happy birthday dear \LaTeX{}\\
Happy birthday to you.
}}{\ldots and many more}
\end{document}


What is best will depend on what is being stacked. Are they single words as you show, or are they free-flowing paragraphs? Or maybe multi-line phrases with manual line breaks? Are they centered or left justified? etc. etc. etc. The particular use case will define the best solution.

• Doesn't standalone have a varwidth option that does this automatically? – daleif Jun 30 '16 at 17:18
• @daleif I know there is a varwidth option, but don't use standalone to know how it works. – Steven B. Segletes Jun 30 '16 at 17:22
• @daleif Thanks. Edited to include as primary method. – Steven B. Segletes Jun 30 '16 at 17:27