2

I am trying to draw a bar chart using pgfplots in which I want to add references to x coordinates. I am getting the following errors with the output.

Paragraph ended before \XC@definec@lor was complete and Argument of \XC@definec@lor has an extra }. \end{axis}

However, when I remove the citation, everything seems to work fine. Here is the MWE.

\begin{tikzpicture}
            \begin{axis}[
                ybar,
                enlargelimits=0.15,
                legend style={at={(0.5,-0.2)},
                    anchor=north,legend columns=-1},
                ylabel={Normalized Cost},
                symbolic x coords={A,\cite{somework},\cite{otherwork}},
                width={\textwidth}, 
                xtick=data,
                nodes near coords, 
                nodes near coords align={vertical},
                ]
                \addplot coordinates {(A,1) (\cite{somework},2) (\cite{otherwork},3)};
            \end{axis}
\end{tikzpicture}

I have used \usepackage{tikz,pgfplots} in the preamble.

1 Answer 1

1

Instead of using symbolic x coords, use xtick and xticklabels.

(You don't need to load tikz explicitly by the way, pgfplots does that for you.)

% arara: pdflatex
% arara: biber
% arara: pdflatex
\documentclass{article}
\usepackage{pgfplots}
\usepackage{biblatex}
\addbibresource{xampl.bib}
\begin{document}
\begin{tikzpicture}
            \begin{axis}[
                ybar,
                enlargelimits=0.15,
                legend style={at={(0.5,-0.2)},
                    anchor=north,legend columns=-1},
                ylabel={Normalized Cost},
                xtick={1,2,3},
                xticklabels={A,\cite{article-full},\cite{book-full}},
                width={\textwidth}, 
                nodes near coords, 
                nodes near coords align={vertical},
                ]
                \addplot coordinates {(1,1) (2,2) (3,3)};
            \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

1
  • 1
    If whoever downvoted this sees this comment, I'd appreciate a reason for the downvote. Oct 10, 2020 at 17:52

You must log in to answer this question.

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