To load these into LaTeX so they are available in hardcopy, you would need to edit /opt/webwork2/config/snippets/hardcopyPreamble.tex
to load the required packages. I think there is another file the might need to be edited to get image mode to load the packages.
To load them into MathJax, you would need to include something like
TEXT(MODES(HTML=>'\(\require{cancel}\)', TeX=>''));
or
TEXT(MODES(HTML=>'\(\require{mhchem}\)', TeX=>''));
at the top of the problem file that needed them (just after the TEXT(beginproblem());
line).
Then you can do things like
BEGIN_TEXT
\(\ce{H2O}\)
END_TEXT
Note also that there is a MathObject context for Reactions (contextReaction.pl
) that might be able to substitute for some aspects of mhchem.