3 Exercises
Set the document language (warning: babel can crash the document if running locally, read the answer for more details).
Answer.
Use the class option british, english, french, etc, and load the babel package. Unfortunately, passing the language as an option to the babel package itself can crash LaTeXML. Make sure to use class options for the time being, just as in the template.
Upload a SCORM package to your VLE.
Add some subsections to your document. Change the configuration (where?) so that the the document is split by subsection, or not split at all.
Answer.
This type of change goes into GNUmakefile. If you do not have one, fish it out of the bookml folder. Add the following line somewhere (normally before include bookml/bookml.mk):
or, to avoid splitting altogether,
LaTeXML splits by either section or chapter by default, depending on the document class.
Divert a block of content (for example, a difficult TikZ picture) to a ‘BookML image’.
Answer.
Wrap the block within
This generates a ‘BookML image’, i.e. an image compiled via LaTeX and converted to SVG without LaTeXML seeing what it is. To divert all TikZ pictures, add the following to your preamble, after loading TikZ.
You may as well hide TikZ completely from LaTeXML to save about 30 seconds using
Add an alternative text to an image (possibly also a BookML image).
Answer.
When using \includegraphics, add the alt={} key:
For TikZ pictures, and any other picture, use:
This also works for BookML images. There must be no other content between the picture and \bmlDescription (sometime even an empty space can cause issues).
Create a foldable environment using the HTML <details> tag, and embed a YouTube video.
Answer.
BookML supports adding HTML tags by roughly typing them as is.
The rules are:
-
•
the initial
<>must be preceded by a backslash\<; -
•
each tag MUST be closed, so
<br>must be written as\<br/>(or\<br>\</br>, but let people see that); -
•
attributes must have quoted values, so
allowfullscreenmust becomeallowfullscreen=""; -
•
TeX special characters like
&,%,#must be prefixed with a backslash too.
This mechanism is a little fragile, due to the mismatch between LaTeXML internal model and HTML, so use it only when LaTeX cannot help: foldable environments and videos.
Add a simple SageMathCell, like the following one:
Answer.
In the preamble, add
In the document,
You should probably create an environment that does all of that for you, and possibly add some custom styling (either using supported LaTeX packages like framed, or by adding your own CSS to the bmluser folder).
Create two versions of the same file, say one with the solutions to some exercises, and one without.
Answer.
Adopt the same strategy you normally use. My tip for working with BookML is that you create two files. For instance, create a secondary file exercises-without-solutions.tex like the following:
In exercises-with-solutions.tex, check if \withoutSolutions is defined to decide if solutions must be included or not. Then BookML will compile both files to separate SCORM packages. For instance:
Help, my memoir document comes out all wrong! Use \iflatexml to selectively use the book class only when running LaTeXML, so that the PDF looks as you wanted it, and to hide all memoir-specific commands from LaTeXML.
Answer.
You need to ingredients: \iflatexml allows you to run different code for PDF and HTML outputs, but you also need to access \iflatexml before even calling \documentclass! Do as follows:
Launch a screen reader and try navigating through the examples. To launch Microsoft Narrator, on Windows: Ctrl +Win +Enter . To launch VoiceOver on macOS: Fn +Cmd +F5 .
Mark a table row as header (this is not well documented!).
Answer.
I’ll just post an example here taken from the BookML tests:
\begin{tabular}{l|c|c} \lxBeginTableHead{} Test & MathJax & MathML \\ \hline \lxEndTableHead{} AMS equations \lxTableRowHead & \href{../amsldoc-equations-mathjax2/}{v2}, \href{../amsldoc-equations-mathjax3/}{v3}, \href{../amsldoc-equations-mathjax4/}{v4} & \href{../amsldoc-equations-nomathjax/}{no MathJax} \\ Mathtools equations \lxTableRowHead & \href{../mathtools-mathjax2/}{v2}, \href{../mathtools-mathjax3/}{v3}, \href{../mathtools-mathjax4/}{v4} & \href{../mathtools-nomathjax/}{no MathJax} \\ \LaTeXML{} equations test \lxTableRowHead & \href{../latexml-t-ams-mathtools-mathjax2/}{v2}, \href{../latexml-t-ams-mathtools-mathjax3/}{v3}, \href{../latexml-t-ams-mathtools-mathjax4/}{v4} & \href{../latexml-t-ams-mathtools-nomathjax/}{no MathJax} \\ Disable MathJax \lxTableRowHead & \href{../disable-mathjax-mathjax2/}{v2}, \href{../disable-mathjax-mathjax3/}{v3}, \href{../disable-mathjax-mathjax4/}{v4} & \href{../disable-mathjax-nomathjax/}{no MathJax} \\ Math variants \lxTableRowHead & \href{../mathvariants-mathjax2/}{v2}, \href{../mathvariants-mathjax3/}{v3}, \href{../mathvariants-mathjax4/}{v4} & \href{../mathvariants-nomathjax/}{no MathJax}\end{tabular}The functionality comes from the latexml.sty package, which is automatically available when running BookML.
Using a screen reader, listen to the difference between and (if you cannot run a screen reader, right click on the formulas and go to ‘Show Math As > Speech Text’; you may need to refresh the page for the speech to activate). Look at all the macros defined in latexml.sty and find the one responsible for the change, then implement the change yourself.
Given that this confusion between multiplication and function application is pervasive in the wild, you should warn your screen reader users that they must pay attention to the context.
Answer.
Here, neither LaTeXML nor MathJax can definitely guess that is a function as opposed to a number being multiplied. LaTeXML usually infers that this is a multiplication. Looking at ‘Show Math As > MathML Code’, you can see that there are different ‘invisible operators’, all of which were guessed by LaTeXML.
To ensure that LaTeXML treats a symbol as a function, wrap it in \lxFcn:
Creating your own macros is recommended:
LaTeXML allows you to customise its maths parsing more deeply, and for instance declare that the command \phi itself is a function. However, it requires some pretty good knowledge of how LaTeXML parses mathematical content.