# How can I avoid a 'Dimension too large' error in an a0 size TikZ figure?

I'm using Debian/Squeeze with its texlive-full package installed.

After some success with TikZ for normal article-size figures, I got interested in using it for an a0 size poster.

As a (fairly) minimal standalone example of the problem I'm running into, the code below fails with a 'Dimension too large.' error if any of the indicated lines are uncommented (so basically when it tries to create an arc of half the page width or more, or thereabouts). I'm processing it with pdflatex.

\documentclass[onlymath]{beamer}
\usefonttheme{serif}

\usepackage[orientation=portrait,size=a0,scale=1.0]{beamerposter}

\usepackage{eulervm}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,matrix}

\begin{document}
\begin{frame}[t,fragile]{}

\begin{block}{Big TikZ Test}
\begin{center}

\begin{tikzpicture}

\tikzstyle{blk} = [rectangle,draw,text width=2in,text centered];
\tikzstyle{edge} = [draw,line width=3pt,black!50];

\matrix[row sep=1cm,column sep=1cm] {
\node[blk] (a) {A};
&
\node[blk] (b) {B};
&
\node[blk] (c) {C};
&
\node[blk] (d) {D};
&
\node[blk] (e) {E};
&
\node[blk] (f) {F};
&
\node[blk] (g) {G};
&
\node[blk] (h) {H};
&
\node[blk] (i) {I};
&
\node[blk] (j) {J};
\\
};

\path[edge] (j) edge [->,bend left=30] (i);
\path[edge] (j) edge [->,bend left=30] (h);
\path[edge] (j) edge [->,bend left=30] (g);
\path[edge] (j) edge [->,bend left=30] (f);
\path[edge] (j) edge [->,bend left=30] (e);

% Uncommenting any of these fails with 'Dimension too large.' error
\path[edge] (j) edge [->,bend left=30] (d);
%      \path[edge] (j) edge [->,bend left=30] (c);
%      \path[edge] (j) edge [->,bend left=30] (b);
%      \path[edge] (j) edge [->,bend left=30] (a);

\end{tikzpicture}

\end{center}
\end{block}

\end{frame}
\end{document}


From other similar questions here, I understand there is some limited-range datatype involved, but none of the suggested code-fragment fixes (typically involving some inclusion of a pgf package and messing with some fp / fpu thing) seems to work for me (they generate their own errors).

Is this fixable through some modification of the above code and/or adopting a different version of these tools (e.g Debian/Wheezy - as yet untried - has PGF 2.10 while Squeeze is on 2.00), or is it just a fundamental limitation and I'm trying to push these tools too far ?

-
I get the same errors on an up-to-date texlive 2011. A hack (perhaps ugly, perhaps necessary) to get round this would be to create the picture in a regular document ('article' or similar), externalize it, and then include it at the appropriate scale in your beamerposter. Of course, if it is to interact with other objects on the poster then this is null and void – cmhughes Jun 19 '12 at 4:04
No problem here with pgf 2.1 normal or cvs. perhaps, you can avoid positioning, and create a small picture and then scale it. – Alain Matthes Jun 19 '12 at 6:08
But in your case with matrixand text width, a workaround is not obvious ! – Alain Matthes Jun 19 '12 at 6:59
Sorry I've the problem but with textmate. The mistake appears in the file .log but I get a pdf ?? with all the edges ?? – Alain Matthes Jun 19 '12 at 8:42
"I'm using Debian/Squeeze with its texlive-full package installed." Please see How to install “vanilla” TeXLive on Debian or Ubuntu?. Debian comes with an totally outdated TeX Live. – Martin Scharrer Jun 19 '12 at 8:43

Update

The problem appears only with the edges. A possibility is to scale only the edges. Firstly we get the coordinates, then we divide them by 10 and finally we scale the coordinates by 10. I changed some styles from the original code.

\documentclass[onlymath]{beamer}
\usefonttheme{serif}
\usepackage[orientation=portrait,size=a0,scale=1.0]{beamerposter}
\usepackage{eulervm}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,matrix}

\begin{document}
\begin{frame}[t,fragile]{}

\begin{block}{Big TikZ Test}
\begin{center}

\begin{tikzpicture}[blk/.style= {rectangle,draw,text width=2in,text centered},
edge/.style = {draw =black!50 ,line width=3pt,->}]

\matrix[row sep=1cm,column sep=1cm] {%
\node[blk] (a) {A};
&
\node[blk] (b) {B};
&
\node[blk] (c) {C};
&
\node[blk] (d) {D};
&
\node[blk] (e) {E};
&
\node[blk] (f) {F};
&
\node[blk] (g) {G};
&
\node[blk] (h) {H};
&
\node[blk] (i) {I};
&
\node[blk] (j) {J};
\\
};

\path[edge] (j) edge [bend left=30] (i)
edge [bend left=30] (h)
edge [bend left=30] (g)
edge [bend left=30] (f)
edge [bend left=30] (e);

\path (a.south);
\pgfgetlastxy{\ax}{\ay}
￼\path (b.south);
\pgfgetlastxy{\bx}{\by}
￼\path (c.south);
\pgfgetlastxy{\cx}{\cy}
￼\path (d.south);
\pgfgetlastxy{\dx}{\dy}
\begin{scope} [scale=10]
\path[edge] (j) edge [bend left=30] (0.1*\dx,0.1*\dy)
edge [bend left=30] (0.1*\cx,0.1*\cy)
edge [bend left=30] (0.1*\bx,0.1*\by)
edge [bend left=30] (0.1*\ax,0.1*\ay);
\end{scope}
\end{tikzpicture}
\end{center}
\end{block}
\end{frame}
\end{document}


There is another problem, when we crate the edges, in the log I see

Missing character: There is no ï in font nullfont!
Missing character: There is no ¿ in font nullfont!
Missing character: There is no ¼ in font nullfont!
Missing character: There is no ï in font nullfont!
Missing character: There is no ¿ in font nullfont!
Missing character: There is no ¼ in font nullfont!
Missing character: There is no ï in font nullfont!
Missing character: There is no ¿ in font nullfont!
Missing character: There is no ¼ in font nullfont!


One warning for one edge

update 2

Perhaps it's a bug in 'to'. I try with controls and the code compiles without errors. I used some control points but without calculations.

\begin{tikzpicture}[blk/.style= {rectangle,draw,text width=2in,text centered},
edge/.style = {draw =black!50 ,line width=3pt,->}]

\matrix[row sep=1cm,column sep=1cm] {%
\node[blk] (a) {A};
&
\node[blk] (b) {B};
&
\node[blk] (c) {C};
&
\node[blk] (d) {D};
&
\node[blk] (e) {E};
&
\node[blk] (f) {F};
&
\node[blk] (g) {G};
&
\node[blk] (h) {H};
&
\node[blk] (i) {I};
&
\node[blk] (j) {J};
\\
};

\path[edge] (j) edge [bend left=30] (i)
edge [bend left=30] (h)
edge [bend left=30] (g)
edge [bend left=30] (f)
edge [bend left=30] (e);
\path[edge] (j) .. controls ([{shift=(210:20)}]j) and ([{shift=(-30:20)}]d) .. (d);
\path[edge] (j) .. controls ([{shift=(210:25)}]j) and ([{shift=(-30:25)}]c) .. (c);
\path[edge] (j) .. controls ([{shift=(210:30)}]j) and ([{shift=(-30:30)}]b) .. (b);
\path[edge] (j) .. controls ([{shift=(210:35)}]j) and ([{shift=(-30:35)}]a) .. (a);

\end{tikzpicture}

-
Tried your second solution and it works well enough. I'm relieved to discover that the problem seems to be associated specifically with "bend" rather than any sort of long line or large graphic, which hopefully means there won't be too much of this sort of intervention needed (come to think of it, 16000pt is over 18ft so it makes sense the blow-up is in some internally calculated value rather than an actual length on even an A0 page). – timday Jun 20 '12 at 12:43
@timday I presented the problem to M. Wibrow (author of some codes in pgfmath) and for him, there is no solution to this problem because to-paths uses (necessarily) complex way involving lots of transforms. Perhaps, Mister Sherlock Stacey can find something in the entrails of TikZ. – Alain Matthes Jun 20 '12 at 19:35

use

\begin{tikzpicture}[scale=10]
\tikzstyle{blk} = [rectangle,draw,text width=0.2in,text centered];
\tikzstyle{edge} = [draw,line width=0.5pt,black!50];
\matrix[row sep=0.1cm,column sep=0.1cm] {

-
Herbert, do you have the error with the orignal code? I don't understand why is fine for me? Logically the problem comes from a dimension > 16 384 pt. A control point with to[bend]? – Alain Matthes Jun 19 '12 at 8:34
yes, I get an error with current TeXLive – Herbert Jun 19 '12 at 8:41
Just tried this myself and unfortunately it doesn't work for me. The picture certainly shrinks way down, but the [scale=10] which is presumably intended to scale it back up seems to have no effect (in fact the result is identical whether I have [scale=10] present or not). (Maybe scale not doing anything is a symptom of my old Texlive though?) – timday Jun 20 '12 at 12:17
Altermundus: yes if I remove the ,bend left=30 from the problem paths, then the error doesn't happen for me. Of course it doesn't draw what I wanted either, but interesting that it seems implicate some internal calculations associated with bend rather than just sheer line length as I was assuming. – timday Jun 20 '12 at 12:27