I have a problem with TikZ's auto-cropping/auto-calculating the bounding box for a tikzpicture
.
Look at the following example:
\documentclass{article}
\usepackage{tikz}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam scelerisque massa quis nibh egestas, sed aliquam justo gravida. Integer eget felis vel erat auctor sagittis. In eget ligula eu velit rutrum sodales sed at velit. Proin id blandit ante, tristique bibendum magna.
\begin{center}
\begin{tikzpicture}
\node[draw,circle] (A) at (0,0){A};
\node[draw,circle] (B) at (3,3){B};
\draw (A) to (B);
\end{tikzpicture}
\end{center}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam scelerisque massa quis nibh egestas, sed aliquam justo gravida. Integer eget felis vel erat auctor sagittis. In eget ligula eu velit rutrum sodales sed at velit. Proin id blandit ante, tristique bibendum magna.
\begin{center}
\begin{tikzpicture}
\node[draw,circle] (A) at (0,0){A};
\node[draw,circle] (B) at (3,3){B};
\draw[bend left=90,looseness=2] (A) to (B);
\draw[bend right=90,looseness=2] (A) to (B);
\end{tikzpicture}
\end{center}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam scelerisque massa quis nibh egestas, sed aliquam justo gravida. Integer eget felis vel erat auctor sagittis. In eget ligula eu velit rutrum sodales sed at velit. Proin id blandit ante, tristique bibendum magna.
\end{document}
This produces the following output:
As you can see the cropping of the picture with the straight lines is perfectly fine. However, for the curved lines there is too much (unnecessary) white-space before and after the picture.
I know I can manually fix this by changing the boundingbox
or simply using \vspace
, but is there an automatic way to get accurate bounding boxes?
(Note: This is very similar to this question, but the answers there do not seem to help with the automatic calculation, mostly checking first what the bounding box is and then applying some sort of clipping.)
pdfcrop
doesn't work for me now but according topgfplots
manual ` (v1.13, end of p. 511) it's possible to defineexternal/system call
like two different commands with&&
in between. Thus I understand you could use externalization withpdflatex ... && pdfcrop ...
and if there's no problem with names, you could get automatically cropped figures.