Fitting page size to TIKZ figure size without the standalone package

Posted on 29, Aug 2013

We need the preview LaTeX package where we specify a tight page and specify the tikzpicture as the preview:

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}

That is it. A full document might look like this:

\documentclass{article}

\usepackage{tikz}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}

\begin{document}
    \begin{tikzpicture}
        \draw [dashed,color=gray] (0, 0) circle (5cm);
    \end{tikzpicture}
\end{document}

Copyright, Christopher Poole 2008-2016.