1

The following code block contains a minimal working example. It displays a group of 2 rows and 3 columns of circles that have an arrow at the top (see result in the image below).

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}

\tikzset{
  clockwise/.style={
    decoration = {
      markings,
      mark = at position 0.25 with {\arrow{<}},
    },
    postaction = {decorate}
  }
}

\begin{document}
\begin{tikzpicture}
  % Row no. 1
  \coordinate(center11) at (0,0);
  \draw[clockwise, red] (center11) circle (0.1);

  \coordinate[right = 1 of center11] (center12);
  \draw[clockwise, red] (center12) circle (0.1);

  \coordinate[right = 1 of center12] (center13);
  \draw[clockwise, red] (center13) circle (0.1);

  % Row no. 2
  \coordinate[below = 1 of center11] (center21);
  \draw[clockwise, blue] (center21) circle (0.1);

  \coordinate[below = 1 of center12] (center22);
  \draw[clockwise, blue] (center22) circle (0.1);

  \coordinate[below = 1 of center13] (center23);
  \draw[clockwise, blue] (center23) circle (0.1);
\end{tikzpicture}
\end{document}

enter image description here

I am now trying to display a group of 3 rows and 3 columns of the same circles, but I'm getting the error Dimension too large. when trying to draw the first node in the third row. The first code block below shows my attempt. The second code block below shows the last lines of the error.

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}

\tikzset{
  clockwise/.style={
    decoration = {
      markings,
      mark = at position 0.25 with {\arrow{<}},
    },
    postaction = {decorate}
  }
}

\begin{document}
\begin{tikzpicture}
  % Row no. 1
  \coordinate(center11) at (0,0);
  \draw[clockwise, red] (center11) circle (0.1);

  \coordinate[right = 1 of center11] (center12);
  \draw[clockwise, red] (center12) circle (0.1);

  \coordinate[right = 1 of center12] (center13);
  \draw[clockwise, red] (center13) circle (0.1);

  % Row no. 2
  \coordinate[below = 1 of center11] (center21);
  \draw[clockwise, blue] (center21) circle (0.1);

  \coordinate[below = 1 of center12] (center22);
  \draw[clockwise, blue] (center22) circle (0.1);

  \coordinate[below = 1 of center13] (center23);
  \draw[clockwise, blue] (center23) circle (0.1);

  % Row no. 3
  \coordinate[below = 1 of center21] (center31);
  \draw[clockwise, red] (center31) circle (0.1);
\end{tikzpicture}
\end{document}
(/gnu/store/45a6z9as21bb7l37813b36lfb9bpgvx3-texlivetexmf-20230313/share/texmf-
dist/tex/latex/l3backend/l3backend-pdftex.def)
No file main.aux.

(/gnu/store/45a6z9as21bb7l37813b36lfb9bpgvx3-texlivetexmf-20230313/share/texmf-
dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)
(/gnu/store/45a6z9as21bb7l37813b36lfb9bpgvx3-texlivetexmf-20230313/share/texmf-
dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/gnu/store/45a6z9as21bb7l37813b36lfb9bpgvx3-texlivetexmf-20230313/share/texmf-
dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! Dimension too large.
<to be read again> 
                   \relax 
l.43 ...w[clockwise, red] (center31) circle (0.1);
                                                  
? 

How to solve this problem?

1
  • Use circle (1mm) instead of circle (0.1).
    – cfr
    Mar 2 at 6:08

2 Answers 2

1

You can avoid the error by substituting 1mm for 0.1, which is equivalent.

Note that your code is then equivalent to

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}

\tikzset{
  clockwise/.style={
    decoration = {
      markings,
      mark = at position 0.25 with {\arrow{<}},
    },
    postaction = {decorate}
  }
}

\begin{document}
\begin{tikzpicture}
  \foreach \i/\k [count=\n] in {0/red,1/blue,2/red}
    \foreach \j [count=\m] in {0,1,2}
      \draw [clockwise,\k] (\j cm,\i cm) coordinate (center\n\m) circle (1mm);
\end{tikzpicture}
\end{document}

3x3 clockwise curls

You might also consider using a pic for this, but that may be unnecessarily complicated unless you need to draw a lot of them.

6
  • Thanks for the help. That got rid of the error when trying to draw the third row, but the same error arises when trying to draw the seventh row. These are the values that I used in the first \foreach: {0/red,1/blue,2/red,3/blue,4/red,5/blue,6/red}.
    – rdrg109
    Mar 2 at 12:29
  • @rdrg109 The problem is the small size of the circles are leading to large values in the calculations. You have various options: you can use one of the maths extension libraries for fixed or floating point or you can come up with workarounds (like the 1mm trick). For example, if all your rows are copies of two possibilities, you could save each to a box and then repeat the boxes as necessary. If you did that here, would you just run into the problem again in your real document? How representative is this of what you're actually doing?
    – cfr
    Mar 2 at 19:21
  • As you suggested, I ended up drawing a single row in the same tikzpicture environment and repeating that environment over and over again in order to have multiple rows. That got rid of the error. This time, that was enough to suit my needs. However, I guess at some point in the future I will do a more complex graphics and I will find the same problem, so I would appreciate you would specifically tell me the math extension libraries that I could use to avoid this problem.
    – rdrg109
    Mar 4 at 14:14
  • There's the fixedpointarithmetic library or fpu for floating point. See the pgf manual for details. Or you can do calculations in expl3 or outsource them from LaTeX completely. Generally, most graphics don't run into this problem. It's not really complexity that's the issue but size. Very small or very large dimensions get problematic. Very small ones are problematic because they require very large ones to represent them. So if your circles were a little bigger, you'd probably be fine.
    – cfr
    Mar 4 at 21:23
  • 1
    Thanks for the information. I skimmed the PGF manual and found a section called "Handling "Dimension too large" errors." which explicitly mentions fpu (the package that you mentioned). I have posted a new answer.
    – rdrg109
    Mar 8 at 3:19
1

Load the fpu tikzlibrary and use the option [/pgf/fpu/install only = {reciprocal}] as shown below. This solution is suggested in section 50.2 "Handling "Dimension too large" errors." of the PGF Manual.

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{positioning}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{fpu}

\tikzset{
  clockwise/.style={
    decoration = {
      markings,
      mark = at position 0.25 with {\arrow{<}},
    },
    postaction = {decorate}
  }
}

\begin{document}
\begin{tikzpicture}[/pgf/fpu/install only = {reciprocal}]
  % Row no. 1
  \coordinate(center11) at (0,0);
  \draw[clockwise, red] (center11) circle (0.1);

  \coordinate[right = 1 of center11] (center12);
  \draw[clockwise, red] (center12) circle (0.1);

  \coordinate[right = 1 of center12] (center13);
  \draw[clockwise, red] (center13) circle (0.1);

  % Row no. 2
  \coordinate[below = 1 of center11] (center21);
  \draw[clockwise, blue] (center21) circle (0.1);

  \coordinate[below = 1 of center12] (center22);
  \draw[clockwise, blue] (center22) circle (0.1);

  \coordinate[below = 1 of center13] (center23);
  \draw[clockwise, blue] (center23) circle (0.1);

  % Row no. 3
  \coordinate[below = 1 of center21] (center31);
  \draw[clockwise, red] (center31) circle (0.1);
\end{tikzpicture}
\end{document}

Minimal example that produces the same error

I was able to found a more minimal example that produces the same error. The following code block contains a document that compiles without errors:

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{decorations.markings}

\tikzset{
  clockwise/.style={
    decoration = {
      markings,
      mark = at position 0.25 with {\arrow{<}},
    },
    postaction = {decorate}
  }
}

\begin{document}
\begin{tikzpicture}
  \coordinate(center1) at (0, 0);
  \draw[clockwise] (center1) circle (1mm);
  \coordinate(center2) at (0, 1);
  \draw[clockwise] (center2) circle (1mm);
\end{tikzpicture}
\end{document}

The following code block adds an additional node to the example shown above and it produces the same error.

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{decorations.markings, fpu}

\tikzset{
  clockwise/.style={
    decoration = {
      markings,
      mark = at position 0.25 with {\arrow{<}},
    },
    postaction = {decorate}
  }
}

\begin{document}
\begin{tikzpicture}[/pgf/fpu/install only = {reciprocal}]
  \coordinate(center1) at (0, 0);
  \draw[clockwise] (center1) circle (1mm);
  \coordinate(center2) at (0, 1);
  \draw[clockwise] (center2) circle (1mm);
  \coordinate(center2) at (0, 2);
  \draw[clockwise] (center2) circle (1mm);
\end{tikzpicture}
\end{document}

This problem is solved by using the same solution:

\documentclass{standalone}

\usepackage{tikz}

\usetikzlibrary{decorations.markings, fpu}

\tikzset{
  clockwise/.style={
    decoration = {
      markings,
      mark = at position 0.25 with {\arrow{<}},
    },
    postaction = {decorate}
  }
}

\begin{document}
\begin{tikzpicture}[/pgf/fpu/install only = {reciprocal}]
  \coordinate(center1) at (0, 0);
  \draw[clockwise] (center1) circle (1mm);
  \coordinate(center2) at (0, 1);
  \draw[clockwise] (center2) circle (1mm);
  \coordinate(center2) at (0, 2);
  \draw[clockwise] (center2) circle (1mm);
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .