summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/etoc/etocsnippet-29.tex
blob: 8116d97e27b4e34768e4e7d826504eacecce9b42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
%% LaTeX2e file `etocsnippet-29.tex'
%% generated by the `filecontentsdef' environment
%% from source `etoc' on 2019/11/17.
%%
\begingroup
% \newtoks\treetok % done in preamble
% \newtoks\parttok

\newcommand*\partnode {}  % just to check we don't overwrite something
\newcommand*\childnode {}

\newcommand*\tmprotate {} % just to check we don't overwrite something
\newcommand*\tmpoption {} % just to check we don't overwrite something
\newcommand*\tmpstuff  {} % just to check we don't overwrite something

\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
   #1\expandafter\expandafter\expandafter{\expandafter\the\expandafter #1#2}}

\newcommand*{\appendchildtree}[3]{%
% this is to construct "t1 child [#3]{t2}" from #1=t1 and #2=t2
% t1 and t2 are two toks variable (not macros)
% #3 = for example teal!60
   \edef\tmpstuff {\the#1 child [#3]{\the#2}}%
   #1\expandafter {\tmpstuff }%
}

\newcounter{partco}

% 1,2,3,4,5,... -> 1,2,3,1,2,3,1,2,3
\def\pseudomodthree #1{\numexpr #1 + 3 - 3*((#1+1)/3)\relax}

\etocsetstyle{part}
  {\etocskipfirstprefix}
% This updates the global tree with the data  from the previous
% part and all its children sections. Moved here because for some parts the
% sections are not displayed due to depth tags.
  {\ifnum\value{partco}=3
     \appendchildtree\treetok\parttok {branch color= green!50,level distance=10cm}%
   \else
\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {branch color= teal!60}%   first
   \or \appendchildtree\treetok\parttok {branch color= yellow!80}% second
   \else\appendchildtree\treetok\parttok {branch color= green!50}% third and next ...
   \fi\fi
   }
  {\stepcounter{partco}%
% customize manually  some TikZ set-up (should be done inside the TikZ thing I guess)
   \def\tmpoption {}%
   \def\tmprotate {}% first
   %\ifnum\value{partco}=5 \def\tmprotate {[counterclockwise from =-40]}\fi
   %\ifnum\value{partco}=8 \def\tmprotate {[counterclockwise from =-50]}\fi
% define the part node
   \edef\partnode{node \tmpoption
                  {\unexpanded\expandafter{\etocthelinkednumber}.
                   \unexpanded\expandafter{\etocthelinkedname}}\tmprotate }%
% this is a starting point which will be filled it by the section children
   \parttok\expandafter{\partnode}}
  {\ifcase\pseudomodthree{\value{partco}}%
   \or \appendchildtree\treetok\parttok {branch color= teal!60}%   first
   \or \appendchildtree\treetok\parttok {branch color= yellow!80}% second
   \else\appendchildtree\treetok\parttok {branch color= green!50}% third and next ...
   \fi
   }

\etocsetstyle{section}
  {}
  {}
  {% define the section node
   \edef\childnode{child {node {\unexpanded\expandafter{\etocthelinkednumber}
                        \unexpanded\expandafter{\etocthelinkedname}}}}%
   % append it to the current \parttok
   \appendtotok\parttok\childnode
    }
  {}

\etocsettocstyle
  {\setcounter{partco}{0}%
   \treetok{\node [root concept]{\textbf{The \etoc documentation}}}}
  {\global\appendtotok\treetok{ ;}}
% The \global above is mandatory because etoc always typesets TOC inside a group

\etocsetnexttocdepth{section}
% use of depth tags to cut out some sections.
\etocsettagdepth {preamble}   {none}
\etocsettagdepth {overview}   {part}
\etocsettagdepth {arbitrarily}{part}
\etocsettagdepth {examples}   {section}
\etocsettagdepth {surprising} {part}
\etocsettagdepth {linestyles} {part}
\etocsettagdepth {globalcmds} {part}
\etocsettagdepth {custom}     {section}
\etocsettagdepth {tips}       {part}
\etocsettagdepth {etocandworld}{part}
\etocsettagdepth {code}       {section}

\tikzset{
    branch color/.style={
        concept color=#1!white,
        every child/.append style={concept color=#1!white!30!white, font=\normalsize},
    }
}%

\begin{figure}[thp!]
\tableofcontents\label{toc:mindmap}%
\centeredline{\resizebox{.85\paperwidth}{!}%
{\begin{tikzpicture}[mindmap,
                    grow cyclic,
                    text width=2cm,
                    align=flush center,
                    nodes={concept},
                    concept color=orange!60,
                    root concept/.append style={text width=4cm, font=\Large},
   level 1/.append style={level distance=5cm,sibling angle=40, text width=3cm},
   level 2/.append style={level distance=7cm,sibling angle=30, text width=3cm},
   level 1 concept/.append style={font=\normalsize},
                    ]
\the\treetok
\end{tikzpicture}}}
\end{figure}
\endgroup