Reputation: 433
I am using exams2moodle()
to create exam quizzes. I would like to use some math symbols which require the LaTeX package amssymb
. How should I proceed?
Upvotes: 2
Views: 1092
Reputation: 17183
TL;DR: amssymb
LaTeX symbols are supported by MathJax which is the default renderer in a standard Moodle installation. So these symbols should work out of the box when using exams2moodle(..., converter = "pandoc-mathjax")
which is the default sinc R/exams 2.3.3 (released in July 2019).
Details: As already pointed out by the answer of @Hack-R, there are various ways of including mathematical notation written in LaTeX in HTML-based exercises. An overview is given in this blog post: http://www.R-exams.org/tutorials/math/
It is important to note that in this case the LaTeX code is not actually processed by LaTeX itself. It can either be converted to MathML (using pandoc
or ttm
) or rendered in the browser by the MathJax JavaScript library. In any case it depends on the converter/renderer which LaTeX commands can be successfully displayed. All of them support basic LaTeX commands plus some extra commands from certain packages. Which additional commands from which packages are supported depends on the converter/renderer. In any case, the capabilities can not be extended by style files!
In a standard Moodle installation MathJax is enabled which suports the AMS LaTeX package (because MathJax was developed by/for the AMS!). So the best strategy is to simply keep the LaTeX in the HTML for Moodle. This can be done with exams2moodle(..., converter = "pandoc-mathjax")
which is actually the default converter
since R/exams 2.3.3 released in July 2019. In previous versions of R/exams, the default was converter = "ttm"
which did not support all the amssymb
symbols.
Upvotes: 2
Reputation: 23214
In general, you input your symbols into either .Rmd
or .Rnw
and you can have it rendered with any available engine (e.g. pandoc, mathjax, knitr, etc).
install.packages("exams")
require(exams)
xWeave is called on each exercise file and creates LaTeX code
elearn_exam <- c("swisscapital.Rmd", "deriv.Rmd", "ttest.Rmd",
"boxplots.Rmd", "function.Rmd", "lm.Rmd", "fourfold2.Rmd")
set.seed(2020-04-16)
exams2moodle()
produces an XML file that may be uploaded into Moodle
It goes from LaTeX to HTML then HTML to XML
exams2moodle(elearn_exam, n = 3, name = "R-exams")
To add custom LaTeX packages you can modify the preamble as per the answers in this post, i.e. \usepackage
As described in the linked post, that can either be done direct, i.e.
---
title: "Title"
author: "Me"
header-includes:
- \usepackage{mypackage}
output:
pdf_document
---
or via a mystyles.sty
file in the same directory.
Upvotes: 1