我尝试制作饼图,但无法获得正确的标签:这是 MWE:
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{tikz}
\definecolorseries{colorser}{rgb}{last}{blue}{green}
\def\piechart#1#2#3#4#5{%1:data,2:numberOfElements,3:colors,4:outerRadius,5:labels
\resetcolorseries[#2]{#3}
\edef\startangle{90}
\foreach [
remember=\endangle as \startangle,
evaluate=\i as \endangle using {\startangle-(\csname#1\endcsname[\i-1]/100*360)},
evaluate=\halfangle using {(\endangle-\startangle)/2+\startangle},
] \i in {1,...,#2} {%
\fill[{#3!![\i]}] (0,0) --++(\startangle:#4) arc (\startangle:\endangle:#4);
\draw[white, line width=0.75mm](0,0)--++(\startangle:#4+0.1pt);
\node at (\halfangle:#4) {\pgfmathparse{\csname#5\endcsname[\i-1]}\pgfmathresult};% With this line commented out there is no error...
}
\draw[white,line width=0.75mm](0,0)--++(\startangle:#4);
\fill[white](0,0)circle [radius=#4*0.4];%
}
\begin{document}
\begin{tikzpicture}
\newcommand\shares{{50,30,15,5}}
\newcommand\labels{{"a","b","c","d"}}
\piechart{shares}{4}{colorser}{2cm}{labels}
\end{tikzpicture}
\end{document}
这会带来错误
Argument of \language@active@arg" has an extra }. \par ...piechart{shares}{4}{colorser}{2cm}{labels}
我希望的输出如下所示:
没有标签,一切正常......
答案1
active"
是一种babel
简写,TikZ 库babel
有助于:
\usepackage[ngerman]{babel}
\usepackage{tikz}
\usetikzlibrary{babel}