When I use exams2moodle()
to generate a cloze quiz, LaTeX symbols are not generated correctly.
Example: (in .Rmd file): ... $\hat{p}$
In Moodle it is presented as: \hat{p}
(Observation: It works in exams2html()
.)
It is converted as: <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mover><mi>p</mi><mo accent="true">^</mo></mover><annotation encoding="application/x-tex">\hat{p}</annotation></semantics></math>
And finally: If I edit the question in Moodle and change to $$\hat{p}$$
, every thing works. But this way, I will have a lot of editions, and that is very bad.
For including LaTeX in HTML-based output in R/exams there is no single best solution. And all solutions have potential drawbacks.
By default, exams2moodle()
converts the mathematical equations to MathML which can be rendered directly by various browsers (Firefox is recommended). Advantage: MathML looks good in Firefox and needs no further support either on server-side or client-side. Disadvantage: Does not work in some browsers, specifically not in Chrome.
As an alternative the equations can also be embedded in LaTeX and rendered by MathJax (on the server side, i.e., not by the browser). Advantage: Works in all browsers. Disadvantage: Needs to have the MathJax scripts installed and available on the server. Users need to have JavaScript enabled in their browser.
As MathJax appears to be available in your Moodle installation I would recommend to leverage this in your exercises (which will also solve your reported problem). This can simply be switched on by
exams2moodle(..., converter = "pandoc-mathjax")
Edit: More detailed explanations are now available at http://www.R-exams.org/tutorials/math/.