1

I have the following code. I am unable to resolve this error: 'Argument of \XC@definec@lor has an extra }.' for the sample code I have not added cites.

Any help is highly appreciated.

\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
  • While it is fine to place \cite macros inside symbolic y coords you cannot place these inside a coordinate list. This just doesn't work. Feb 26, 2023 at 18:08

1 Answer 1

1

You may only use plain text as symbolic coordinate. You cannot place macros there. If you want to add stuff to the y ticks, use the option 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}

enter image description here

2
  • I already used yticklabels in my other answer, but maybe I was not clear enough about why it is necessary to use it in such situations. Feb 26, 2023 at 18:14
  • You're a life saver, internet friend! Thank you so much!! Upvoted the sol'n. Feb 26, 2023 at 20:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .