我有以下代码。我无法解决此错误:“\XC@definec@lor 的参数有一个额外的 }。”对于示例代码,我没有添加引用。
非常感谢您的帮助。
\documentclass{article}
\usepackage{relsize, pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{figure}[ht]
\begin{tikzpicture}
\begin{axis}[
width=0.33\textwidth,
height=0.33\textwidth,
xbar, xmin=0, xmax=70,
yticklabel style={align=center},
xlabel={stuff2 \%},
xlabel style={font=\smaller},
symbolic y coords={%
{a},
{b\cite{b18}},
{c\cite{b20}},
{d\cite{b19}},
{e\cite{b15}},
{f\cite{b16}},
{g\cite{b13}},
{h\cite{b12}},
{i\cite{b17}},
{j\cite{b1}}},
ytick=data,
nodes near coords={
\pgfmathprintnumber[zerofill, fixed, precision=1]{\pgfplotspointmeta}
},
coordinate style/.condition={x == 16.49}{font=\smaller\boldmath},
coordinate style/.condition={x != 16.49}{font=\smaller},
]
\addplot [fill=gray!90,draw=black!70]
coordinates {%
(16.49,{a})
(17.60,{b\cite{b18}})
(26.37,{c\cite{b20}})
(29.0,{d\cite{b19}})
(29.83,{e\cite{b15}})
(29.99,{f\cite{b16}})
(36.22,{g\cite{b13}})
(43.80,{h\cite{b12}})
(49.55,{i\cite{b17}})
(54.50,{j\cite{b1}})
};
\end{axis}
\end{tikzpicture}
\caption{stuff}
\end{figure}
\end{document}
答案1
您只能使用纯文本作为符号坐标。您不能在那里放置宏。如果您想向是勾选,使用选项yticklabels
:
\documentclass{article}
\usepackage{relsize, pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{figure}[ht]
\begin{tikzpicture}
\begin{axis}[
width=0.5\textwidth,
height=0.5\textwidth,
xbar, xmin=0, xmax=70,
yticklabel style={align=center},
xlabel={stuff2 \%},
xlabel style={font=\smaller},
symbolic y coords={a,b,c,d,e,f,g,h,i,j},
ytick=data,
yticklabels={
{\textbf{a}},
{b\cite{b18}},
{c\cite{b20}},
{d\cite{b19}},
{e\cite{b15}},
{f\cite{b16}},
{g\cite{b13}},
{h\cite{b12}},
{i\cite{b17}},
{j\cite{b1}}},
nodes near coords={
\pgfmathprintnumber[zerofill, fixed, precision=1]{\pgfplotspointmeta}
},
coordinate style/.condition={x == 16.49}{font=\smaller\boldmath},
coordinate style/.condition={x != 16.49}{font=\smaller},
]
\addplot [fill=gray!90,draw=black!70]
coordinates {%
(16.49,a)
(17.60,b)
(26.37,c)
(29.0,d)
(29.83,e)
(29.99,f)
(36.22,g)
(43.80,h)
(49.55,i)
(54.50,j)
};
\end{axis}
\end{tikzpicture}
\caption{stuff}
\end{figure}
\end{document}