I'm compiling this simple quiz under LaTex TexShop 4.27

\def\EN{{\bf A}}
\begin{essay}{Question A}
Report on study case \EN\  with numerical values:
\begin{tabular}{|c|c|} \hline
     $x$ & $y$  \\ \hline
     \XV & \YV  \\ \hline
  \item Case \EN\  with numerical values \XV,\YV

and I get a nice pdf file. But inside the moodle.xml file the defined values don't appear anywhere and the body of the question is:

<text><![CDATA[<p>Report on study case \EN  with numerical values: <CENTER>\begin {tabular}{|c|c|} \hline \(x\) & \(y\) <BR/> \hline \XV & \YV <BR/> \hline \end {tabular}</CENTER> </p>]]></text>

producing this ugly result inside moodle:

enter image description here

What is happening with my definitions and the tabular environment ?.

  • change all the \def to \newcommand and it all compiles fine.
    – oliversm
    May 14 '20 at 12:52
  • 2
    Section 4 of the manual lists the commands and environments that get translated into HTML; tabular is not among them, neither are, of course, your personal commands.
    – egreg
    May 14 '20 at 15:16

This is what the package moodle documentation says; in particular, neither tabular nor your personal commands are supported.

enter image description here

  • Thanks for the clarifying remark. I get confused since environments like \begin{array} work flawlessly and also in the introduction I read: "Users of LaTeX are also accustomed to the speed and flexibility that comes from defininf their own macros, which may be as brief as writting \R instead of \mathbb{R} or as complex as macros that generate entire paragraphs of text. The Moodel editor, by constrast, requires you to type \mathbb{R} every single time you want R"
    – JMS
    May 17 '20 at 7:18

If you really need a tabular, the best solution I can see is to pack it into an image. For instance, see this answer.

However, for your macros, I figured out there is an undocumented utility to declare them for expansion by the package before writing in the XML file : \htmlregister. In your case, just place at the end of the preamble:

\def\EN{{\bf A}}

In a development version of the package, I introduced the command \moodleregisternewcommands which triggers the expansion of all macros subsequently defined using \newcommand (and the likes). See this fixed issue. In this case, the use is:

\newcommand{\EN}{{\bf A}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.