2

I'm giving students a problem involving eight limit/function requirements and would like them to be equally spaced onto two lines. Here's the code:

\documentclass[11pt, bothsides]{exam}
\usepackage{multicol}
\usepackage{amsmath}
\extrawidth{1in}
\begin{document}
\begin{questions}
\question[10] Draw an example of a function $f(x)$ that satisfies the following conditions:
\newline
\begin{multicols}{4}
    $$\lim_{x\to-2}f(x)=1$$
    $$f(-2)=\text{DNE}$$
    $$\lim_{x\to2^-}f(x)=-4$$
    $$f(2)=3$$
    $$\lim_{x\to2}f(x)=\text{DNE}$$
    $$f(4)=-2$$
    $$\lim_{x\to4}f(x) \hspace{.1in} \text{exists}$$
    $$\lim_{x\to4}f(x)\neq f(4)$$
\end{multicols}
\end{questions}
\end{document}

But here's the output:

Note the uneven first column

Any ideas why this might be the case? I think it may be due to the extrawidth command, but removing it just screws things up a bit more:

All bets are off

Any ideas? It's not a deal-breaker, but would like to help understand things. Perhaps an array would be better?

3
  • The immediate cause of the problem you've run into is the absence of a \noindent instruction immediately after \begin{multicols}{4}. Your code raises some other issues, though, which I've tried to address in my answer.
    – Mico
    Sep 30 '16 at 17:17
  • @Mico, a quick follow-up: since I'm using the exam package I often have scenarios where, for example, I have four quick derivative problems that I'd like to space out in a 2x2 array. Any thoughts on this? It seems that using alignat* or gather* will cause some issues. I have been using 'multicols' to solve this so far. Oct 17 '16 at 17:32
  • Could you spell out the "issues" that might be caused by using the alignat* and gather* environments? At any rate, there's nothing stopping you from setting up a 2x2 array environment, is there?
    – Mico
    Oct 17 '16 at 20:03
2

Since you're also loading the amsmath package, you might as well make use of its alignat* environment to line up the 8 equations. In the example below, I've set a distance of 4em (equivalent to 4 "quads") between the columns; feel free to modify the spacing as you see fit.

enter image description here

\documentclass[11pt, bothsides]{exam}
\usepackage{amsmath}
\extrawidth{1in}
\begin{document}
\begin{questions}
\question[10] Draw an example of a function $f(x)$ that satisfies the following conditions:

\begin{alignat*}{4}
&\lim_{x\to-2}f(x)=1&\hspace{4em}&
 f(-2)=\text{DNE}&\hspace{4em}&
 \lim_{x\to2^-}f(x)=-4&\hspace{4em}&
 f(2)=3\\
&\lim_{x\to2}f(x)=\text{DNE}&&
 f(4)=-2&&
 \lim_{x\to4}f(x) \text{ exists}&&
 \lim_{x\to4}f(x)\neq f(4)
\end{alignat*}
\end{questions}
\end{document}

I think of the multicols environment as something meant primarily for text. Using (abusing?!) this environment to typeset a bunch of displayed equations probably raises all kinds of issues that the package's author never considered. If, for some reason, you simply must use it in your code, I would suggest you use a gather* environment instead of 8 individual displayed equations. Oh, and observe the use of \noindent after \begin{multicols}{4}.

enter image description here

\documentclass[11pt, bothsides]{exam}
\usepackage{amsmath,multicol}
\allowdisplaybreaks
\extrawidth{1in}
\begin{document}
\begin{questions}
\question[10] Draw an example of a function $f(x)$ that satisfies the following conditions:

\begin{multicols}{4}
\noindent
\begin{gather*}
\lim_{x\to-2}f(x)=1\\
f(-2)=\text{DNE}\\
\lim_{x\to2^-}f(x)=-4\\
f(2)=3\\
\lim_{x\to2}f(x)=\text{DNE}\\
f(4)=-2\\
\lim_{x\to4}f(x) \text{ exists}\\
\lim_{x\to4}f(x)\neq f(4)
\end{gather*}
\end{multicols}
\end{questions}
\end{document}
1
  • Both solutions are great, and thanks for the quicker fix of \noindent. I'll make some changes for next time using \alignat* and I'll look up some more examples to get a better handle on the usage. Sep 30 '16 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.