WeBWorK Problems

LaTeX packages

LaTeX packages

by Zak Zarychta -
Number of replies: 2
I am now starting to put detailed solutions to some physics problems that I have written. Is it possible to load the latex package cancel?

Whilst on the subject, what are the standard latex packages that are loaded or where do I look in the directory tree to find out?

Thinking forward, it would also be useful to be able to load other packages such as mchem and hepnames. Would this be possible.

Thanks,
Zak
In reply to Zak Zarychta

Re: LaTeX packages

by Danny Glin -
If you are using MathJax as the display mode, then you won't be able to add any packages.  MathJax is not a full LaTeX renderer, so it doesn't support additional packages.

Using images mode it should be possible to add packages, though I think it is buried somewhere in the code, and I don't know how well it will work.  You would have to make sure that the package was loaded for both images mode and hardcopy generation, which are handled in different places in the code.
In reply to Zak Zarychta

Re: LaTeX packages

by Davide Cervone -
MathJax does have a few extensions that mirror some LaTeX packages. In particular, it does have cancel and mhchem (but not hepnames).

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.