2

So I'm calling data in to a pgfplotstable with

\pgfplotstabletypeset[col sep=comma]{example.txt}

which has been working fine, until I tried to include a citation in my example.txt file with \cite{somebozo}. The error message from the compiler is that there is an extra } Somewhere just after the pgfplotstabletypeset command.

Does anyone have any suggestions?

3

By default pgfplotstable assumes numbers, and will try to parse the content of the cells as numbers. If you set string type for the column containing the citation it seems to work fine:

\documentclass{article} 
\usepackage{pgfplotstable,filecontents} 
\begin{filecontents*}{example.txt}
x,y,meta
1,2,\cite{aksin}
2,3,\cite{angenendt}
3,7,\cite{doody}
\end{filecontents*}

\usepackage[backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document} 
\pgfplotstabletypeset[
   col sep=comma,
   display columns/2/.style={string type} % column count starts at 0, col 2 is third column
]{example.txt}

\printbibliography
\end{document}

enter image description here

Citation in header

I don't have a good solution for this case at the moment, though I do have a workaround. Remove the citation from the .csv file, and replace the column name for the column in question with something containing a citation.

Alternatively, if you don't need any parsing of the values in the columns, you can use the method described in https://tex.stackexchange.com/a/236364/586

There may well be better ways of doing this, but I'm not that well versed in pgfplotstable trickery.

\documentclass{article} 
\usepackage{pgfplotstable,filecontents} 
\begin{filecontents*}{example.txt}
x,y,whatever % note no citation here
1,2,\cite{aksin}
2,3,\cite{angenendt}
3,7,\cite{doody}
\end{filecontents*}
\begin{filecontents*}{example2.txt}
x,y,meta\cite{glashow}
1,2,\cite{aksin}
2,3,\cite{angenendt}
3,7,\cite{doody}
\end{filecontents*}    
\usepackage[backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document} 
\pgfplotstabletypeset[
   col sep=comma,
   display columns/2/.style={string type},
   every col no 2/.style={column name={meta\cite{glashow}}} % redefine column name
]{example.txt}


\pgfplotstabletypeset[
   col sep=comma,
   header=false,
   every head row/.style={output empty row},
   string type
]{example2.txt}

\printbibliography
\end{document}

enter image description here

  • I tried your Method, it seems to work well, except that in my case the citations are in the header row, and this seems to not work on the header row. Do you know how I can put the citation in the header row and have it read correctly? – sean read May 15 '16 at 10:22
  • @seanread Will have a look. (This highlights the value of a good minimal working example (MWE) by the way, with one of those I wouldn't have made any wrong assumptions.) – Torbjørn T. May 15 '16 at 10:33
  • sorry about that, will remember for next time – sean read May 15 '16 at 10:51
  • @seanread I don't know of any brilliant solutions, but I added a workaround. – Torbjørn T. May 15 '16 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.