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:
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.
Best Answer
Ok, solved the problem with
standalone
. It was the empty line after thetikzpicture
environment. Like meantioned here: Standalone package creates a page with a fixed widthAnd the following makes it work with
preview
. Notice that it is loaded aftertikz
:The last problem is because the
minimal
class does not work withgeometry
. Simply using thearticle
class made that work too. (See also Why should the minimal class be avoided?)