I would like to use the array package to format a column filled with chemical formula in order to avoid writing \ce{X}
on each line. I don't know if it is even possible. I started from the trick used to hide a column, but didn't get very far.
My code is :
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{array}
\newcolumntype{F}{>{\hbox\bgroup\ce{}}l<{\egroup}@{}}
\newcolumntype{H}{>{\setbox0=\hbox\bgroup}c<{\egroup}@{}}
\newcolumntype{N}{>{\raggedright\arraybackslash}p{3cm}}
\newcolumntype{M}{>{\centering\arraybackslash}p{2cm}}
\usepackage{booktabs}
\usepackage[version=3]{mhchem}
\begin{document}
\begin{array}{N F M}
\toprule
Name & Formula & MW\\
&& (Da) \\
\midrule
glycol & C2H6O2 & 62.07\\
glycerol & C3H8O3 & 92.09\\
& & \\
\bottomrule
\end{array}
\end{document}
What I am looking for, is a command like
\newcolumntype{F}{????}
which can format the content of the column as a chemical formula
collcell
package