我正在尝试重新创建 Jean-Francois Burnol 的“etoc 包“但我无法解决第 115 行发生的错误:
(\centeredline{\resizebox{.85\paperwidth}{!}%)
以下 MWE:
\documentclass[12pt,oneside, tikz, ignorerest=false]{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\pagestyle{empty}
\usepackage{etoc}
\def\input@path{{/usr/local/texlive/2022/texmf-dist/tex/latex/centeredline/}}
\usepackage{centeredline}
\newcounter{visibletoc}
\renewcommand{\etocaftertitlehook}
{\stepcounter{visibletoc}\etoctoccontentsline{visibletoc}{\thevisibletoc}}
\etocsetlevel{visibletoc}{6}
\begin{document}
\subsection{Surprising uses of etoc}
\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
MWE 是取自第 46-49 页的代码的组合“etoc 包“,以及序言的设置代码用户46862015 年对 SE 帖子中问题的回答可视化目录(tikz 思维导图) - 输出问题。
我还添加了以下代码,试图解决加载“中心编辑line' 包,例如 '\usepackage{center编辑线}':
\def\input@path{{/usr/local/texlive/2022/texmf-dist/tex/latex/centeredline/}}
消除编译时出现的警告。
如果您对我所遗漏的内容有任何想法,我将不胜感激。
答案1
如果您想要内容等,请不要使用该类standalone
。您不需要定义\input@path
,而且我不确定这样做的目的是什么。
您使用的代码假定使用\part
,因此您需要使用部件来显示部分等。也就是说,部分代码附加到树的部分代码中。如果没有部件节点,则永远不会使用部分节点。我还添加了一些子部分,只是为了表明它们按照指定的方式被忽略,并删除了一些您的示例不需要的行。
\documentclass[12pt,oneside, tikz, ignorerest=false]{article}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\pagestyle{empty}
\usepackage{etoc}
\usepackage{centeredline}
\begin{document}
\part{Part Level}
If we're appending to \verb|\parttok| we need a part to avoid losing it.
\section{Section level}
\subsection{Surprising uses of etoc}
\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}
\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
\subsubsection{Lower by Two}
\subsubsection{Another Lower by Two}
\subsection{A Lower Level}
\section{Another Top Level}
\end{document}