![我该如何调试错误“\XC@definec@lor 的参数有一个多余的}”?](https://linux22.com/image/394167/%E6%88%91%E8%AF%A5%E5%A6%82%E4%BD%95%E8%B0%83%E8%AF%95%E9%94%99%E8%AF%AF%E2%80%9C%5CXC%40definec%40lor%20%E7%9A%84%E5%8F%82%E6%95%B0%E6%9C%89%E4%B8%80%E4%B8%AA%E5%A4%9A%E4%BD%99%E7%9A%84%7D%E2%80%9D%EF%BC%9F.png)
以下代码输出错误:
Argument of \XC@definec@lor has an extra }.
<inserted text>
\par
l.26 \end{axis}
但是,我无法调试并找到导致错误的代码。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
% \usepgfplotslibrary{statistics}
\pgfplotsset{compat=1.14}
% \usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{figure}[tb]
\centering
\hspace*{-0.32cm}
\begin{tikzpicture}[font=\scriptsize]
\begin{axis}[ybar stacked,
height=4.5cm,width=9cm,
ymin=0,ymax=5,
ylabel style = {align=center},
ylabel={\# relevant score},
symbolic x coords={Launch,Options,Text Input,Text\\Display,Fixed-item\\List,Dynamic-\\item List},
xticklabel style={align=center},
nodes near coords,
% nodes near coords align={vertical},
% nodes near coords style={/pgf/number format/fixed,
% /pgf/number format/fixed zerofill,
% /pgf/number format/precision=2},
% every node near coord/.append style={font=\scriptsize},
]
\addplot coordinates
{(Launch,3.93) (Options,4) (Text Input,4.38) (Text\\Display,3.35) (Fixed-item\\List,3.44) (Dynamic-\\item List,4.32)};
\end{axis}
\end{tikzpicture}
% \vspace*{-0.5cm}
\caption{Relevance evaluation result from experiment participants}
\label{fig:user_scores}
\end{figure}
\end{document}
答案1
问题在于换行符。类似地这个很好的答案,您可以定义没有它们的符号坐标,但将它们放在标签中。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
% \usepgfplotslibrary{statistics}
\pgfplotsset{compat=1.14}
% \usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{figure}[tb]
\centering
\hspace*{-0.32cm}
\begin{tikzpicture}[font=\scriptsize]
\begin{axis}[ybar stacked,
height=4.5cm,width=9cm,
ymin=0,ymax=5,
ylabel style = {align=center},
ylabel={\# relevant score},
symbolic x coords={Launch,Options,Text Input,
Text Display,Fixed-item List,Dynamic-item List},
xticklabels={,Launch,Options,Text Input,
Text\\ Display,Fixed-\\item List,Dynamic-\\item List},
xticklabel style={align=center},
nodes near coords,
% nodes near coords align={vertical},
% nodes near coords style={/pgf/number format/fixed,
% /pgf/number format/fixed zerofill,
% /pgf/number format/precision=2},
% every node near coord/.append style={font=\scriptsize},
]
\addplot coordinates
{(Launch,3.93) (Options,4) (Text Input,4.38)
(Text Display,3.35)
(Fixed-item List,3.44) (Dynamic-item List,4.32)
};
\end{axis}
\end{tikzpicture}
% \vspace*{-0.5cm}
\caption{Relevance evaluation result from experiment participants}
\label{fig:user_scores}
\end{figure}
\end{document}