I would like to place some LaTeX math code in the columns of a file to be read by pgfplotstable
. Unlike How to use underscores with pgfplotstable?, I would like the columns to be formatted so LaTeX will interpret the subscripts and symbols that it contains. For example, I have a data file that looks like:
{Time} {$\theta$} {Fit to $C_a \tan 3\theta$}
0 0.2 0.195
...
Every time I try to read a file like this with pgfplotstable
, I get an error:
! Missing \endcsname inserted. <to be read again> \mathop l.101 } ^^M
Is it possible to have the formatting embedded in the column headings of a data file? If so, how?
Best Answer
pgfplotstable
assumes that column names do not contain expandable material.Its way of dealing with "display names" is to provide the display names explicitly using the
column name
key which is used during\pgfplotstabletypeset
.Protecting expandable material in column names is unsupported. It is unlikely that
pgfplotstable
will support such protection automatically in the future (because protection cannot be done during\edef
which is a common use case of access to columns).So, the answer is: no, this is generally unsupported. Period.
You can hack the processing such that it does basic escaping - on your own risk. You should skip this section unless you know what you are doing and you know why you are doing it. Do not blame me. This here would work if you wanted to typeset the table:
It is based on the fact that
\string\macro
yields the string sequence "\ m a c r o" . Clearly, you would need to change the header of your input table for such an approach.