I'm drawing a standalone tikz picture and when I compile it one of the edges is cut off. I think it's because I'm using a shifted scope within the picture. (Edit, it may be due to the [x=2cm,y=2cm] scale I have applied to the picture)

    \draw (0,0) rectangle (3,3);

    \draw (0,0) rectangle (3,3);

The furthest right part of my picture is being cut off, I suspect the varwidth, border=5pt] arguments aren't taking the shift (edit: or maybe the scale) into account.

So my question is either:

  • Is there a non-manual way of making sure the edges of my picture don't get cut off? (I'm aware of \useasboundingbox but would prefer not to use it)
  • Is there a better technique than shift to construct two pictures which are very similar but offset from one another by some amount? I don't want to have to draw the picture twice with different coordinates. From an editing point of view shift is much more efficient.
  • 2
    Can you make an example that actually demonstrates the problem? Adding something like \draw (0,0) rectangle (1,1); in both scopes isn't enough. For the second part you could have a look at using \pics. See chapter 18 in the manual, or the tikz-pic tag here on the site. Sep 25, 2017 at 15:55
  • @TorbjørnT. I've replicated the problem but it might be due not to the shift but due to a scaling of the whole picture I have: \begin{tikzpicture}[x=2cm,y=2cm]. Now the problem is there when the shift is {3.5,0} and the rectangles are (3,3) large.
    – thosphor
    Sep 25, 2017 at 16:12
  • 1
    @user3087409 please edit your post and place the code so that we can just copy paste.
    – koleygr
    Sep 25, 2017 at 16:14
  • Why are you using varwidth anyway, if you all you have is a tikzpicture it's pointless? (And apparently the cause of the problem.) Sep 25, 2017 at 16:15
  • 1
    I answered. Might as well keep it around, no need to delete I think. Sep 25, 2017 at 16:21

1 Answer 1


The problem is varwidth, which in the example you show is completely unnecessary, so just remove it.

With varwidth, the content is set in a varwidth environment that is \linewidth wide. By default, \linewidth corresponds to about 12cm. The content in your diagram is 7.5 * 2 = 14cm wide, so you get an Overfull \hbox (25.28575pt too wide). Because standalone sets the size of the PDF to that of the varwidth, part of the diagram is cut off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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