summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/etoc/etocsnippet-17.tex
blob: 744737a72f6a0d0b1c8f569fca7f33ed8d7affc5 (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
%% LaTeX2e file `etocsnippet-17.tex'
%% generated by the `filecontentshere' environment
%% from source `etoc' on 2023/07/05.
%%
% \newtoks\treetok % put this (uncommented) preferably in the preamble
% \newtoks\subsectiontok
% \newtoks\subsubsectiontok
% Attention: this code has been prepared only for subsections
% and subsubsections.

\newcommand*{\treenode}{}% only to make sure our \edef's do not overwrite
                         % an existing command

% expands 2nd argument (macro) and appends it to 1st argument (toks)
\newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2
  #1\expandafter\expandafter\expandafter
    {\expandafter\the\expandafter #1#2}}

% appends 2nd argument contents (toks) as child of first argument (toks)
\newcommand*{\appendchildtree}[2]{% token list t1 becomes: t1 child {t2}
   \edef\tmp{\the#1 child {\the#2}}%
   #1\expandafter{\tmp}%
}
% prepare the (hyperlinked) number in the "node (number)" shape
\newcommand*{\preparetreenode}{%
  \tmptok\expandafter{\etocthelinkednumber}% expanded once (needed)
  \edef\treenode{node {\the\tmptok}}%
}

\etocsetstyle{subsection}
  {\etocskipfirstprefix}
  {\appendchildtree\treetok\subsectiontok}
  {\preparetreenode
   \subsectiontok\expandafter{\treenode}}
  {\appendchildtree\treetok\subsectiontok}

\etocsetstyle{subsubsection}
  {\etocskipfirstprefix}
  {\appendchildtree\subsectiontok\subsubsectiontok}
  {\preparetreenode
   \subsubsectiontok\expandafter{\treenode}}
  {\appendchildtree\subsectiontok\subsubsectiontok}

\etocsettocstyle
  {\treetok{\node {\hyperref[sec:linestyles]{Line styles}}}}
  {\global\appendtotok\treetok{ ;}}

\centeredline{% from package centeredline (limits scope of \hypersetup)
   \etocsetnexttocdepth{subsubsection}
   \etocinline\tableofcontents \label{toc:molecule} \ref{toc:tocstyle}
   \hypersetup{hidelinks}%
   \begin{tikzpicture}
              [grow cyclic,
               level 1/.style={level distance=4cm,sibling angle=72},
               level 2/.style={level distance=2cm,sibling angle=60},
               every node/.style={ball color=red,circle,text=SkyBlue},
               edge from parent path={[dashed,very thick,color=cyan]
                           (\tikzparentnode) --(\tikzchildnode)}]
   \the\treetok
   \end{tikzpicture}%
}