I have a CSV file with a list of chemical compounds I would like to have parsed through the \ce{}
from the mhchem
which converts them to nice chemical notation. While using the raw string as an argument for \ce{}
works, when the same string is given as a command, the macro does nothing.
\documentclass{scrartcl}
\begin{filecontents*}{foo.csv}
Molecule
CH4
\end{filecontents*}
\usepackage{datatool}
\usepackage{mhchem}
\DTLloaddb{foo}{foo.csv}
\DTLgetvalue{\methane}{foo}{1}{1}
\begin{document}
CH4
\methane
\ce{CH4}
\ce{\methane}
\end{document}
Yields
So \ce{\methane}
is not doing anything (it should be putting 4
as a subscript).
\expandafter\ce\expandafter{\methane}