我无法让以下 tikz 示例运行(PGF 手册 2.10,第 255 页)。我很可能可以在这里找到一个可以节省我时间的解决方案。
错误:
! Missing \endcsname inserted.
<to be read again>
\pgf@arrows@invertserif cm
l.55 ...ck}{green!25!black}{green}{green!80}{leaf}
顺便说一句:如果手册中能列出必要的库和示例就好了。
示例 1:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\tikzset{
ld/.style={level distance=#1},lw/.style={line width=#1},
level 1/.style={ld=4.5mm, trunk, lw=1ex ,sibling angle=60},
level 2/.style={ld=3.5mm, trunk!80!leaf a,lw=.8ex,sibling angle=56},
level 3/.style={ld=2.75mm,trunk!60!leaf a,lw=.6ex,sibling angle=52},
level 4/.style={ld=2mm, trunk!40!leaf a,lw=.4ex,sibling angle=48},
level 5/.style={ld=1mm, trunk!20!leaf a,lw=.3ex,sibling angle=44},
level 6/.style={ld=1.75mm,leaf a, lw=.2ex,sibling angle=40},
}
\pgfarrowsdeclare{leaf}{leaf}
{\pgfarrowsleftextend{-2pt} \pgfarrowsrightextend{1pt}}
{
\pgfpathmoveto{\pgfpoint{-2pt}{0pt}}
\pgfpatharc{150}{30}{1.8pt}
\pgfpatharc{-30}{-150}{1.8pt}
\pgfusepathqfill
}
\newcommand{\logo}[5]{%
\colorlet{border}{#1}
\colorlet{trunk}{#2}
\colorlet{leaf a}{#3}
\colorlet{leaf b}{#4}
\begin{tikzpicture}
\scriptsize\scshape
\draw[border,line width=1ex,yshift=.3cm,
yscale=1.45,xscale=1.05,looseness=1.42]
(1,0) to [out=90, in=0] (0,1) to [out=180,in=90] (-1,0)
to [out=-90,in=-180] (0,-1) to [out=0, in=-90] (1,0) -- cycle;
\coordinate (root) [grow cyclic,rotate=90]
child {
child [line cap=round] foreach \a in {0,1} {
child foreach \b in {0,1} {
child foreach \c in {0,1} {
child foreach \d in {0,1} {
child foreach \leafcolor in {leaf a,leaf b}
{ edge from parent [color=\leafcolor,-#5] }
}
}
}
} edge from parent [shorten >=-1pt,serif cm-,line cap=butt]
};
\node [align=center,below] at (0pt,-.5ex){
\textcolor{border}{T}heoretical \\ \textcolor{border}{C}omputer \\
\textcolor{border}{S}cience
};
\end{tikzpicture}
}
\begin{document}
\begin{minipage}{3cm}
\logo{green!80!black}{green!25!black}{green}{green!80}{leaf}\\
\logo{green!50!black}{black}{green!80!black}{red!80!green}{leaf}\\
\logo{red!75!black}{red!25!black}{red!75!black}{orange}{leaf}\\
\logo{black!50}{black}{black!50}{black!25}{}
\end{minipage}
\end{document}
示例 2:
\begin{document}
\begin{tikzpicture}[
mindmap,
every node/.style={concept, execute at begin node=\hskip0pt},
root concept/.append style={
concept color=black, fill=white, line width=1ex, text=black
},
text=white, grow cyclic,
level 1/.append style={level distance=4.5cm,sibling angle=90},
level 2/.append style={level distance=3cm,sibling angle=45}
]
\clip (0,-1) rectangle ++(4,5);
\node [root concept] {Computational Complexity}
child [concept color=red] { node {Computational Problems}
child { node {Problem Measures} }
...
}
child [concept color=blue] { node {Computational Models}
child { node {Turing Machines} }
...
}
child [concept color=orange] { node {Measuring Complexity}
child { node {Complexity Measures} }
...
}
child [concept color=green!50!black] { node {Solving Problems}
child { node {Exact Algorithms} }
...
};
\end{tikzpicture}
\end{document}
编辑
感谢 Medina。以下是我想要做的事情:
答案1
1)您需要arrows
库(手册中没有明确提到示例所需的所有库是很常见的):
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap,arrows}
\tikzset{
ld/.style={level distance=#1},lw/.style={line width=#1},
level 1/.style={ld=4.5mm, trunk, lw=1ex ,sibling angle=60},
level 2/.style={ld=3.5mm, trunk!80!leaf a,lw=.8ex,sibling angle=56},
level 3/.style={ld=2.75mm,trunk!60!leaf a,lw=.6ex,sibling angle=52},
level 4/.style={ld=2mm, trunk!40!leaf a,lw=.4ex,sibling angle=48},
level 5/.style={ld=1mm, trunk!20!leaf a,lw=.3ex,sibling angle=44},
level 6/.style={ld=1.75mm,leaf a, lw=.2ex,sibling angle=40},
}
\pgfarrowsdeclare{leaf}{leaf}
{\pgfarrowsleftextend{-2pt} \pgfarrowsrightextend{1pt}}
{
\pgfpathmoveto{\pgfpoint{-2pt}{0pt}}
\pgfpatharc{150}{30}{1.8pt}
\pgfpatharc{-30}{-150}{1.8pt}
\pgfusepathqfill
}
\newcommand{\logo}[5]{%
\colorlet{border}{#1}
\colorlet{trunk}{#2}
\colorlet{leaf a}{#3}
\colorlet{leaf b}{#4}
\begin{tikzpicture}
\scriptsize\scshape
\draw[border,line width=1ex,yshift=.3cm,
yscale=1.45,xscale=1.05,looseness=1.42]
(1,0) to [out=90, in=0] (0,1) to [out=180,in=90] (-1,0)
to [out=-90,in=-180] (0,-1) to [out=0, in=-90] (1,0) -- cycle;
\coordinate (root) [grow cyclic,rotate=90]
child {
child [line cap=round] foreach \a in {0,1} {
child foreach \b in {0,1} {
child foreach \c in {0,1} {
child foreach \d in {0,1} {
child foreach \leafcolor in {leaf a,leaf b}
{ edge from parent [color=\leafcolor,-#5] }
}
}
}
} edge from parent [shorten >=-1pt,serif cm-,line cap=butt]
};
\node [align=center,below] at (0pt,-.5ex){
\textcolor{border}{T}heoretical \\ \textcolor{border}{C}omputer \\
\textcolor{border}{S}cience
};
\end{tikzpicture}
}
\begin{document}
\begin{minipage}{3cm}
\logo{green!80!black}{green!25!black}{green}{green!80}{leaf}\\
\logo{green!50!black}{black}{green!80!black}{red!80!green}{leaf}\\
\logo{red!75!black}{red!25!black}{red!75!black}{orange}{leaf}\\
\logo{black!50}{black}{black!50}{black!25}{}
\end{minipage}
\end{document}
快速猜测问题出在哪里的关键是错误消息中的这一行:
\pgf@arrows@invertserif
表示与箭头相关的一些问题。
2)删除占位符...
:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\begin{document}
\begin{tikzpicture}[
mindmap,
every node/.style={concept, execute at begin node=\hskip0pt},
root concept/.append style={
concept color=black, fill=white, line width=1ex, text=black
},
text=white, grow cyclic,
level 1/.append style={level distance=4.5cm,sibling angle=90},
level 2/.append style={level distance=3cm,sibling angle=45}
]
\clip (0,-1) rectangle ++(4,5);
\node [root concept] {Computational Complexity}
child [concept color=red] { node {Computational Problems}
child { node {Problem Measures} }
}
child [concept color=blue] { node {Computational Models}
child { node {Turing Machines} }
}
child [concept color=orange] { node {Measuring Complexity}
child { node {Complexity Measures} }
}
child [concept color=green!50!black] { node {Solving Problems}
child { node {Exact Algorithms} }
};
\end{tikzpicture}
\end{document}
或者用实际有效的内容替换它们,例如:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}
\begin{document}
\begin{tikzpicture}[
mindmap,
every node/.style={concept, execute at begin node=\hskip0pt},
root concept/.append style={
concept color=black, fill=white, line width=1ex, text=black
},
text=white, grow cyclic,
level 1/.append style={level distance=4.5cm,sibling angle=90},
level 2/.append style={level distance=3cm,sibling angle=45}
]
\node[root concept] {Computational Complexity} % root
child[concept color=red] { node {Computational Problems}
child { node {Problem Measures} }
child { node {Problem Aspects} }
child { node {Problem Domains} }
child { node {Key Problems} }
}
child[concept color=blue] { node {Computational Models}
child { node {Turing Machines} }
child { node {Random-Access Machines} }
child { node {Circuits} }
child { node {Binary Decision Diagrams} }
child { node {Oracle Machines} }
child { node {Programming in Logic} }
}
child[concept color=orange] { node {Measuring Complexity}
child { node {Complexity Measures} }
child { node {Classifying Complexity} }
child { node {Comparing Complexity} }
child { node {Describing Complexity} }
}
child[concept color=green!50!black] { node {Solving Problems}
child { node {Exact Algorithms} }
child { node {Randomization} }
child { node {Fixed-Parameter Algorithms} }
child { node {Parallel Computation} }
child { node {Partial Solutions} }
child { node {Approximation} }
};
\end{tikzpicture}
\end{document}
在这种情况下,使用原始占位符,...
您会收到一条包含以下内容的错误消息:
! Undefined control sequence.
\pgfutil@reserved@c ->\tikz@curveto@auto
最后一部分表明TikZ
正在尝试应用一项curveto
操作:解析器将其..
作为以曲线方式扩展路径的语法的一部分.. controls <point> ..
,但显然剩余的代码不是解析器所期望的。