# Why does standalone not detect the TikZ crop correctly?

This small example

\documentclass{standalone}
\usepackage{xltxtra,textcomp,graphicx,color,tikz}
\usepackage[absolute,overlay]{textpos}
\begin{document}
\begin{tikzpicture}
\clip (0,0) rectangle (12.8cm, 1.15cm);
\draw (0,0) grid (12.8cm, 1.15cm);
\end{tikzpicture}
\end{document}


generates this output:

Where is the margin / extra space on the left side coming from, and how can I remove it? Shouldn't \clip take care of that?

• You don't need graphicx,color if you're loading TikZ. You almost certainly shouldn't be loading both xltxtra and textcomp. That suggests some level of confusion. Do you really want textpos for a standalone TikZ picture? – cfr Jun 7 '16 at 22:21

## 1 Answer

use

\documentclass[
tikz,
%border=1pt
]{standalone}


With the tikz option the standalone class knows that it should crop the environment(s) tikzpicture and not only the given text box.

With the border option you can better control the result

• thank you, that worked just fine. Could you maybe elaborate a bit about the use of the tikz option, what does it do? – barbaz Oct 14 '13 at 9:38
• see documentation page 7 – user2478 Oct 14 '13 at 9:41
• This reference shows a simple solution: \documentclass[border=10pt]{standalone}. – Rubens Jul 22 '14 at 21:56
• @Rubens: border=... doesn't solve the problem with the tikz key ... – user2478 Jul 23 '14 at 4:40
• Alternatively, one could use multi=tikzpicture,varwidth=false instead. The only difference according to the documentation is that standalone would not load the tikz package itself thus one has to do that manually. However, this might help in some situations, e.g., if one uses \usepackage[svgnames]{xcolor} which has to be loaded before tikz or else results in LaTeX Error: Option clash for package xcolor. (which would be impossible if the document class has loaded tikz already. – stefanct Nov 10 '17 at 13:58