This differs slightly from directory listing as at TeXample and Drawing a directory listing a la the tree command in TikZ in that I'd like to annotate the final structure showing links between the files. I need some means of referring back to the nodes in the tree and the following seems to be my options
- Use a
tabbingenvironment, to layout the tree structure leveragingtikzmarkto annotate the nodes. - Use either the
graphsor thetreeslibraries within atikzpictureenvironment. - Use the
dirtreeandforestpackages in some combination with the previous setups (1 or 2).
Method 1 gave me the desired output but the annotations got all muddled if the tree extended across more then one page, using multicols and minipage did not improve this. I am currently considering method 2 and if that fails will try 3.
My hope was that the sublayers in the following tree, drawn using TikZ graphdrawings' tree layout,
could be nested between their parents, as in the second layout using the TikZ library trees library and Loop Space's dirtree key,
, and not symmetrically spread in a fan about them.
My assumption, probably in error, was that the graph drawing library would allow one to manipulate the subgraphs into the preferred position. However the interface for the graphs and graphdrawing seems to be rather segregated unlike the other TikZ libraries. The examples I've encountered are as follows
- The
trieskey gets some of the layout correct but breaks if using subgraphs. - Setting
grow down sepgives the correct structure but I can't see how to tweak it further and it's ignored for subgraph layouts. - Using
tree layoutallows subgraphs but not much control over their placement.
The code below produces the first image. Within it I specify a nudge value for the first sublayer which offsets the next sublayer as expected but not its' node, the floating rectangle in the upper right. Trying to provide phantom values also fails as seen by the errant arrows in the lowest layer.
\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}
I would also like to use the |- line specification but can't seem to set that within the /tikz/graphs/edges key. My understanding is that the edges are drawn with to[...] commands versus the --/|-/-| commands. Effectively I would like to "down grade" the drawing mechanism from to[...] to |-. Fork down edge style with Tikz 3.0 tree graph asks a similar question. The topath library, section 70 in version 3.0.1a of the pgfmanual, allows one to use a straight line as in to[line] but makes no mention for elbows.
At present I'm trying both the trees and graph together, the former doing the layout and the latter the annotations.
I think the main question really is "how to control the placement of subgraphs beyond nudging them about". Is this actually possible reading the manual leads one to believe so but I couldn't find a nice example on how to do so and I went through the layered layout, tree layout and graphdrawing sections quite thoroughly I felt.


standaloneclass does not accomodate tabbing environments and one is forced to setcrop=falsewhich falls to thearticleclass. This exlcudes a monolithic tabbed page. By switching to a tikzpicture I can have a monolithic graph or tikzpicture. Negating the need to deal with page breaks until another time. I noticed that the TikZmark documentation mentions some functionality for page breaks but I have not fully explored it. – Carel May 02 '17 at 00:07treeslibrary, an update to Loop Spaces' code, and thegraphslibrary. I've updated the original code accordingly contrasting what I get with what I want. Now it's more of an interest to know whether or not it's possible to manipulate the tree layout but I'd make it a low priority question :) If you want to see my script eventually let me know, my intention is to include it with Pythons'PyLaTeXpackage though. – Carel May 02 '17 at 00:22folderstyle from theedgeslibrary, but has a very different syntax. – cfr May 03 '17 at 02:21