# standalone: varwidth option limits output width?

It seems, that the varwidth option for the standalone class limits the output width. The problem is produced in the following example:

\documentclass[10pt,crop,varwidth]{standalone}

\usepackage{tikz}

\begin{document}%

\begin{tikzpicture}
\pgfsetlinewidth{0.3cm}
\path[draw=red] (0,0) -- (0,400pt) -- (400pt,400pt) -- (400pt,0) -- cycle;
\end{tikzpicture}

\begin{tikzpicture}
\pgfsetlinewidth{0.3cm}
\path[draw=red] (0,0) -- (0,200pt) -- (200pt,200pt) -- (200pt,0) -- cycle;
\end{tikzpicture}

\end{document}


The above code produces an image of 458x821pxl with the bigger square cut of on the right side:

Leaving away the varwidthoption results in a 824x543px image with the two squares shown correctly:

I want to place several objects beneath each other, that's why I use the varwidthoption in the first place. Unfortunatly my intended width of 510pt is to much for varwidth. So my question is: Is there a way to expand the limit set by varwidth? If not, is there another way to put objects beneath each other in standalone without using varwidth?

-

The varwidth=<length> option (length is optional and defaults to \linewidth) wraps the content into a {varwidth}{<length>} environment (from the varwidth package). This environment is like {minipage}{<length>} but will shrink horizontally to the content if it is smaller then <length>. This is the effect you see. This is not a bug.
The varwidth option is intended for content which requires paragraphs and therefore doesn't work in the restricted horizontal mode used otherwise by standalone. For tikzpictures it is not required nor recommended.
A solution for your example would be to simply select a wider width. Using varwidth=\maxdimen or a similar high value should do it. (I didn't used \maxdimen as a default width because sometimes it caused errors if the resulting box was for some reason slightly wider than the content, resulting in a too large dimension value. Also, paragraphs which are \maxdimen wide look rather strange!)
You might also want to have a look at the standalone manual. It describes the varwidth option and all others in detail. – Martin Scharrer Jan 18 '13 at 15:18
Thanks! As I stated earlier, I wanted to put several objects (not necessarily tikzpictures) beneath each other and found an answer saying, this was possible by using the varwidthoption since standalonewould usually just ignore linebreaks. This is how I ran into the problem. Increasing the \linewidthwouldn't help either. But your solution works, thanks. – Janek Jan 18 '13 at 15:56
@Janek: Also the preview option instead of crop might work. It uses the preview package for cropping, which IIRC supports line breaks. – Martin Scharrer Jan 18 '13 at 19:13
Thank you! My standalone_verbatim.txt that renders text file given by \txtfile parameter works thanks to your answer! Here is source code for reference for other readers: gist.github.com/gwpl/5128cb3cd348c38492da59800b6ab3f2 – Grzegorz Wierzowiecki May 9 at 20:46