I am trying to create a standalone pdf with the following source code:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{xcolor}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\draw[fill=teal] (0,0) rectangle (2,1);
\end{tikzpicture}
\caption{Rectangle in TikZ}
\end{figure}
\end{document}
This does not work, outputting the following:
Something's wrong--perhaps a missing \\item.
Something's wrong--perhaps a missing \\item.
Something's wrong--perhaps a missing \\item.
Missing \\endgroup inserted.\n<inserted text>
Missing \\endgroup inserted.\n<inserted text>
Missing \\endgroup inserted.\n<inserted text>
Missing } inserted.\n<inserted text>
Undefined control sequence.\n<argument> \\csname fnum@\\@captype
Extra \\endgroup.\n\\@caption ...me }{\\ignorespaces #3}\\par \\endgroup
Something's wrong--perhaps a missing \\item.
\\begin{document} ended by \\end{figure}.
Extra \\endgroup.\n<recently read> \\endgroup
Extra \\endgroup.\n\\color@endgroup ->\\endgraf \\endgroup
Too many }'s.\n\\endsa@boxit ...dvarwidth \\color@endgroup \\egroup
Does anybody here know how to work around this problem? Using a documentclass other than standalone is an option for me, as long as it renders a pdf that matches the size of the content.