I have the following csv file (myCSVfile.csv) which contains header with LaTeX code:
| $T_{1,2}$, | $T_{3}$ |
|---|---|
| 100, | 300 |
| 200, | 500 |
In my LaTeX document, I import this table with \pgfplotstabletypeset[col sep=comma,row sep=newline]{myCSVfile.csv}.
It works well but my csv file is not satisfying for me because some comma are note column separators but just characters in a math expression in header titles, as in: $T_{1,2}$
I there a native command that just print a comma in math mode, e.g.: $T_{1\comma{}2}$ instead of $T_{1,2}$ which output nearly the same in the pdf ?. In text mode it would also be OK for me even if it's not the best solution: $T_{1\text{\comma{}}2}$.
I found the \mathpunct command here but there is still a comma when I use it in the csv file : $T_{1\mathpunct{,}2}$ instead of $T_{1,2}$ and I get an error when importing with \pgfplotstabletypeset...
I know that I can just put my header title between double quotes "$T_{1,2}$" to be sure that the comma in header title will not be interpreted as column separator, but I wonder if there is a way to obtain a comma with a native command in math mode or even in text mode.
MWE:
\documentclass{article}
\usepackage{pgfplotstable,filecontents}
\begin{filecontents}{myCSVfile.csv}
$T_{1,2}$, $T_{3}$
100, 300
200, 500
\end{filecontents}
\begin{document}
\pgfplotstabletypeset[col sep = comma,row sep=newline]{myCSVfile.csv}
\end{document}
\newcommand{\comma}{,}– egreg Sep 14 '22 at 09:19\commais ? I would prefer more "portable" solution... – zetyty Sep 14 '22 at 09:27