0

In certain situations within the exam class, I would like the parts or subparts enumeration to read left-to-right (across) columns, rather than high to low (down) columns. Here's a working example:

enter image description here enter image description here

\documentclass{exam}
\usepackage{amsmath,pgf,tikz,pgfplots,multicol}

%Lengthens \fillin answer lines and raises text above the line so text isn't cut off by the answer line, see documentation http://mirror.utexas.edu/ctan/macros/latex/contrib/exam/examdoc.pdf and this question https://tex.stackexchange.com/questions/352246/vertical-spacing-between-fillin-in-exam \setlength\fillinlinelength{4cm} \setlength\answerclearance{1.25ex}

%Customizes spacing between list items, and adjusts spacing betwen multicols to match. From https://tex.stackexchange.com/questions/597536/exam-parts-in-multicols-left-to-right-numbering/597560#597560 \setlength{\itemsep}{8mm} \setlength{\multicolsep}{\itemsep}

%The following is to make a node style answer which has by default text opacity=0 but changes to text opacity=1 when \printanswers is issued. See: %https://tex.stackexchange.com/questions/485101/put-exam-answerline-blanks-as-nodes-inside-tikzpicture %https://tex.stackexchange.com/questions/497877/how-to-reveal-tikz-plot-with-printanswers-in-exam-class/497901 \tikzset{answer/.style={draw,text opacity=0},answer plot/.style={opacity=0}} \let\oldprintanswers\printanswers \def\printanswers{\oldprintanswers\tikzset{answer/.style={text opacity=1}, answer plot/.style={opacity=1}}} %\printanswers

\begin{document} \begin{questions} \question[12] For the rational function \begin{equation} f(x)=\frac{3x+5}{x+2}, \end{equation}

\begin{parts} \part[2] Use polynomial division to rewrite $f(x)$ in mixed fraction form $q(x)+\frac{r(x)}{d(x)}$. \begin{solution} \begin{equation} f(x)=3-\frac{1}{x+2} \end{equation} \end{solution} \vspace*{\stretch{1}}

\part Use transformations of the parent function $\frac{1}{x}$ to graph $f(x)$. \begin{center} \begin{tikzpicture} \begin{axis}[grid, axis x line=middle, axis y line=middle, xlabel={$x$}, ylabel={$f(x)$}, height=8cm, xtick={-5,-4,...,5}, ytick={-5,-4,...,5}, xmin=-6, xmax=6, ymin=-6, ymax=6] \addplot[domain=-6:-2.1, samples=100, mark=none, thick, blue, answer plot]{3-1/(x+2)}; \addplot[domain=-1.9:6, samples=100, mark=none, thick, blue, answer plot]{3-1/(x+2)}; \addplot +[mark=none, dashed, blue, answer plot] coordinates {(-2, -6) (-2, 6)}; \addplot +[mark=none, dashed, blue, answer plot] coordinates {(-6, 3) (6, 3)}; \end{axis} \end{tikzpicture} \end{center} \vspace*{\stretch{1}}

\part[6] Find the following function features: \begin{subparts} \begin{multicols}{2} \subpart \small{\textbf{Domain:}} \fillin[$(-\infty,-2)\cup(-2,\infty)$] \columnbreak \subpart \small{\textbf{Range:}} \fillin[$(-\infty,3)\cup(3,\infty)$] \end{multicols}

\begin{multicols}{2} \subpart \small{\textbf{Increasing:}} \fillin[$(-\infty,-2)\cup(-2,\infty)$] \columnbreak \subpart \small{\textbf{Decreasing:}} \fillin[$\emptyset$] \end{multicols}

\begin{multicols}{2} \subpart \small{\textbf{$x$-intercept(s):}} \fillin[$\left\langle -\frac{5}{3},0\right\rangle$] \columnbreak \subpart \small{\textbf{$y$-intercept:}} \fillin[$\left\langle 0,\frac{5}{2}\right\rangle$] \end{multicols}

\begin{multicols}{2} \subpart \small{\textbf{Asymptotes:}} \fillin[$x=-2, y=3$] \columnbreak \subpart \small{\textbf{Maxima/minima:}} \fillin[None] \end{multicols} \end{subparts} \vspace*{\stretch{1}}

\part[6] Find the following function limits: \begin{subparts} \begin{multicols}{2} \subpart $\lim_{x\to 3^{-}} f(x)=$ \fillin[$-\infty$] \subpart $\lim_{x\to 3^{+}} f(x)=$ \fillin[$\infty$] \subpart $\lim_{x\to 3} f(x)=$ \fillin[$DNE$] \columnbreak \subpart $\lim_{x\to 4} f(x)=$ \fillin[$-1$] \subpart $\lim_{x\to \infty} f(x)=$ \fillin[$-2$] \subpart $\lim_{x\to -\infty} f(x)=$ \fillin[$-2$] \end{multicols} \end{subparts} \vspace*{\stretch{1}} \end{parts}

\end{questions} \end{document}

What worked: I am happy that the subparts in (c) read across columns, and those in (d) read down columns.

What didn't work: The spacing is inconsistent. The parts and subparts that read left-to-right (across) columns have more vertical space than the parts and subparts that read high to low (down) columns.

This question is similar, but I don't want to define custom enumerate / itemize / tasks. I would like to keep using the pre-defined parts and subparts so I don't lose their exam class features.

EthanAlvaree
  • 1,367

1 Answers1

1

The spacing between the multicols environment is defined by \multicolsep. In the other question (d), the spacing is defined by the list items, i.e. \itemsep. Therefore the following command should give you equal spacing:

\setlength{\multicolsep}{\itemsep}

EDIT: If you want to change the spacing in the \subparts for example, you have to put the relevant definitions in \subparthook. There are hooks for most construct, see section 4.10 (Customizing the list parameters) in the exam class documentation.

The customisation becomes then

\renewcommand\subpartshook{%
  \setlength{\itemsep}{8mm}%
  \setlength{\multicolsep}{\itemsep}%
}

enter image description here

  • Thanks, Pieter! This is a good option and I will use it in some places. In other places where I would like more spacing, is it possible to do the reverse -- lengthen spacing between itemsep to match spacing between multicols? Or make it all automatically spread out and adjustable similar to \vspace*{\stretch{1}}? – EthanAlvaree May 18 '21 at 17:37
  • You can also say \setlength{\itemsep}{6mm} or whatever you want it to be, and set \multicolsep to the same (using the above command for example). – Pieter van Oostrum May 18 '21 at 18:38
  • Hi Pieter, it seems that \setlength{\itemsep}{8mm} has no effect on the spacing of the part and subpart spacing. The subpart spacing in part (d) remains compact no matter what value I change the parameter to. I will update the original post with a new screenshot. – EthanAlvaree May 18 '21 at 20:27
  • See the edit in my answer. – Pieter van Oostrum May 18 '21 at 20:49
  • Wonderful - thank you very much for your help! – EthanAlvaree May 19 '21 at 05:23