Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a problem with the following code:

\begin{tikzpicture} [level distance=4mm]
    \path [
        every node/.style={ball color=red,inner sep=1.5pt},
        level 2/.style={sibling distance=22mm},
        level 5/.style={sibling distance=3mm}
        ]
        node{} child foreach \perI in {1,...,6} {
            node{} child { node{} child { node{} child {
            node{} child foreach \perII in {1,...,5} {
                node{} child { node{} child { node{} child { node{} child {
                node{} child { node{} child { node{} child { node{} child {
                node{} child { node{} child { node{} child { node{} child {
                node{} child { node{} child { node{} child { node{} child {
                node{} child { node{} child { node{} child { node{} child {
                    node{}
                }}}}}}}}}}}}}}}}}}}}
            }}}}
        }
    ;
\end{tikzpicture}

When I compile it with pdflatex (using MiKTeX), I get the following error message:

! TeX capacity exceeded, sorry [grouping levels=255].

I guess I hit a bound on the level of recursion .. Is there some way around this?
Note that I actually need an even longer tree (48 levels in total) - do not ask why, long story..

My only idea is to generate the long path under the second foreach command in advance and then re-use it in each node, i.e. 30 times - but I do not know how to do this.
(I tried \path[save to=\tmpPath], but it seems to save it with absolute co-ordinates, so I did not manage to get the 30 copies I need.)

share|improve this question
2  
I know you said "don't ask why" but… why? –  Seamus Mar 29 '12 at 8:04
    
The example compiles fine if you use lualatex (instead of pdflatex), because it can dynamically increase the memory limits. –  Jake Mar 29 '12 at 9:13
    
@Seamus The tree represents a structure in my code, for which I am writing documentation. –  Michal Kaut Mar 29 '12 at 10:39
    
@Jake That works, thanks - but I am co-writing the document with more people, and they have not even heard of lualatex, and have their TeX-editors set up for pdflatex.. –  Michal Kaut Mar 29 '12 at 10:57
    
Just prepare the tree in a document with the standalone class, compile it and include the PDF. –  egreg Mar 29 '12 at 11:52

2 Answers 2

up vote 3 down vote accepted

You could use a chain instead of children for the long path at the bottom. If you use node distance=\tikzleveldistance, on grid, join, the placement of the nodes will be the same as for the tree levels, and you'll get connecting lines between the nodes.

This will compile using pdflatex:

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots, pgfplotstable}
\usetikzlibrary{chains}

\pgfplotstableread{volcano.dat}\datatable



\begin{document}
\begin{tikzpicture} [level distance=4mm]
    \path [
        every node/.style={ball color=red,inner sep=1.5pt},
        level 2/.style={sibling distance=22mm},
        level 5/.style={sibling distance=3mm}
        ]
        node{} child foreach \perI in {1,...,6} {
            node{} child { node{} child { node{} child {
            node{} child foreach \perII in {1,...,5} {
                node [start chain=going below]{}
                \foreach \perIII in {1,...,25}{
                    node [node distance=\tikzleveldistance,
                        on grid,
                        on chain,
                        join
                    ] {}
                    }
                }   
            }
            }}
        }
    ;
\end{tikzpicture}


\end{document}
share|improve this answer
    
Thanks, this is exactly what I needed! Works like a charm :-) –  Michal Kaut Mar 30 '12 at 7:50
    
One extra observation: if I use scale for the whole tikzfigure, then the distances between the first type of nodes get scaled, but not the distances between nodes on the chain - so I have to multiply the \tikzleveldistance in node distance by the scale manually.. –  Michal Kaut Mar 30 '12 at 8:53

Check this

\begin{tikzpicture} [level distance=4mm]
    \path [
        every node/.style={ball color=red,inner sep=1.5pt},
        level 2/.style={sibling distance=22mm},
        level 5/.style={sibling distance=3mm}
        ]
        node{} child foreach \perI in {1,...,6} {
            node{} child { node{} child { node{} child {
            node{} child foreach \perII in {1,...,5} {
                node{} child { node{} child { node{} child { node{} child {
                node{} child { node{} child { node{} child { node{} child {
                node{} child { node{} child { node{} child { node{} child {
                node{} child { node{} child { node{} child { node{} child {
                node{} child { node{} child { node{} child { node{} child {
%                    node{}
                }}}}}}}}}}}}}}}}}}}}
            }}}}
        }
    ;
\end{tikzpicture}
share|improve this answer
    
I think that's what the OP was trying to show, that the last node breaks the example. –  Jake Mar 30 '12 at 7:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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