0

I am using \fillin[] command in the latex exam class to produce the following output:

enter image description here

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}

The output is actually exactly as I hoped for. However, I am getting several errors from Overleaf:

enter image description here

I suspect it is not proper to put \fillin[] inside of an align environment. I also tried removing the dollar signs, which are typically not allowed inside an align environment, but this did not help and caused the fractions to stop rendering correctly.

Is there a proper way to deal with \fillin[] inside an align environment?

Additionally, this may be better saved for a separate question, but is there a way to make a \fillin[] command that works outside of the exam class, e.g. in the kaobook class?

1 Answer 1

2

These are by no means errors. The Overleaf editor is instructed to mark cases where there are $ signs inside a known math display environment.

The text you give in brackets is the correct answer and \fillin doesn't “know” whether it's in math mode or not: it uses its argument in text mode anyway.

You can avoid being signalled an “error” by using

\fillin[\ensuremath{\frac{1}{2}}]

or defining an alias for an argument to be used in math mode.

\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}

Please, note that align* is not the right tool for the job: `$\begin{aligned}[t]...\end{aligned}$ is much better.

enter image description here

Without the answers option:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .