2

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?

Stefan Pinnow
  • 29,535
SpmP
  • 1,201
  • Please make your code compilable, if possible, or as close to compilable as you can. If you can't make it compile, at least make it so we can reproduce the error message you get when you try. – cfr Mar 05 '15 at 03:54
  • As you put your code inside another definition, did you remember to double all of the # tokens? – Joseph Wright Mar 05 '15 at 07:07
  • 1
    Hmm, I think there is a mismatch here. The conditional \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 using col sep=&,row sep=\\, otherwise we don't need any of those stuff. So you have col sep=comma hence don't need the extra &. – percusse Mar 05 '15 at 09:28
  • Did the tricks of Joseph and/or percusse help you to solve the problem or do you need further assistance? – Stefan Pinnow Feb 14 '17 at 09:22

0 Answers0