I've been working with pgfplotstable
for some time now and initially I was reading in data from .csv
files. I'm writing a couple of packages that print tables and so I've written various \def
s to encapsulate some table printing routines. So far so good. Now I want to produce tables from scratch and all of a sudden I'm getting errors. If you run the MWE it prints a table. If you uncomment the last call the following error text is produced
./Repeated Plots.tex:23: Package pgfplots Error: \pgfplotslistfront\ from
\pgfplotstable@colnames\ although list is EMPTY.
I can do tables with the same definition over and over again when I'm reading them from file, but when creating them from scratch I get conflicts.
MWE
\documentclass[border=6mm]{standalone}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\pgfplotsset{compat=1.9}
%: table printing routine
\def\printtable#1{%
\pgfplotstableset{%
create on use/set/.style={create col/expr={1+\pgfplotstablerow}},
every head row/.style={before row=\toprule, after row=\midrule},
every last row/.style={after row=\bottomrule}
}
\pgfplotstablenew[columns={set}]{#1}\testtable
\pgfplotstablecreatecol[create col/assign/.code={%
\getthisrow{set}\tval\pgfmathtruncatemacro\entry{2*\tval-1}%
\pgfkeyslet{/pgfplots/table/create col/next content}\entry
}]{test}\testtable
\pgfplotstabletypeset[columns={test}]\testtable
}
\begin{document}
\printtable{10}\par
%\printtable{5}
\end{document}