# \ ce command not recognized within the H5P, no chemical formulas possible

\ ce command not recognized within the H5P I installed on moodle:

Hello, I'm not able to write mathematical expressions and chemical formulas inside the H5P that I installed in Moodle 3.8. Before installing the H5P plugin I used to successfully write formulas and chemical reactions in Moodle. For example, the command

\(\ce{Bi}\) + \(\ce{HNO3}\) \(\ce{->}\) \(\ce{Bi(NO3)3}\) + \(\ce{NO2}\) + \(\ce{H2O}\)

The commands above worked to write the oxidation reaction of bismuth by HNO3 on Moodle 3.8. Perfect.

For this to be possible, in the administration of the Moodle site I went there in plugins, filters, manage filters and configured Mathjax because mhchem is a Mathjax package.

Then I started using the H5P plugin in Moodle to improve my graphical interface. Right away H5P did not recognize the formulas I usually write on moodle and displayed the message (Undefined control sequence \ce) when I try to use mhchem commands. when I try to use mhchem commands.

Seeking help on the internet, I was directed to the page: https://h5p.org/mathematical-expressions

I did not understand the instructions very well because I am illiterate in computers. What I did was proceed to the administration of my Moodle page, I clicked on manage H5P content and uploaded the file (h5p-math-display-1.0.5.h5p).

It now appears in Moodle that the Mathdisplay Library is installed. The problem is that I'm still not able to write the chemical formulas and mathematical expressions in H5P that I use in Moodle. Outside the H5P, chemical formulas worked.

I tried other things too. I put the code contained in the last frame of the page

https://h5p.org/mathematical-expressions

in my server's config.php but it hasn't changed at all. I don't know if I should mofify MathJax configuration file in any way.

I'm writing to ask you for help so that I can finally write chemical formulas on Moodle's H5P. Thanks a lot for the help.

Renato

otacke

Tue, 06/30/2020 - 14:44

Permalink

## Hi Renato!The default

Hi Renato!

The default MathDisplay library does only use plain MathJax loaded from a so called CDN on the internet without any additional extensions like mhchem. Your approach of modifying the config.php file was correct in general, but if you just copy and paste the code from that page, you'll not change anything.

I believe it's enough to add

to the list of

configparameters of MathJax (after the messageStyle definition) inside config.php (googled that for you ;-)).Best,

Oliver

rcambrosio

Tue, 06/30/2020 - 20:06

Permalink

## mhchem.js

Hi Oliver,

Thank you for your help.

I tryed your suggestion but anywhere I paste the command lines an error (syntax error, unexpected T_constant_encapsed_string, expecting ')')

Here is the code:

// BEGGIN ADDED BY ME FROM https://h5p.org/mathematical-expressions $CFG->mod_hvp_library_config = array( "H5P.MathDisplay" => array( "observers" => array( array("name" => "mutationObserver", "params" => array("cooldown" => 500)), array("name" => "domChangedListener"), array("name" => "interval", "params" => array("time" => 1000)) ), "renderer" => array( "mathjax" => array( "src" => "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js", "config" => array( "extensions" => array("tex2jax.js"), "jax" => array("input/TeX", "output/HTML-CSS"), "tex2jax" => array( // Important, otherwise MathJax will be rendered inside CKEditor "ignoreClass" => "ckeditor" ), "messageStyle" => "none" "TeX" => array( "extensions" => array("mhchem.js") ), ) ) ) ) ); // END - added from https://h5p.org/mathematical-expressions

am I pasting in the right place?

By the way, in my moodle page, to mhchem work on Moodle in filters, I configurated mathjax with the following code ( I don't know if it is relevant to write chemical equations in H5P)

MathJax.Ajax.config.path["mhchem"] = "https://cdnjs.cloudflare.com/ajax/libs/mathjax-mhchem/3.3.2"; MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true }, TeX: { Macros: { sen: "{\\operatorname{sen}}", senh: "{\\operatorname{senh}}", arcsen: "{\\operatorname{arcsen}}", arcsenh: "{\\operatorname{arcsenh}}", arccos: "{\\operatorname{arccos}}", arccosh: "{\\operatorname{arccosh}}", arctg: "{\\operatorname{arctg}}", arctgh: "{\\operatorname{arctgh}}", cossec: "{\\operatorname{cossec}}", cossech: "{\\operatorname{cossech}}", sech: "{\\operatorname{sech}}", tg: "{\\operatorname{tg}}", tgh: "{\\operatorname{tgh}}", cotg: "{\\operatorname{cotg}}", cotgh: "{\\operatorname{cotgh}}", arcsec: "{\\operatorname{arcsec}}", dist: "{\\operatorname{dist}}", mdc: "{\\operatorname{mdc}}", mmc: "{\\operatorname{mmc}}", C: "{\\mathbb{C}}", R: "{\\mathbb{R}}", Q: "{\\mathbb{Q}}", Z: "{\\mathbb{Z}}", N: "{\\mathbb{N}}" }, extensions: ["[mhchem]/mhchem.js"] }, config: ["Accessible.js", "Safe.js"], errorSettings: { message: ["!"] }, skipStartupTypeset: true, messageStyle: "none" }); MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions.macros,{ cancel: ["Extension","cancel"], bcancel: ["Extension","cancel"], xcancel: ["Extension","cancel"], cancelto: ["Extension","cancel"] }); });

otacke

Tue, 06/30/2020 - 20:43

Permalink

## Hi rcambrosio!Even without

Hi rcambrosio!

Even without knowing anything about coding, I believe it's very easy to follow the logic of those lines and notice that your code is lacking a comma after

"messageStyle" => "none"...Sorry if this comes across as rude. I guess I need a break from helping the H5P community. It's too frustrating for me.

Best,

Oliver

rcambrosio

Wed, 07/01/2020 - 14:56

Permalink

## It worked. Thank you

It finally worked. I am very grateful to you and I apologize for making fun of you with my ignorance. If one day you need something inside physicochemical I will be happy to help you.

Best

Renato

otacke

Wed, 07/01/2020 - 23:09

Permalink

## Hi Renato!Don't worry, I just

Hi Renato!

Don't worry, I just had a bad day. I feel sorry for my behavior.

Best,

Oliver