1

This question already has an answer here:

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 Gaborit Jun 30 '16 at 23:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

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}

enter image description here

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}

enter image description here

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}

enter image description here

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}

enter image description here

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}

enter image description here

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.

  • 1
    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
  • 1
    @daleif Thanks. Edited to include as primary method. – Steven B. Segletes Jun 30 '16 at 17:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.