I cannot use my new defined command \ces inside \ce{} I get an error. However i can use my defined command outside the array environment but not inside it. What am I doing wrong with this new command? If it can work outside the array environment why isn't it working inside a math environment like array ? I have my command definition enclosed in $ $.
MWE:
Code: Select all
\documentclass[fleqn]{article}
\usepackage[version=3]{mhchem}
\usepackage{cancel}
\newcommand{\ces}[2]{$\cancel{\ce{#1}}\ce{_{(#2)}}$}
\begin{document}
$\begin{array}[t]{l}
\ce{H2O + \ces{O2}{g} -> H2O + Cl2}
\end{array}$ \\ \\
\ces{O2}{g}
\end{document}