%% LaTeX2e file `etocsnippet-27.tex' %% generated by the `filecontentsdef' environment %% from source `etoc' on 2021/09/23. %% % \newtoks\treetok % put this (uncommented) preferably in the preamble % \newtoks\tmptok % (idem) \newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2 #1\expandafter\expandafter\expandafter {\expandafter\the\expandafter #1#2}} \newcommand*\PrepareSectionNode{% \tmptok {\centering\bfseries}% \appendtotok\tmptok\etocthelinkedname \edef\foresttreenode{ [{\noexpand\parbox{2cm}{\the\tmptok}}}% } \newcommand*{\PrepareSubsectionNode}{% \tmptok {\raggedright}% \appendtotok\tmptok\etocthelinkedname \edef\foresttreenode{ [{\noexpand\parbox{6cm}{\the\tmptok}}}% } \etocsetstyle{section} {\etocskipfirstprefix} {\appendtotok\treetok{ ]}} {\PrepareSectionNode \appendtotok\treetok\foresttreenode} {\appendtotok\treetok{ ]}} \etocsetstyle{subsection} {\etocskipfirstprefix} {\appendtotok\treetok{ ]}} {\PrepareSubsectionNode \appendtotok\treetok\foresttreenode} {\appendtotok\treetok{ ]}} \etocsettocstyle {\treetok{[{\hyperref[part:overview]{Overview}}}} {\global\appendtotok\treetok{ ]}} % forest does not like @\the\treetok if \treetok is empty. On first latex % run, this will be the case because the TOC style defined above will not % have been executed, as the label {toc:overview} does not refer to a valid % TOC yet. So we must give a safe default value to \treetok \treetok{[{run latex again}]} \begin{figure}[th!]\centering \etocsetnexttocdepth{subsection} \tableofcontents \label{toc:forest}\ref{toc:overview} \hypersetup{hidelinks}% \bracketset{action character=@} \begin{forest} for tree={anchor=center,child anchor=west, grow'=east,draw,thick, edge={draw,thick,dashed,color=teal}}, where={level()==1}{circle,thick,fill=blue!5, before computing xy={l=3cm}}{}, where={level()==2}{fill=red!5, before computing xy={l=6cm}}{}, rectangle, thick, fill=cyan!5, inner sep=6pt, @\the\treetok \end{forest} \end{figure}