Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When I try to fit the page size to my tikz image, too much is cropped. No matter whether I use \documentclass{standalone}, \documentclass[preview=true]{standalone} or \usepackage[active,tightpage]{preview}\PreviewEnvironment{tikzpicture}. The complete source:

\documentclass{minimal}

\usepackage{tikz}
\definecolor{darkred}{rgb}{0.5,0,0}

\begin{document}

\begin{tikzpicture}
    \begin{scope}[color=lightgray]
        \draw (-8,0) -- (8,0);
        \filldraw[shift={(8,0)},scale=0.25] +(-210:1) -- +(210:1) -- +(0:1) -- cycle;
        \draw (0,-8) -- (0,8);
        \filldraw[shift={(0,8)},scale=0.25,rotate=90] +(-210:1) -- +(210:1) -- +(0:1) -- cycle;
    \end{scope}
    \newcommand\hyper[4][]{\draw[mark=*,mark options={fill=black}] plot [#1] ({#2*exp(#4)+#3*exp(-#4)}, {#2*exp(#4)-#3*exp(-#4)})}
    \newcommand\hyperline[6]{\draw ({#1*exp(#3)+#2*exp(-#3)}, {#1*exp(#3)-#2*exp(-#3)}) -- ({#4*exp(#6)+#5*exp(-#6)}, {#4*exp(#6)-#5*exp(-#6)})}
    \pgfsetplotmarkrepeat{6}
    \foreach \a in {-1, 1}{%
        \foreach \b in {-1, 1}{%
            \begin{scope}[very thin, color=gray]
                \begin{scope}[domain=-2:2]
                    \hyper\a0\x;
                    \hyper0\b\x;
                    \hyper\a\b\x;
                \end{scope}
                \begin{scope}[domain=-1.3:1.3]
                    \hyper{\a*2}{\b*2}\x;
                \end{scope}
            \end{scope}
        }
    }
    \begin{scope}[color=darkred]
        \foreach \k in {0,...,2}{%
            \hyperline0{-1}\k1{-1}\k;
            }
    \end{scope}
\end{tikzpicture}

\end{document}

This looks like this:

enter image description here

After reading Transparency in tikz, preview package and xelatex, I tried to set the size manually:

\usepackage{geometry}
\geometry{paperwidth=163mm,paperheight=163mm,margin=0mm}

But this gives me the error message:

! Package geometry Error: \paperwidth (0.0pt) too short.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Ok, solved the problem with standalone. It was the empty line after the tikzpicture environment. Like meantioned here: Standalone package creates a page with a fixed width

And the following makes it work with preview. Notice that it is loaded after tikz:

\documentclass{minimal}

\usepackage{tikz}
\definecolor{darkred}{rgb}{0.5,0,0}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}

The last problem is because the minimal class does not work with geometry. Simply using the article class made that work too. (See also Why not use the minimal class)

share|improve this answer
    
In preview, \PreviewBorder=<length>\relax is the replacement for the border=<length> of standalone document class. –  I am who I say I am Jul 18 '12 at 9:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.