我第一次尝试将测验上传到 Moodle,并使用包 {Moodle} 生成文件。问题是上传的文件无法识别矩阵环境,并显示代码而不是矩阵形式。有解决方案吗?
\documentclass[12pt]{article}
\usepackage{amsmath,amsthm, amssymb, latexsym}
\makeatletter
\renewcommand*\env@matrix[1][c]{\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols #1}}
\makeatother
\usepackage{moodle}
\begin{document}
\begin{quiz}{Revisiting Linear Algebra}
\begin{multi}[points=2]{Matrix Form of a Linear System}
Consider the following system
\begin{center}
$
\begin{matrix}[r]
3.0 x_1 &+2.0 x_2 &+2.0 x_3 & -5.0 x_4 & =8 .0 \\
0.6 x_1 &+ 1.5 x_2 &+1.5 x_3 & -5.4 x_4 & =2.7 \\
1.2 x_1 & -0.3 x_2 & -0.3 x_3 & 2.4 x_4 & =2.1 , \\
\end{matrix}
$
\end{center}
which may be written as a single vector equation; i.e, $\mathbf{AB}=\mathbf{B}$.\\
The $\mathbf{A}$ matrix associated with the system is:
\item*
$
\begin{bmatrix}[r]
3.0 &+2.0 &+2.0 & -5.0 \\
0.6 &+ 1.5 &+1.5 & -5.4 \\
1.2 & -0.3 & -0.3 & 2.4 , \\
\end{bmatrix}
$
\item $
\begin{bmatrix}[r]
8 .0 \\
2.7 \\
2.1 \\
\end{bmatrix}
$
\item $
\begin{bmatrix}[r]
x_1 &\\
x_2& \\
x_3 &\\
x_4 &\\
\end{bmatrix}
$
\item
$
\begin{bmatrix}[r]
3.0 &+2.0 &+2.0 & -5.0 & 8.0 \\
0.6 &+ 1.5 &+1.5 & -5.4 & 2.7 \\
1.2 & -0.3 & -0.3 & 2.4 , & 2.1\\
\end{bmatrix}
$
\end{multi}
\begin{multi}[points=2]{Matrix Form of a Linear System}
Consider the following system
\begin{center}
$
\begin{matrix}[r]
3.0 x_1 &+2.0 x_2 &+2.0 x_3 & -5.0 x_4 & =8 .0 \\
0.6 x_1 &+ 1.5 x_2 &+1.5 x_3 & -5.4 x_4 & =2.7 \\
1.2 x_1 & -0.3 x_2 & -0.3 x_3 & 2.4 x_4 & =2.1 , \\
\end{matrix}
$
\end{center}
which may be written as a single vector equation; i.e, $\mathbf{AB}=\mathbf{B}$.\\
The $\mathbf{B}$ matrix associated with the system is:
\item*
$
\begin{bmatrix}[r]
8 .0 \\
2.7 \\
2.1 \\
\end{bmatrix}
$
\item[fraction=0]
$
\begin{bmatrix}[r]
3.0 &+2.0 &+2.0 & -5.0 \\
0.6 &+ 1.5 &+1.5 & -5.4 \\
1.2 & -0.3 & -0.3 & 2.4 , \\
\end{bmatrix}
$
\item[fraction=0]
$
\begin{bmatrix}[r]
x_1 &\\
x_2& \\
x_3 &\\
x_4 &\\
\end{bmatrix}
$
\item[fraction=0]
$
\begin{bmatrix}[r]
3.0 &+2.0 &+2.0 & -5.0 & 8.0 \\
0.6 &+ 1.5 &+1.5 & -5.4 & 2.7 \\
1.2 & -0.3 & -0.3 & 2.4 , & 2.1\\
\end{bmatrix}
$
\end{multi}
\end{quiz}
\end{document}
答案1
这手动的for moodle.sty
(第 10 页) 提到,只有四种环境会被识别并转换为 html:、center
和enumerate
。因此itemize
,tikzpicture
所有其他环境(例如matrix
)都无法使用。引用(重点是我的):
请注意,moodle.sty 不知道如何将任何其他 TEX 或 LATEX 命令转换为 HTML。如果使用其他序列,它们可能 逐字通过XML 文件或可能会导致不可预测的结果。
但是,tikzpicture
您可以在 中使用 LaTeX 代码node
,这样您就可以使用环境matrix
。矩阵将由 Moodle 转换为图像,并以 base64 编码存储在文件中.xml
,类似于包含.png
文件。
请注意,要使其工作,您可能需要\tikzexternalize
在测验源代码中明确调用。也是shell-escape
必需的(与图像相同)。
梅威瑟:
\documentclass[12pt]{article}
\usepackage{amsmath,amsthm, amssymb, latexsym}
\usepackage{tikz}
\makeatletter
\renewcommand*\env@matrix[1][c]{\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols #1}}
\makeatother
\usepackage{moodle}
\usetikzlibrary{external} % set this
\tikzexternalize % explicitly
\begin{document}
\begin{quiz}{Revisiting Linear Algebra}
\begin{multi}[points=2]{Matrix Form of a Linear System}
Consider the following system
\begin{tikzpicture} % matrix inside of tikzpicture node
\node{
$\begin{matrix}[r]
3.0 x_1 &+2.0 x_2 &+2.0 x_3 & -5.0 x_4 & =8 .0 \\
0.6 x_1 &+ 1.5 x_2 &+1.5 x_3 & -5.4 x_4 & =2.7 \\
1.2 x_1 & -0.3 x_2 & -0.3 x_3 & 2.4 x_4 & =2.1 , \\
\end{matrix}
$};
\end{tikzpicture}
which may be written as a single vector equation; i.e, $\mathbf{AB}=\mathbf{B}$.\\
The $\mathbf{A}$ matrix associated with the system is:
\item*
\begin{tikzpicture}
\node{ $
\begin{bmatrix}[r]
3.0 &+2.0 &+2.0 & -5.0 \\
0.6 &+ 1.5 &+1.5 & -5.4 \\
1.2 & -0.3 & -0.3 & 2.4 , \\
\end{bmatrix}
$};\end{tikzpicture}
\item\begin{tikzpicture}
\node{ $
\begin{bmatrix}[r]
8 .0 \\
2.7 \\
2.1 \\
\end{bmatrix}
$};\end{tikzpicture}
\item \begin{tikzpicture}
\node{$
\begin{bmatrix}[r]
x_1 &\\
x_2& \\
x_3 &\\
x_4 &\\
\end{bmatrix}
$};\end{tikzpicture}
\item
\begin{tikzpicture}
\node{$
\begin{bmatrix}[r]
3.0 &+2.0 &+2.0 & -5.0 & 8.0 \\
0.6 &+ 1.5 &+1.5 & -5.4 & 2.7 \\
1.2 & -0.3 & -0.3 & 2.4 , & 2.1\\
\end{bmatrix}
$};\end{tikzpicture}
\end{multi}
\end{quiz}
\end{document}
生成的 xml 的一部分:
<questiontext format="html">
<text><![CDATA[<p>Consider the following system </P>
<P><IMG SRC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAc4AAACOCAYAAAC4 etc.
答案2
最佳实践解决方案似乎是用 Moodle 提出的解决方案来matrix
替代array
手动的, 如下:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{moodle}
\begin{document}
\begin{quiz}{Revisiting Linear Algebra}
\begin{multi}[points=2]{Matrix Form of a Linear System}
Consider the following system
\[
\left[
\begin{array}{ccccc}
3.0 x_1 &+2.0 x_2 &+2.0 x_3 & -5.0 x_4 & =8.0\\
0.6 x_1 &+ 1.5 x_2 &+1.5 x_3 & -5.4 x_4 & =2.7\\
1.2 x_1 & -0.3 x_2 & -0.3 x_3 & 2.4 x_4 & =2.1 , \\
\end{array}\right]
\]
which may be written as a single vector equation; i.e, $\mathbf{AB}=\mathbf{B}$.\\
The $\mathbf{A}$ matrix associated with the system is:
\item* First answer
\[
\left[
\begin{array}{cccc}
3.0 &+2.0 &+2.0 & -5.0 \\
0.6 &+ 1.5 &+1.5 & -5.4 \\
1.2 & -0.3 & -0.3 & 2.4 , \\
\end{array}
\right]
\]
\item Second answer
\end{multi}
\end{quiz}
\end{document}
重要的提示:当前发布的moodle
软件包版本 0.5 已过时,并且存在无法处理的错误\\
。您必须从下载最新版本这里. 安装指南如下这里。