I have the following tree produced by the LaTeX code at the end, which is a modification from Drawing a directory listing a la the tree command in TikZ
My problem: When I have a lot of nodes, I get Dimension too large error, as shown in the second picture. I saw something like \pgfkeys{/pgf/fpu=true}, but I can't make it work in my code. I need help to allow any number of nodes other than reducing the size of each node and the distances between them.
\documentclass{standalone}
\usepackage[english, french]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{hyperref}
\usepackage{amsmath}
\makeatletter
\newcount\dirtree@lvl
\newcount\dirtree@plvl
\newcount\dirtree@clvl
\def\dirtree@growth{%
\ifnum\tikznumberofcurrentchild=1\relax
\global\advance\dirtree@plvl by 1
\expandafter\xdef\csname dirtree@p@\the\dirtree@plvl\endcsname{\the\dirtree@lvl}
\fi
\global\advance\dirtree@lvl by 1\relax
\dirtree@clvl=\dirtree@lvl
\advance\dirtree@clvl by -\csname dirtree@p@\the\dirtree@plvl\endcsname
\pgf@xa=1.15cm\relax
\pgf@ya=-1.45cm\relax
\pgf@ya=\dirtree@clvl\pgf@ya
\pgftransformshift{\pgfqpoint{\the\pgf@xa}{\the\pgf@ya}}%
\ifnum\tikznumberofcurrentchild=\tikznumberofchildren
\global\advance\dirtree@plvl by -1
\fi
}
\tikzset{
dirtree/.style={
growth function=\dirtree@growth,
every node/.style={anchor=south},
every child node/.style={anchor=west},
edge from parent path={(\tikzparentnode\tikzparentanchor) |- (\tikzchildnode\tikzchildanchor)}
}
}
\makeatother
\makeatletter
\newcommand*\mylabel[2]{%
\immediate\write\@auxout{\string\newlabel%
\string{#1\string}%
\string{\string{#2\string}%
\string{\thepage\string}\string}}%
}
\makeatother
\makeatletter
\begin{document}
\begin{tikzpicture}[dirtree, event/.style={rectangle,thick,draw,fill=yellow!20,
anchor=south}, level 1/.style={nodes=event}, line width=0.75mm]
\node[event] {Master}
child { node {1}
child { node {1-1}
}
child { node {1-2}
}
}
child { node {2}
child { node {2-1}
}
child { node {2-2}
}
}
;
\end{tikzpicture}
\end{document}
Update: Zarko's answer (forest) doesn't help me:



forestis a better option for trees. – Ignasi Mar 22 '18 at 14:50forestand compiling with lualatex? It dynamically allocates memory and is less likely to give out of memory errors. – Hood Chatham Mar 23 '18 at 22:25save sizecan be altered. See egreg's comment at https://tex.stackexchange.com/questions/234095/forest-causing-pdflatex-to-run-out-of-memory#comment554612_234095. – cfr Mar 29 '18 at 20:05