TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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




\path[draw=red] (0,0) -- (0,400pt) -- (400pt,400pt) -- (400pt,0) -- cycle;

\path[draw=red] (0,0) -- (0,200pt) -- (200pt,200pt) -- (200pt,0) -- cycle;


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

enter image description here

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

enter image description here

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?

share|improve this question
up vote 4 down vote accepted

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!)

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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