# Can I make the page as big as my picture?

This is the reciprocal to How can I create a pdf document exactly as big as my tikz picture?. My understanding of all the answers there is that they extract a picture from a TeX document and strip away all the unnecessary space around the edges. My situation is that the picture I'm drawing is bigger than the usual page and I want to resize the page to be big enough to fit it.

More specifically, I'm drawing a picture using TikZ (though that's not important, I guess) and the document consists only of that picture. As I draw more and more, it gets bigger and bigger (current size is about 80cm square). I use the geometry package to keep enlarging the paper size, but it would be nice if TeX could handle that automatically.

(It is possible that one of the answers to How can I create a pdf document exactly as big as my tikz picture? can do this, but it wasn't obvious from reading them.)

-

Your approach seems the right one for me. Just set the paper size to \maxdimen and let preview or standalone scale it down:

\documentclass{standalone}
\usepackage[paperwidth=\maxdimen,paperheight=\maxdimen]{geometry}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (100cm,100cm);
\draw (0,0) -- (100cm,100cm);
\end{tikzpicture}
\end{document}


Make sure it is really just the tikzpicture no empty lines around it. This isn't required when using preview directly:

\documentclass{article}
\usepackage[paperwidth=\maxdimen,paperheight=\maxdimen]{geometry}
\usepackage{tikz}
\usepackage[tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (100cm,100cm);
\draw (0,0) -- (100cm,100cm);
\end{tikzpicture}
\end{document}

-
So \maxdimen is some internal constant that determines just how big dimensions can be, is that right? ... ah, yes, I see it in latex.ltx: \newdimen\maxdimen .... % the largest legal <dimen>. Useful to know about. – Andrew Stacey Mar 11 '11 at 9:50
@Andrew: TeX seems to use 31-bit signed integers for dimensions. The lower 16 bits are for the fractional part. No idea what happens with the 32nd bit. It's a pity that eTeX isn't expanding it to 64 bit :-) – Martin Scharrer Mar 11 '11 at 10:19
I just wanted to see what that length translated to in "normal" units, so searched for "tex length conversion". The first hit offered to convert TeX points to ... wait for it ... arms lengths! (There are about 1991 TeX points in an arm.) – Andrew Stacey Mar 11 '11 at 10:35
Okay \maxdimen turns out to be just under 6m. I think that that's big enough for now. – Andrew Stacey Mar 11 '11 at 10:40
@Andrew: Anything larger than 5.758x5.758m must be done using scaling. – Martin Scharrer Mar 11 '11 at 10:45
show 1 more comment