Tikz:圖形:在樹佈局中水平和垂直移動子層/級別?

Tikz:圖形:在樹佈局中水平和垂直移動子層/級別?

這與目錄列表略有不同,如下所示範例繪製一個目錄,列出 TikZ 中的樹命令我想註釋顯示文件之間連結的最終結構。我需要一些方法來引用樹中的節點,以下似乎是我的選擇

  1. 使用tabbing環境來佈局樹結構,利用tikzmark註解節點。
  2. 在環境中使用graphs或庫。treestikzpicture
  3. dirtree將和forest軟體包與先前的設定(1 或 2)結合使用。

方法1給了我想要的輸出,但是如果樹延伸超過一頁,使用multicols和,註釋就會變得混亂minipage沒有改進這一點。我目前正在考慮方法2如果失敗會嘗試3

我希望以下樹中的子層使用 TikZ graphdrawings' 繪製tree layout

目前佈局

可以嵌套在它們的父級之間,就像在使用 TikZ 庫庫的第二個佈局中trees一樣循環空間的 dirtree鑰匙,

首選佈局

,並且不對稱地以扇形分佈在它們周圍。

我的假設(可能是錯誤的)是圖形繪製庫將允許人們將子圖操縱到首選位置。然而,與其他 TikZ 庫不同graphs, 和的介面graphdrawing似乎相當隔離。我遇過的例子如下

  • tries金鑰使某些佈局正確,但如果使用子圖則會中斷。
  • 設定grow down sep給出了正確的結構,但我不知道如何進一步調整它,並且子圖佈局會忽略它。
  • 使用tree layout允許子圖,但對其放置沒有太多控制。

下面的程式碼產生第一張圖像。在其中,我為第一個子層指定了一個微移值,該值按預期偏移下一個子層,但不是其節點(右上角的浮動矩形)。嘗試提供幻象值也會失敗,如最低層中的錯誤箭頭所示。

\documentclass[tikz]{standalone}%
\usepackage{tikz}%
%
\usepackage{luatex85}%
\usepackage{menukeys}%
\usetikzlibrary{graphs}%
\usetikzlibrary{graphdrawing}%
\usegdlibrary{trees}%
\usegdlibrary{layered}%
\usegdlibrary{circular}%
%
\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=\tikzleveldistance
  \pgf@ya=-\tikzsiblingdistance
  \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,
    level distance =1.2em,
    sibling distance =1.2em,
    growth parent anchor=west,
%     every node/.style={anchor=west},
%     every parent node/.style={anchor=south west},
    every child node/.style={anchor=west},
    edge from parent path={(\tikzparentnode.south west) ++(0.5*\tikzleveldistance,0) |- (\tikzchildnode\tikzchildanchor)}
  }
}
\makeatother
%
\newmenumacro{\nixpath}[/]{hyphenatepathswithfolder}
\newmenumacro{\nixfile}[/]{hyphenatepaths}
\newmenumacro{\winpath}[bslash]{hyphenatepathswithfolder}
\newmenumacro{\winfile}[bslash]{hyphenatepaths}
%
\begin{document}%
\normalsize%
\begin{tikzpicture}%
\graph [tree layout, grow'=right]
 {"00"/"\winpath{E:\CheatSheets\Algorithms}" -> 
  {"01"/"\winpath{Genetic}";
   "02"/"\winpath{Linear_Programming}" -> 
   {"03"/"\winpath{build}";
    "04"/"\winfile{Affine_Scaling.pseudo.tex}"};
   "05"/"\winpath{build}";
   "06"/"\winfile{Algorithms.tex}";
   "07"/"\winfile{Genetic.tex}";
   "08"/"\winfile{input.tex}";
   "09"/"\winfile{input2.tex}";
   "10"/"\winfile{input3.tex}"}};%
\end{tikzpicture}%
\begin{tikzpicture}%
\node (00) {\winpath{E:\CheatSheets\Algorithms}}[dirtree]
 child {node (01) {\winpath{Genetic}}}
 child {node (02) {\winpath{Linear_Programming}}
 child {node (03) {\winpath{build}}}
  child {node (04) {\winfile{Affine_Scaling.pseudo.tex}}}}
 child {node (05) {\winpath{build}}}
 child {node (06) {\winfile{Algorithms.tex}}}
 child {node (07) {\winfile{Genetic.tex}}}
 child {node (08) {\winfile{input.tex}}}
 child {node (09) {\winfile{input2.tex}}}
 child {node (10) {\winfile{input3.tex}}} ;%
\graph [use existing nodes]
{06      ->[in=0, out=0, looseness=3] {04     }};%
\end{tikzpicture}%
\end{document}

我還想使用|-線路規範,但似乎無法在/tikz/graphs/edges鍵內設定它。我的理解是,邊緣是用to[...]命令繪製的,而不是--/ |-/-|命令。實際上,我想將繪圖機制從「降級」to[...]|-使用 Tikz 3.0 樹狀圖叉下邊緣樣式問了類似的問題。該topath庫(pgfmanual 3.0.1a 版本中的第 70 節)允許使用直線,to[line]但沒有提及肘部。

目前我正在嘗試將 和trees一起嘗試graph,前者進行佈局,後者進行註釋。

我認為主要問題實際上是“如何控制子圖的放置而不是輕推它們”。這實際上layered layout可能嗎tree layoutgraphdrawing

相關內容