\fillin[]
我在 Latex類別中使用命令exam
來產生以下輸出:
Convert the following angles from degrees to radians:
\begin{questions}
\begin{multicols}{4}
\question
\begin{align*}
180 \degree
&= \fillin[$1$] \pi \\
&= \fillin[$\frac{1}{2}$] \tau \\
&\approx \fillin[$3.14159$]
\end{align*}
\columnbreak
\question
\begin{align*}
90 \degree
&= \fillin[$\frac{1}{2}$] \pi \\
&= \fillin[$\frac{1}{4}$] \tau \\
&\approx \fillin[$1.57079$]
\end{align*}
\columnbreak
\question
\begin{align*}
270 \degree
&= \fillin[$\frac{3}{2}$] \pi \\
&= \fillin[$\frac{3}{4}$] \tau \\
&\approx \fillin[$4.71238$]
\end{align*}
\columnbreak
\question
\begin{align*}
360 \degree
&= \fillin[$2$] \pi \\
&= \fillin[$1$] \tau \\
&\approx \fillin[$6.28318$]
\end{align*}
\end{multicols}
\vspace*{\stretch{1}}
\end{questions}
輸出實際上正如我所希望的那樣。但是,我從 Overleaf 收到幾個錯誤:
\fillin[]
我懷疑放在環境中是不合適的align
。我還嘗試刪除美元符號,這通常是不允許在環境中使用的align
,但這沒有幫助並導致分數停止正確渲染。
有沒有正確的方法來處理\fillin[]
內部align
環境?
此外,這可能會更好地保存為一個單獨的問題,但是有沒有辦法使\fillin[]
命令在exam
類別外(例如在kaobook
類別中)工作?
答案1
這些絕不是錯誤。 Overleaf 編輯器被指示標記$
已知數學顯示環境中存在符號的情況。
您在括號中給出的文字是正確的答案,並且\fillin
不“知道”它是否處於數學模式:無論如何它都在文字模式下使用其參考。
您可以透過使用避免收到「錯誤」訊號
\fillin[\ensuremath{\frac{1}{2}}]
或為數學模式中使用的參數定義別名。
\documentclass[answers]{exam}
\usepackage{multicol,amsmath}
\NewDocumentCommand{\mathfillin}{oo}{%
\IfNoValueTF{#1}{\fillin}{%
\IfNoValueTF{#2}{\fillin[$#1$]}{%
\fillin[$#1$][#2]%
}%
}%
}
% guesses to make the code to compile
\newcommand{\degree}{\ensuremath{^\circ}}
\setlength{\fillinlinelength}{3em}
%%%
\begin{document}
Convert the following angles from degrees to radians:
\begin{questions}
\begin{multicols}{4}
\question
$\begin{aligned}[t]
180 \degree
&= \mathfillin[1] \pi \\
&= \mathfillin[\frac{1}{2}] \tau \\
&\approx \mathfillin[3.14159]
\end{aligned}$
\question
$\begin{aligned}[t]
90 \degree
&= \mathfillin[\frac{1}{2}] \pi \\
&= \mathfillin[\frac{1}{4}] \tau \\
&\approx \mathfillin[1.57079]
\end{aligned}$
\question
$\begin{aligned}[t]
270 \degree
&= \mathfillin[\frac{3}{2}] \pi \\
&= \mathfillin[\frac{3}{4}] \tau \\
&\approx \mathfillin[4.71238]
\end{aligned}$
\question
$\begin{aligned}[t]
360 \degree
&= \mathfillin[2] \pi \\
&= \mathfillin[1] \tau \\
&\approx \mathfillin[6.28318]
\end{aligned}$
\end{multicols}
\vspace*{\stretch{1}}
\end{questions}
\end{document}
請注意,這align*
不是適合該工作的工具:`$\begin{aligned}[t]...\end{aligned}$ 更好。
沒有該answers
選項: