TikZ 树 - 太大(很多节点)

TikZ 树 - 太大(很多节点)

我在最后用 LaTeX 代码生成了以下树,它是对使用 TikZ 中的 tree 命令绘制目录列表

我的问题:当我有很多节点时,我得到尺寸太大错误,如第二张图片所示。我看到了类似的东西\pgfkeys{/pgf/fpu=true},但我无法在我的代码中让它工作。我需要帮助来允许任意数量的节点,而不是减少每个节点的大小和它们之间的距离。

enter image description here

enter image description here

\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}

更新:Zarko 的回答(森林)对我没有帮助:

enter image description here

相关内容