我一直试图包含来自这里芬兰语 TeX 文档。但是,我得到了错误
! Argument of \language@active@arg" has an extra }.<inserted text>\par }
。
经过一番谷歌搜索后,我发现这可能与 TikZ 和 babel 有关,但通常建议用于其他语言的解决方案(例如这里)不起作用。
下面的 TeX 代码将重现这个错误
\documentclass[tikz,border=10pt]{standalone}
% Removing these two \usepackage statements will eliminate the error
\usepackage[finnish]{babel}
\usepackage[utf8]{inputenc}
\begin{document}
\def\angle{0}
\def\radius{3}
\def\cyclelist{{"orange","blue","red","green"}}
\newcount\cyclecount \cyclecount=-1
\newcount\ind \ind=-1
\begin{tikzpicture}[nodes = {font=\sffamily}]
\foreach \percent/\name in {
46.6/Chrome,
24.6/Internet Explorer,
20.4/Firefox,
5.1/Safari,
1.3/Opera,
2.0/Other
} {
\ifx\percent\empty\else % If \percent is empty, donothing
\global\advance\cyclecount by 1 % Advance cyclecount
\global\advance\ind by 1 % Advance list index
\ifnum3<\cyclecount % If cyclecount is larger than list
\global\cyclecount=0 % reset cyclecount and
\global\ind=0 % reset list index
\fi
\pgfmathparse{\cyclelist[\the\ind]} % Get color from cycle list
\edef\color{\pgfmathresult} % and store as \color
% Draw angle and set labels
\draw[fill={\color!50},draw={\color}] (0,0) -- (\angle:\radius)
arc (\angle:\angle+\percent*3.6:\radius) -- cycle;
\node at (\angle+0.5*\percent*3.6:0.7*\radius) {\percent\,\%};
\node[pin=\angle+0.5*\percent*3.6:\name]
at (\angle+0.5*\percent*3.6:\radius) {};
\pgfmathparse{\angle+\percent*3.6} % Advance angle
\xdef\angle{\pgfmathresult} % and store in \angle
\fi
};
\end{tikzpicture}
\end{document}
答案1
正确答案由 Ulrike Fischer 在原帖评论中发布:
您应该在定义自行车清单之前停用“:
\shorthandoff{"} \def\cyclelist{{"orange","blue","red","green"}} \shorthandon{"}