
我第一次嘗試將測驗上傳到 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 (第 10頁moodle.sty
)提到只有四種環境被辨識並轉換為 html:center
、enumerate
和itemize
。因此,無法使用tikzpicture
所有其他環境,例如。matrix
引用(強調我的):
請注意,moodle.sty 不知道如何將任何其他 TEX 或 LATEX 指令轉換為 HTML。如果使用其他序列,它們可能是 逐字透過XML 文件,否則可能會導致不可預測的結果。
但是,在 a 中,tikzpicture
您可以在 a 中使用 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
最佳實踐解決方案似乎已替換matrix
為array
Moodle 提出的解決方案手動的, 如下:
\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已經過時,並且有一個無法處理的bug \\
。您必須從以下位置下載最新版本這裡。安裝指南是這裡。