Debian Codegraph @

texmf-dist/doc/latex/etoc/etocsnippet-18.tex

raw
1 %% LaTeX2e file `etocsnippet-18.tex'
2 %% generated by the `filecontentsdef' environment
3 %% from source `etoc' on 2026/05/05.
4 %%
5 % \newtoks\treetok % done in preamble
6 % \newtoks\parttok
7 \newcommand*\partnode {} % check with \newcommand we will not overwrite something
8 \newcommand*\childnode {}
9
10 \newcommand*\tmprotate {} % (idem)
11 \newcommand*\tmpoption {} %
12 \newcommand*\tmpstuff {} %
13
14 \newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
15 #1\expandafter\expandafter\expandafter{\expandafter\the\expandafter #1#2}}
16
17 \newcommand*{\appendchildtree}[3]{%
18 % this is to construct "t1 child [#3]{t2}" from #1=t1 and #2=t2
19 % t1 and t2 are two toks variable (not macros)
20 % #3 = for example teal!60
21 \edef\tmpstuff {\the#1 child [#3]{\the#2}}%
22 #1\expandafter {\tmpstuff }%
23 }
24
25 \newcounter{partco}
26
27 % 1,2,3,4,5,... -> 1,2,3,1,2,3,1,2,3
28 \def\pseudomodthree #1{\numexpr #1 + 3 - 3*((#1+1)/3)\relax}
29
30 \etocsetlinestyle{part}
31 {\etocskipfirstprefix}
32 % This updates the global tree with the data from the previous
33 % part and all its children sections. Moved here because for some parts the
34 % sections are not displayed due to depth tags.
35 {\ifnum\value{partco}=3
36 \appendchildtree\treetok\parttok {branch color= green!50,level distance=10cm}%
37 \else
38 \ifcase\pseudomodthree{\value{partco}}%
39 \or \appendchildtree\treetok\parttok {branch color= teal!30}% first
40 \or \appendchildtree\treetok\parttok {branch color= yellow!80}% second
41 \else\appendchildtree\treetok\parttok {branch color= green!50}% third and next ...
42 \fi\fi
43 }
44 {\stepcounter{partco}%
45 % customize manually some TikZ set-up (should be done inside the TikZ thing I guess)
46 \def\tmpoption {}%
47 \def\tmprotate {}% first
48 %\ifnum\value{partco}=5 \def\tmprotate {[counterclockwise from =-40]}\fi
49 %\ifnum\value{partco}=8 \def\tmprotate {[counterclockwise from =-50]}\fi
50 % define the part node
51 \edef\partnode{node \tmpoption
52 {\unexpanded\expandafter{\etocthelinkednumber}.
53 \unexpanded\expandafter{\etocthelinkedname}}\tmprotate }%
54 % this is a starting point which will be filled it by the section children
55 \parttok\expandafter{\partnode}}
56 {\ifcase\pseudomodthree{\value{partco}}%
57 \or \appendchildtree\treetok\parttok {branch color= teal!60}% first
58 \or \appendchildtree\treetok\parttok {branch color= yellow!80}% second
59 \else\appendchildtree\treetok\parttok {branch color= green!50}% third and next ...
60 \fi
61 }
62
63 \etocsetlinestyle{section}
64 {}
65 {}
66 {% define the section node
67 \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber}
68 \unexpanded\expandafter{\etocthelinkedname}}}}%
69 % append it to the current \parttok
70 \appendtotok\parttok\childnode
71 }
72 {}
73
74 \etocsettocstyle
75 {\setcounter{partco}{0}%
76 \treetok{\node [root concept]{\textbf{The \etoc documentation}}}}
77 {\global\appendtotok\treetok{ ;}}
78 % The \global above is mandatory because etoc always typesets TOC inside a group
79
80 \etocsetnexttocdepth{section}
81 % use of depth tags to cut out sections for most parts, the sections
82 % are too numerous to fit well with the circular growth
83 \etocsettagdepth {preamble} {part}
84 \etocsettagdepth {overview} {part}
85 \etocsettagdepth {styling} {part}
86 \etocsettagdepth {control} {part}
87 \etocsettagdepth {examples} {part}
88 \etocsettagdepth {advanced} {part}
89 \etocsettagdepth {etocandworld}{part}
90 \etocsettagdepth {code} {section}
91
92 \tikzset{
93 branch color/.style={
94 concept color=#1!white,
95 every child/.append style={concept color=#1!white!30!white, font=\normalsize},
96 }
97 }%
98
99 \begin{figure}[htbp!]
100 \etocobeydepthtags % obey the depth tags restrictions (which is default anyhow)
101 \tableofcontents\label{toc:mindmap}%
102 \centeredline{\resizebox{.85\paperwidth}{!}%
103 {\begin{tikzpicture}[mindmap,
104 grow cyclic,
105 text width=2cm,
106 align=flush center,
107 nodes={concept},
108 concept color=orange!60,
109 root concept/.append style={text width=4cm, font=\Large},
110 level 1/.append style={level distance=5cm,sibling angle=45, text width=3cm},
111 level 2/.append style={level distance=7cm,sibling angle=30, text width=3cm},
112 level 1 concept/.append style={font=\normalsize},
113 ]
114 \the\treetok
115 \end{tikzpicture}}}
116 \end{figure}