I think I found a bug, but there might be a reason for it.
So there I was, making some nice figure of a duck on a gray backround in tikz.
But as it turned out, I needed the figure to have a different size, and the figure had gotten complicated, and I didn't want to redo all the placements of things. So I thought to myself. Can I not just adjust the size of the figure to the size I want? What a great idea! So I usepackaged the adjustwidth package, and wrote \begin{adjustbox}{width=5cm} ... \end{adjustbox}
around my picture:
\documentclass[tikz]{standalone}
\usepackage{graphicx}
\usepackage{duckuments}
\usepackage{adjustbox}
\begin{document}
\begin{adjustbox}{width = 5cm}
\begin{tikzpicture}
\node[anchor = north east] at (5.5,0) {\includegraphics{example-image-duck}};
\end{tikzpicture}
\end{adjustbox}
\end{document}
Around my tikzpicture, but low and behold, it did not compile!
For many a night, I scratch my brain, did adjustbox not like ducks on gray backrounds? surely that could not be the case (I was also conviced I had adjusted the width of ducks on gray boxes at earlier times). In a desperate attempt to fix the mistake, I moved the use of tikz from the declaration of the standalone documentclass to a regular usepckage statement:
\documentclass{standalone}
\usepackage{graphicx}
\usepackage{duckuments}
\usepackage{adjustbox}
\usepackage{tikz}
\begin{document}
\begin{adjustbox}{width = 5cm}
\begin{tikzpicture}
\node[anchor = north east] at (5.5,0) {\includegraphics{example-image-duck}};
\end{tikzpicture}
\end{adjustbox}
\end{document}
To my surprise the code compiled! And what came out was a beautiful duck with a blue hat and a green lightsaber on a gray background 5 cm wide, never had my life felt so complete!
My question then is, Why does this fail when I import tikz through the documentclass. Is there times where importing tikz through the standalone documentclass is more benificial than others? what is the proper way to go about this?
For the interested, it also fails if you have tikz imported both in the documentclass and as a usepackage.
Thanks for reading and for your answers ;-)
tikz
,standalone
will output multiple pages, and each page will be the contents of a singletikzpicture
environment. So thetikz
option does more than just loading a package for you.