summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/etoc/etocsnippet-27.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/etoc/etocsnippet-27.tex')
-rw-r--r--Master/texmf-dist/doc/latex/etoc/etocsnippet-27.tex62
1 files changed, 62 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/etoc/etocsnippet-27.tex b/Master/texmf-dist/doc/latex/etoc/etocsnippet-27.tex
new file mode 100644
index 00000000000..1b79b140746
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/etoc/etocsnippet-27.tex
@@ -0,0 +1,62 @@
+%% LaTeX2e file `etocsnippet-27.tex'
+%% generated by the `filecontentsdef' environment
+%% from source `etoc' on 2019/11/17.
+%%
+% \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}