# Math mode for csvsimple Import

I am currently struggling when I try to import a CSV file which contains math code using the following code:

\documentclass{article}
\usepackage{csvsimple}
\usepackage{amssymb}  % Math symbols
\usepackage{amsmath}  % Math formulas

% Make csv in question
\begin{filecontents*}{example.csv}
ex1,\rho = 4e9
0,19.85
\end{filecontents*}

\begin{document}
\csvautotabular{example.csv}
\end{document}


The problem is that \rho is not interpreted. Moreover, it does not even compile. I also tried $\rho$ or within quotes. Unfortunately, csvsimple does not seem to work along with math mode contents of the CSV. Does anybody has a solution for this?

• This seems to be caused by the presence of macros in the first line of the file, which, according to the package documentation, is usually used to indicate the column identifiers. If you swap the lines (and insert $ around \rho) the problem goes away. – Ian Thompson Dec 13 '13 at 12:38 • Thank you for the fast anwer. You're right. Unfortunately, this is not what i want. I'd like to have $\rho$ in the identifier line, as this is the parameter I am varying. Is there any solution? – RMK Dec 13 '13 at 12:58 ## 1 Answer The \csvautotabular macro is just intended for raw viewing of text CSV files. For everything else, you should use \csvreader which allows full control of the content. If your file has no header, the assignment to the columns is simpy achieved by arabic numbers. For following example sets the two columns in math mode and adds a line numbering for fun. \documentclass{article} \usepackage{csvsimple} \usepackage{amssymb} % Math symbols \usepackage{amsmath} % Math formulas % Make csv in question \begin{filecontents*}{example.csv} ex1,\rho = 4e9 0,19.85 \end{filecontents*} \begin{document} \csvreader[no head,tabular=|l|c|c|, table head=\hline,late after line=\\\hline]{example.csv} {1=\one,2=\two} {\thecsvrow &$\one$&$\two\$}%

• You are welcome. Please, don't forget to press the accept button :-) – Thomas F. Sturm Dec 18 '13 at 8:05