I'm trying to optimize the teXForm output of a table because the standard output ist not satisfying:
badLatex = TeXForm[TableForm[{
{"nm", "E1", "E2"},
{500.`, -0.001`, -0.001`},
{499.`, -0.001`, 0.`},
{498.`, 0.`, -0.001`}}]]
I get this output
\begin{array}{ccc}
\text{nm} & \text{E} & \text{E} \\
500. & -0.001 & -0.001 \\
499. & -0.001 & 0. \\
498. & 0. & -0.001 \\
\end{array}
No I want to replace the decimal points with commas, change the environment and eliminate the "\text" command. The last doesn't work for me.
goodLatex = StringReplace[ToString[badLatex],
{"array" -> "tabular","." -> "," , "\text" -> ""}]
I get the following result:
\begin{tabular}{ccc}
\text{nm} & \text{E1} & \text{E2} \\
500, & -0,001 & -0,001 \\
499, & -0,001 & 0, \\
498, & 0, & -0,001 \\
\end{tabular}
As you can see, the expression "\text" is still there. Why is "\" not replaced by StringReplace? Do you have a better idea how to convert tables to proper LaTex code?
Thanks in advance for your help! Michael