I am using the excellent answer from @percusse to the question How to rotate head row cell entries of pgfplotstable which works great if you always want rotated headers.
I am calling \pgfplotstabletypset from within a \newcommand with some optional arguments and as such I cannot move the lines:
typeset cell/.code={
\ifnum\pgfplotstablecol=\pgfplotstablecols
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\rotatebox{90}{##1}\\}%
\else
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\rotatebox{90}{##1}&}%
\fi
},
out into the \pgfplotstypeset[ <options here> ]{} bit as the ##1 is not interpreted. No problem if the \pgfplotstypeset[typeset cell/.code={...]{} is not encapsulated in a macro with paramteres.
So, how do I get around this. Ultimately I would like the part that rotates headers to be within a style as:
\pgfplotstableset{
rotated header/.style={
col sep=comma,
row sep=newline,
every head row/.style={
typeset cell/.code={
\ifnum\pgfplotstablecol=\pgfplotstablecols
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\rotatebox{90}{##1}\\}%
\else
\pgfkeyssetvalue{/pgfplots/table/@cell content}{\rotatebox{90}{##1}&}%
\fi
},
after row=\midrule,
},
% string type,
font=\footnotesize,
set thousands separator={},
fixed,
precision=2,
every last row/.style={
after row=\bottomrule
},
}
}
Placing the rotation in a style does not work either. Xparse didn't save me either... How can it be made to do so please?
#tokens? – Joseph Wright Mar 05 '15 at 07:07\ifnum...stuff tests for whether we are in the last column or not. So I don't know if you really need it. Also @JosephWright's remark hold that inside the definitions you will need to double##1->####1. Also please note that I had to insert double backslash and&just because the OP was usingcol sep=&,row sep=\\,otherwise we don't need any of those stuff. So you havecol sep=commahence don't need the extra&. – percusse Mar 05 '15 at 09:28