2

When I use the following code

\documentclass{article}
\usepackage[edges]{forest}

\begin{document}
    
\begin{forest}
  for tree={
    grow'=east,
    anchor=west,
    font=\itshape,
    forked edge,
    fork sep = 2mm, 
    l sep=4mm,
    s sep=2mm,
  },
  s sep=2mm,
 delay={   where content={}{coordinate}{}, },
  [XXX-root,
   [ % 1
    [ % 2
     [XXX-children-A
      [XXX-children-B]
      [XXX-children-C]
     ] 
     [XXX-children-D]
    ]
    [ % 3
     [XXX-children-E]
     [XXX-children-F
      [XXX-children-G]
       [ % 4
        [XXX-children-H]
        [XXX-children-I]
       ]
     ]
    ]
   ]
   [ % 5
    [ % 6
     [XXX-children-J]
     [XXX-children-K]
    ]
    [ % 7
      [XXX-children-L]
      [XXX-children-M
        [XXX-children-N]
        [ % 8
         [XXX-children-O]
         [ % 9
          [XXX-children-P]
          [ % 10
          [ % 11
             [XXX-children-Q]
             [XXX-children-S]
         ]
         [ % 12
            [XXX-children-T]
            [XXX-children-U]
          ]
          ]
         ]
        ]
      ]
    ] 
   ]
  ]
\end{forest}
\end{document}

Everything works fine. However, if I change the text in the nodes in the following code

\documentclass{article}
\usepackage[edges]{forest}

\begin{document}
\begin{forest}
  for tree={
    grow'=east,
    anchor=west,
    font=\itshape,
    forked edge,
    fork sep = 2mm, 
    l sep=4mm,
    s sep=2mm,
  },
  s sep=2mm,
 delay={   where content={}{coordinate}{}, },
  [Nymphalidae,
   [ % 1
    [ % 2
     [Limenitidinae
      [Neptini]
      [Limenitidini]
     ]
     [Heliconiinae]
    ]
    [ % 3
     [Apaturinae]
     [Nymphalinae
      [Nymphalini]
       [ % 4
        [Junoniini]
        [Melitaeini]
       ]
     ]
    ]
   ]
   [ % 5
    [ % 6
     [Libytheinae]
     [Danainae]
    ]
    [ % 7
      [Charaxinae]
      [Satyrinae
        [Elymniini]
        [ % 8
         [Coenonymphini]
         [ % 9
          [Ypthimini]
          [ % 10
          [ % 11
             [Melanargiini]
             [Satyrini]
         ]
         [ % 12
            [Maniolini]
            [Erebiini]
          ]
          ]
         ]
        ]
      ]
    ]
   ]
  ]
\end{forest}

\end{document}

I get the error message ! Dimension too large. \pgf@x

If I change null nodes 11 and 12 to nodes with one or more characters in them everything works fine. This is very confusing, as the only difference between the two pieces of code is the text in each node.

2

I do not know why precisely there is this error. However, it seems that the purpose of using coordinates is to avoid gaps. Here is a workaround that also avoids the gaps: replace the empty nodes by some short horizontal line stretches.

\documentclass{article}
\usepackage[edges]{forest}

\begin{document}
\begin{forest}
  for tree={
    grow'=east,
    anchor=west,
    font=\itshape,
    forked edge,
    fork sep = 2mm, 
    l sep=4mm,
    s sep=2mm,
  },
  s sep=2mm,
 delay={   where content={}{outer sep=0pt,inner sep=0pt,
    append after command={(\tikzlastnode.west) edge (\tikzlastnode.east)}}{}, },
  [Nymphalidae,
   [ % 1
    [ % 2
     [Limenitidinae
      [Neptini]
      [Limenitidini]
     ]
     [Heliconiinae]
    ]
    [ % 3
     [Apaturinae]
     [Nymphalinae
      [Nymphalini]
       [ % 4
        [Junoniini]
        [Melitaeini]
       ]
     ]
    ]
   ]
   [ % 5
    [ % 6
     [Libytheinae]
     [Danainae]
    ]
    [ % 7
      [Charaxinae]
      [Satyrinae
        [Elymniini]
        [ % 8
         [Coenonymphini]
         [ % 9
          [Ypthimini]
          [ % 10
          [ % 11
             [Melanargiini]
             [Satyrini]
         ]
         [ % 12
            [Maniolini]
            [Erebiini]
          ]
          ]
         ]
        ]
      ]
    ]
   ]
  ]
\end{forest}

\end{document}

enter image description here

3
  • Good workaround! I'm investigating the source of the error (but don't have much time for it). – Sašo Živanović Nov 3 '20 at 15:28
  • @SašoŽivanović Thanks! Nice to meet you! Believe it or not, I was just looking at this post of yours. – user227987 Nov 3 '20 at 15:34
  • Small world ;-) Yes, I volunteered for maintanence of trace-pgfkeys ... and I plan to get back to it soon(ish). – Sašo Živanović Nov 4 '20 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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