2

I am trying to make a series of engineering drawings with TikZ for an industrial catalogue. I would like to get only the drawings. The following MWE crops the bottom of the picture, and I would like to prevent this.

\documentclass[]{standalone}
\usepackage{tikz}
\usepackage{wasysym}
\usetikzlibrary{arrows}

\begin{document}
\begin{tikzpicture}
\draw [<->, >=triangle 45, thick] (0,0)--(5,0) node[above, midway]{\large \diameter\normalsize {3}};
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688
Yves
  • 2,825
  • \documentclass[border={0 4pt 0 0}]{standalone} – Gonzalo Medina Jun 05 '13 at 16:58
  • @GonzaloMedina Good. Is there a way to make this adjusment sort of automatic ? – Yves Jun 05 '13 at 17:03
  • No, there isn't such automatic adjustment, as far as I know. – Gonzalo Medina Jun 05 '13 at 17:07
  • The newest update for TikZ CVS does now support the inclusion of arrowheads into the bounding box. Thus, smart cropping of TikZ pictures with standalone is now possible.

    According to the feature request https://sourceforge.net/p/pgf/feature-requests/77/, it is not yet documented but available.

    – LaRiFaRi Sep 19 '13 at 08:04

1 Answers1

2

This is happening because the arrow tips don't count in the computation of the bounding box by Tikz

As one of the comments (by Gonzola) mentionned, you can specify a border in the standalone document class options. Personally, I prefer specifying an all-around border with border = 4pt, but with Gonzalo's suggestion, only the bottom border is drawn, which is what you want.

Another way is to specify, within the picture code, what the bounding box should be. For example

\path[use as bounding box] <some code here>

tells tikz what to use.

In addition to including everything you want from your picture, this approach has another use. It can help in aligning a picture within a document according to your preferences: Say you want a part of a picture to be aligned with the center of the page but some annotation always makes the picture shift left with respect to the page, manually selecting the bounding box can fix this. Of course, using the bounding box to align a picture is only useful in a complete document, it is of no use for a standalone picture.

Frédéric
  • 11,087
  • 3
  • 37
  • 43
  • This is a clear explanation. I had noticed that the cropping was not consistent in various pictures, without an understanding of the reason for it. Forcing the bounding box is a good way to prevent the inconsistent behavior. – Yves Jun 05 '13 at 17:44
  • I have finally found that the solution without the standalone package, posted by Herbert on the page below suits my needs well, as I have large number of pictures to handle. http://tex.stackexchange.com/questions/71299/how-to-make-a-smarter-cropping-with-standalone-or-preview-packages – Yves Jun 05 '13 at 18:08