# Dimension too large error (apparently no calculation involved)

From what I have read so far, a Dimension too large! is caused by a result or an intermediate calculation that goes beyond the limit of 16384.

I get this error with this document (note: the doubledash setting comes from this answer; and using 2pt instead of 2.5pt does not solve the case.):

\documentclass[a4paper,12pt]{article}

\usepackage{tikz}
\usetikzlibrary{angles,decorations.markings}

\tikzset{doubledash/.style={decoration={ markings, %
mark= at position 0.5
with{
\draw (-1pt,-2.5pt) -- (-1pt,2.5pt);
\draw (1pt,-2.5pt) -- (1pt,2.5pt);
} },
pic actions/.append code=\tikzset{postaction=decorate}}}

\begin{document}

\begin{tikzpicture}
% Text font size
\scriptsize

% Declare Points
\coordinate (G) at (0,0);
\coordinate (U) at (1.5,0);
\coordinate (M) at (0.75,0.661);

% Draw IsoscelesTriangle
\draw[thick] (G)
-- (U)
-- (M)
-- cycle
pic [draw, thick, angle radius = 0.25 cm, doubledash] {angle = U--G--M}
pic [draw, thick, angle radius = 0.25 cm, doubledash] {angle = M--U--G};

% Label Points
\draw (G) node[left] {G};
\draw (U) node[right] {U};
\draw (M) node[above] {M};
\end{tikzpicture}

\end{document}


Exact error message:

! Dimension too large.
\relax
l.31 ...ius = 0.25 cm, doubledash] {angle = U--G--M}


The doubledash hatchmarks seem necessary to get the error, if both of them are removed, then the document compiles:

I guess the 16384 limit has been reached by some internal calculation were the doubledash is involved, but how exactly, I have no idea...

It's worth noticing that other pictures did compile while preserving the doubledash but that some of them required to round the coordinates to the tenth, what, in the case of an isosceles triangle, is not really satisfying since the triangle then looks slightly slanted. In the example above, this solution actually "works" too, but required to round the coordinates of M to the unit, what is even worse (after that, the triangle doesn't look isosceles at all!).

## Some more context

I am currently working on a software library (written in python) that creates such TikZ code in an automated way and I need to be able to anticipate when this error will be triggered, in order to produce a compilable picture. It's not possible to try to compile the produced code and then try again and again with slightly different values until it's "ok" (and the picture maybe quite different than expected).

## Question

How to ensure that the document will compile before trying to compile?

EDIT: from Zarcos' answer, it seems that increasing the angle's radius solves the problem. But how is it possible to anticipate which minimal value will be required for the picture to compile well? (The 1st example requires 0.35 cm, and the 2d example, below, requires 0.85 cm).

## Extra example that does not compile, yet with a larger radius

\documentclass[a4paper,12pt]{article}

\usepackage{tikz}
\usetikzlibrary{angles,decorations.markings,quotes}

\tikzset{doubledash/.style={decoration={ markings, %
mark= at position 0.5
with{
\draw (-1pt,-2pt) -- (-1pt,2pt);
\draw (1pt,-2pt) -- (1pt,2pt);
} },
pic actions/.append code=\tikzset{postaction=decorate}}}

\begin{document}

\begin{tikzpicture}
% Text font size
\scriptsize
% Declare Points
\coordinate (A) at (0,0);
\coordinate (E) at (-1.35,1.609);
\coordinate (F) at (-1.837,1.018);

% Draw Angles
\draw[thick] (E) -- (A) -- (F)
pic ["$\alpha$", draw, angle eccentricity=1.3333, angle radius = 0.84 cm, thick, doubledash] {angle = E--A--F};

% Label Points
\draw (A) node[below] {A};
\draw (E) node[above] {E};
\draw (F) node[below left] {F};
\end{tikzpicture}

\end{document}

• Print out the source and let an assistant proofread it. – Johannes_B Feb 28 '18 at 7:33
• @Johannes_B I am not sure to understand, what do you mean? What assistant? (PS if this is unclear, let me precise that I work on a library, written in python, not at a library. I will edit the question to make it clear) – zezollo Feb 28 '18 at 7:40
• @Zarko enlarging the angle radius seems to work, but 4 mm is not enough is another document (I add it as an extra example) where using 1 cm instead or 0.84 cm is enough. How to anticipate the minimal radius value? – zezollo Feb 28 '18 at 8:41
• Let a person proofread your code. Not really being serious in 2018, where PCs are very fast. – Johannes_B Feb 28 '18 at 9:14
• @Johannes_B : ??? – AlexG Feb 28 '18 at 9:18

You can add \tracingmacros=1 to your code before the \draw command.

Then you can look in the log-file and it is rather easy to see a few lines before the error (around line 84000) that pgf is just trying to calculate the reciprocal of a rather small number (0.00006).

       \pgfmath@reciprocaltemp ->0.00006


You could -- if you have lot time -- go back through the calculations and try to figure out the math involved and what this means for your starting values. But imho the core problem is that the math library is not so good.

The fpu library handles this numbers better, but loading it doesn't replace the relevant pgf commands and so don't help currently. You could make a feature request for it.

The xfp-package handles this values too without problems. So an alternative is to wait for Joseph Wright to finish l3draw so that it could be used as basic layer for tikz.

\documentclass[a4paper,12pt]{article}

\usepackage{tikz}
\usetikzlibrary{fpu}
\usepackage{xfp}
\begin{document}

%\pgfmathreciprocal{0.00006} %error

\makeatletter
\pgfmathfloatparsenumber{0.00006}
\pgfmathfloatreciprocal@{\pgfmathresult}
\pgfmathfloattofixed{\pgfmathresult}
\pgfmathresult
\makeatother

\fpeval{1/0.00006}

\end{document}


• l3draw is out. Can you update the answer? – azetina Jan 8 '20 at 3:11
• @azetina l3draw was "out" already when I wrote the answer, but that doesn't mean that you can use it as basic layer for tikz. – Ulrike Fischer Jan 8 '20 at 7:34

your angle radius is to small. enlarge it to 4mm. also observe small differences between yours and mine code:

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{angles,decorations.markings}
\tikzset{
doubledash/.style={decoration = { markings, %
mark= at position 0.5
with{
\draw[thin] (-0.6pt,-2pt) -- (-0.6pt,2pt);
\draw[thin] ( 0.6pt,-2pt) -- ( 0.6pt,2pt);
}},
pic actions/.append code=\tikzset{postaction=decorate}
},
myangle/.style={draw, semithick, angle radius = 3.5mm, doubledash}
}

\begin{document}
\begin{tikzpicture}
% Text font size
\scriptsize
% Declare Points with labels
\coordinate[label= left:G]  (G) at (0,0);
\coordinate[label=right:U]  (U) at (1.5,0);
\coordinate[label=M]        (M) at (0.75,0.661);
% Draw IsoscelesTriangle
\draw[thick] (G) -- (U) -- (M) -- cycle
pic [myangle] {angle = U--G--M}
pic [myangle] {angle = M--U--G};
\end{tikzpicture}
\end{document}


i also made code slightly shorter.

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{angles, decorations.markings, quotes}
\tikzset{
doubledash/.style={decoration = { markings, %
mark= at position 0.5
with{
\draw[thin] (-0.6pt,-2pt) -- (-0.6pt,2pt);
\draw[thin] ( 0.6pt,-2pt) -- ( 0.6pt,2pt);
}},
pic actions/.append code=\tikzset{postaction=decorate}
},
myangle/.style={draw, semithick,
angle radius = 3.5mm, angle eccentricity=1.5, doubledash},
}

\begin{document}
\begin{tikzpicture}
% Text font size
\scriptsize
% Declare Points with labels
\coordinate[label= left:G]  (G) at (0,0);
\coordinate[label=right:U]  (U) at (1.5,0);
\coordinate[label=M]        (M) at (0.75,0.661);
% Draw IsoscelesTriangle
\draw[thick] (G) -- (U) -- (M) -- cycle
pic [myangle,"$\alpha$"] {angle = U--G--M}
pic [myangle,"$\alpha$"] {angle = M--U--G};
\end{tikzpicture}
\end{document}


• Okay, but how can I know what is the minimal value that must be used for the radius? (See the extra example I added where the minimal value is higher). Anyway, thanks for this hint and for the other code optimizations. – zezollo Feb 28 '18 at 8:46
• @zezollo, experiences? and observe differences between your and mine code. i tested your code and it not work, as you say, however, including angle name in mine works. see addendum to my answer. – Zarko Feb 28 '18 at 8:58
• I need to know in advance which minimal value will be required for the radius and I don't see how I can know that. The 1st example requires at least 0.35 cm to compile. The 2d example does not work, and would work up from a radius of 0.85 cm. How could I have known that 0.84 cm was not enough, before trying to compile? – zezollo Feb 28 '18 at 10:28
• first you should make code compilable. with my code it works wit 3.5 mm! again, observe difference in code. and after some experiences you will able to estimate what is sensible. otherwise, try to compare the size doubledash and angle radius. you might find some rule of the thumb :-). or wait on answer, which will provide ai which will able do, what you so persistent require. – Zarko Feb 28 '18 at 10:35
• I am sorry to make this persistent requirements, but the library that writes this code is used in a software that produces a lot of pictures automatically. If one fails to compile, then the software crashes, I cannot push this into production. So, from @Ulrike Fischer 's answer, I guess I will indeed have to guess a rule of thumb that would be a sufficient workaround for the moment. So. Both your, and her, answers are interesting but her answer addresses exactly my question, so I will accept it. – zezollo Feb 28 '18 at 10:47