# Moodle package. Problem with definitions and environments

I'm compiling this simple quiz under LaTex TexShop 4.27

\documentclass[12pt]{article}
\usepackage{moodle}
\def\EN{{\bf A}}
\def\XV{3}
\def\YV{4}
%---------------------------
\begin{document}
\begin{quiz}{MyQuiz}
\begin{essay}{Question A}
Report on study case \EN\  with numerical values:
\begin{center}
\begin{tabular}{|c|c|} \hline
$x$ & $y$  \\ \hline
\XV & \YV  \\ \hline
\end{tabular}
\end{center}
\item Case \EN\  with numerical values \XV,\YV
\end{essay}
\end{quiz}
\end{document}


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:

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

• change all the \def to \newcommand and it all compiles fine. May 14 '20 at 12:52
• 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. May 14 '20 at 15:16

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

• 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}}
\def\XV{3}
\def\YV{4}
\htmlregister{\EN}
\htmlregister{\XV}
\htmlregister{\YV}



\moodleregisternewcommands
\newcommand{\EN}{{\bf A}}
\newcommand{\XV}{3}
\newcommand{\YV}{4}