4

I am making a multiple-choice test. For some problems, the choices are nicely displayed in the tabbing environment. For some problems, since the choices display quotients, I don't think the tabbing environment is suitable. I know that \\ [5mm] at the end of a line in a tabbing environment either sets the inter-line spacing at 5mm or increases the default inter-line spacing by 5mm. I want the display of choices to be the same whether I am using the tabbing environment or the alignment environment.

I give a sample consisting of two problems. The choices of the first problem are displayed the way I like. How do I put the choices of the second problem \hspace*{2em} from the left margin?

I display the third problem only to show that the inter-line spacing is too big when the choices are usual in-line expressions. What is the inter-line spacing for these two environments?

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}

\begin{document}

\noindent {\bf 1.) }$A$, $B$, $C$, $D$, $E$, and $F$ are six points in the Cartesian plane. A line is drawn if, and only if, it contains two of these points. If no line contains three of the given points, how many lines are drawn?
\begin{tabbing}
\hspace*{2em} \= \kill
\> {\bf{a.) }}15 \\
\> {\bf{b.) }}18 \\
\> {\bf{c.) }}20 \\
\> {\bf{d.) }}30 \\
\> {\bf{e.) }}36
\end{tabbing}
\vskip0.25in


\noindent {\bf 2.) }A rectangular pen enclosing 4,000 square meters is to be made from split rail fencing along the span of one side of a barn. The pen is to be divided into three smaller, rectangular regions with more split rail fencing. If the side of this barn bordering the pen is $y$ meters long, how many meters of split rail fencing is needed to make the pen?
\begin{align*}
&\mbox{\bf{a.) }}\displaystyle{y + \frac{4,000}{y}} \\
&\mbox{\bf{b.) }}\displaystyle{y + \frac{16,000}{y}} \\
&\mbox{\bf{c.) }}\displaystyle{y + \frac{16,000}{3y}} \\
&\mbox{\bf{d.) }}\displaystyle{3y + \frac{8,000}{3y}} \\
&\mbox{\bf{e.) }}\displaystyle{3y + \frac{16,000}{3y}}
\end{align*}
\vskip0.25in


\noindent {\bf 3.) }Some bacteria are being cultured in a laboratory. The population of the bacteria in the culture $t$ days after the culture began is modeled by the function
\begin{equation*}
P(t) = 3,000 \left(2^{\frac{t}{4}}\right) .
\end{equation*}
By how many bacteria does the population increase from the end of the $4^{\mathrm{th}}$ day to the end of the $16^{\mathrm{th}}$ day?

\begin{tabbing}
\hspace*{3em} \= \hspace{2.5in} \= \kill
\> {\bf{a.) }}6,000     \> {\bf{b.) }}24,000 \\
\> {\bf{c.) }}36,000    \> {\bf{d.) }}42,000 \\
\> {\bf{e.) }}48,000
\end{tabbing}


\end{document}
user74973
  • 4,071
  • 1
    why are you numbering "by hand" rather than use section headings or lists that number automatically? – David Carlisle May 14 '15 at 16:31
  • @David Carlisle I just followed what I saw in an old manual. – user74973 May 14 '15 at 17:06
  • 7
    burn that manual:-) – David Carlisle May 14 '15 at 17:10
  • @David Carlisle I am looking at the enumitem package now. You're right - the manual is obsolete. – user74973 May 14 '15 at 17:17
  • @David Carlisle Do you know the size of the inter-line spacing in the tabbing environment? I would like to keep that spacing, I think, when I use the enumitem package. – user74973 May 14 '15 at 17:30
  • 1
    tabbing has no vertical space it's just normal spacing as in a paragarph, so \baselineskip – David Carlisle May 14 '15 at 18:42
  • @David Carlisle I added \usepackage{enumitem} to the preamble of my file, and I put all the choices in the three problems in an enumerate environment, but I get at least double the inter-line spacing than what I would expect from \baselineskip. I put the options label=\bfseries \alph*.), itemsep=\baselineskip,, and itemindent=0mm in all of the enumerate environments. – user74973 May 15 '15 at 14:59
  • @David Carlisle After looking at the display, I decided the choices in 1.) and 3.) would look much better in two columns. What is the option to start the second column 2.5 inches from the left side of the first column? What is the syntax to put two entries on the row. (For example, in the tabbing environment, \> would indicate that the entry that follows belongs in the next column.) – user74973 May 15 '15 at 15:01
  • just but \begin{multicolumn}{2} before the list and \end{multicolumn} after it and and latex will split it at the right place, (multicols package) – David Carlisle May 15 '15 at 15:06
  • @David Carlisle How do I specify that I want the columns 2.5in apart? The numbers in the choices for the first problem are 15, 18, 20, 30, and 36. I will typset item 15 followed by something that indicates skip to next tab, 20. With two numbers on a line, LaTeX puts any other numbers on other lines. Is that what you are saying? – user74973 May 15 '15 at 15:13

2 Answers2

7

You can use the enumitem package. This gives you a lot of power to customise the enumerations. You can customise the vertical and horizontal spacing by giving the enumerate optional arguments. See the documentation http://anorien.csc.warwick.ac.uk/mirrors/CTAN/macros/latex/contrib/enumitem/enumitem.pdf for details, I think it is well explained there. Your code would look like this (I think it would also make your code more legible):

\begin{enumerate}[label=\bfseries \alph*.), itemsep=0.5em]
  \item $ y + \dfrac{4,000}{y} $
  \item $ y + \dfrac{16,000}{y} $
  \item $ y + \dfrac{16,000}{3y} $
  \item $ 3y + \dfrac{8,000}{3y} $
  \item $ 3y + \dfrac{16,000}{3y} $
\end{enumerate}

enter image description here

EDIT: For completeness, I am including a complete file with two variables that globally control the inter-line spacing and left indentation:

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{enumitem}


% Change these to globally change inter-line spacing and left indentation
\def\interLine{0.5em}
\def\leftMargin{0cm}

\begin{document}

\noindent {\bf 1.) }$A$, $B$, $C$, $D$, $E$, and $F$ are six points in the Cartesian plane. A line is drawn if, and only if, it contains two of these points. If no line contains three of the given points, how many lines are drawn?
\begin{enumerate}[label=\bfseries \alph*.), itemsep=\interLine, itemindent=\leftMargin]
  \item 15
  \item 18
  \item 20
  \item 30
  \item 36
\end{enumerate}
\vskip0.25in

\noindent {\bf 2.) }A rectangular pen enclosing 4,000 square meters is to be made from split rail fencing along the span of one side of a barn. The pen is to be divided into three smaller, rectangular regions with more split rail fencing. If the side of this barn bordering the pen is $y$ meters long, how many meters of split rail fencing is needed to make the pen?
\begin{enumerate}[label=\bfseries \alph*.), itemsep=\interLine, itemindent=\leftMargin]
  \item $ y + \dfrac{4,000}{y} $
  \item $ y + \dfrac{16,000}{y} $
  \item $ y + \dfrac{16,000}{3y} $
  \item $ 3y + \dfrac{8,000}{3y} $
  \item $ 3y + \dfrac{16,000}{3y} $
\end{enumerate}
\vskip0.25in


\noindent {\bf 3.) }Some bacteria are being cultured in a laboratory. The population of the bacteria in the culture $t$ days after the culture began is modeled by the function
\begin{equation*}
P(t) = 3,000 \left(2^{\frac{t}{4}}\right) .
\end{equation*}
By how many bacteria does the population increase from the end of the $4^{\mathrm{th}}$ day to the end of the $16^{\mathrm{th}}$ day?
\begin{enumerate}[label=\bfseries \alph*.), itemsep=\interLine, itemindent=\leftMargin]
  \item 6,000
  \item 24,000
  \item 36,000
  \item 42,000
  \item 48,000
\end{enumerate}


\end{document}
Augustin
  • 5,695
  • Maybe some space between the items is needed (the fractions are touching each other). – Alenanno May 14 '15 at 16:44
  • 1
    This can be done easily by using e.g. \begin{enumerate}[label=\bfseries \alph*.), itemsep=0.5em]. – Augustin May 14 '15 at 16:47
  • I meant to fix it in your answer. :P – Alenanno May 14 '15 at 16:48
  • Autopilot, sorry. Done now :-). – Augustin May 14 '15 at 16:51
  • @Augustin This is the first time I have seen the enumerate environment. You have itemsep=0.5em as an option. I guess this is the inter-line spacing. Using the enumerate environment and the option itemsep=0.5em, can I get the same inter-line spacing between the choices in all three problems? – user74973 May 14 '15 at 17:13
  • @Augustin This may be an irrelevant question because I am primarily interested in consistency. How much are the letters indented in your display of the choices in 2.)? – user74973 May 14 '15 at 17:14
  • @Augustin For this cases, I prefer to pass before=\everymath{\displaystyle} to enumerate rather than using explicit \displaystyle or \dfrac. – Manuel May 14 '15 at 17:44
  • @Alenanno Do you know the size of the inter-line spacing in the tabbing environment? I would like to keep that spacing, I think, when I use the enumitem package. – user74973 May 14 '15 at 17:54
  • 1
    @user74973 AD 1: Yes, the itemsep=0.5em is the spacing between the inter-line spacing. You can indeed get the same spacing in all three cases if you use enumerate with that option in all three cases. AD 2: I don't really know how much the letters are indented, but you can set that using the leftmargin=... and itemindent=... options passed to the enumerate. AD 3: I would rather use enumerate in all three cases. This way you would get the same spacing in all three cases. – Augustin May 14 '15 at 18:14
  • @Augustin If I want a second column for my choices in problem 3.), how would I get 2.5in of separation? For example, I want choices a.) and b.) in the first row, choices c.) and d.) in the second row, and e.) in the third row. – user74973 May 14 '15 at 18:18
  • @user74973 Have a look at this http://tex.stackexchange.com/questions/89603/horizontal-enumeration-in-multiple-columns – Augustin May 14 '15 at 18:26
  • @Augustin I do not know the syntax to define my own commands. I know that I should learn how to do this. For now, I am learning TikZ. I am asking about enumerating to make a test. (I think that you edited one of your responses. I will look at it now.) – user74973 May 14 '15 at 18:32
  • 1
    @user74973 I found a question which is dealing exactly with you problem actually: http://tex.stackexchange.com/questions/46665/multiple-choices-questions-in-2-or-3-columns – Augustin May 14 '15 at 18:42
  • @Augustin Yes, that is exactly what I was asking. Thanks. I edited my post so that the choices in 3.) are displayed in two columns. I would like, I think, the inter-line spacing to be \baselineskip, which is the inter-line spacing in a tabbing environment. (I see that you have \def\interLine{0.5em}. Can that be replaced with \baselineskip?) I would like there to be 2.5 inches between columns - if the display is to have two columns. Please edit your code to include these changes. – user74973 May 14 '15 at 19:13
  • @user74973: Sure. Either use it directly or use \def\interLine{\baselineskip}. – Augustin May 14 '15 at 19:26
  • @Augustin I seem to get the same inter-line spacing with \def\interLine{\baselineskip} and with \def\interLine{0.5em} in the preamble. Anyway, the inter-line spacing in both is bigger than what I had using the tabbing environment. – user74973 May 15 '15 at 01:04
  • @Augustin Also, I edited my original post so that the choices in 3.) are displayed in two columns. How do I do that with an enumerate environment? (I looked in the manual. That doesn't help at all. Why are there any examples?!) Please include the display with your response. – user74973 May 15 '15 at 01:04
3

Here's an alternative using tabularstacks, which I have wrapped into the macro \answers. The inter-answer gap is set to 4pt, and a 5pt buffer is added above and below the answer field, prior to performing the 1/4in \vskip.

EDITED so that automated label may be inserted with \>. REDITED to provide \newquestion, which is simply used to start a new question, with the question number incremented.

Thus, input is in the form of

\newquestion Text of question?
\answers{
  \> answer1 \\
  \> answer2 \\
  \> ...
}

The gap between the a.) and the answer can be set with \setstacktabulargap{<length>}. The default value is \tabcolsep.

The answers default to math mode input, but adding \stackText prior to a given \answers will change the default answer mode to text. It can be changed back with \stackMath following the conclusion of \answers.

\documentclass{amsart}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tabstackengine}
\stackMath
\makeatletter
\def\answers#1{%
  \renewcommand\>{\textbf{\alph{TAB@stackindex}.)}&}%
  \setstackgap{S}{4pt}%
  \par\noindent\hspace*{2em}\addstackgap[5pt]{\tabularShortstack{rl}{#1}}%
  \vskip0.25in\par\noindent\ignorespaces%
}
\makeatother
\newcounter{Question}
\newcommand\newquestion{\stepcounter{Question}\noindent\textbf{\arabic{Question}.)\ \,}}
%\setstacktabulargap{\tabcolsep}
\begin{document}

\newquestion $A$, $B$, $C$, $D$, $E$, and $F$ are six points in the Cartesian plane. A line is drawn if, and only if, it contains two of these points. If no line contains three of the given points, how many lines are drawn?
\answers{
  \> 15 \\
  \> 18 \\
  \> 20 \\
  \> 30 \\
  \> 36 
}
\newquestion A rectangular pen enclosing 4,000 square meters is to be made from split rail fencing along the span of one side of a barn. The pen is to be divided into three smaller, rectangular regions with more split rail fencing. If the side of this barn bordering the pen is $y$ meters long, how many meters of split rail fencing is needed to make the pen?
\answers{
  \> y + \dfrac{4,000}{y} \\
  \> y + \dfrac{16,000}{y} \\
  \> y + \dfrac{16,000}{3y} \\
  \> 3y + \dfrac{8,000}{3y} \\
  \> 3y + \dfrac{16,000}{3y}
}
\newquestion Some bacteria are being cultured in a laboratory. The population of the bacteria in the culture $t$ days after the culture began is modeled by the function
\begin{equation*}
P(t) = 3,000 \left(2^{\frac{t}{4}}\right) .
\end{equation*}
By how many bacteria does the population increase from the end of the $4^{\mathrm{th}}$ day to the end of the $16^{\mathrm{th}}$ day?
\answers{
  \> 6,000 \\
  \> 24,000 \\
  \> 36,000 \\
  \> 42,000 \\
  \> 48,000
}
\end{document}

enter image description here

  • I am going to try to get the display that I want using the enumerate environment. I have some questions about the post Augustin provided, but I think someone can answer these questions for me. – user74973 May 15 '15 at 14:12
  • @user74973 The enumerate approach is very flexible. While neither approach is currently multicolumn, that might prove more of a challenge to both approaches, if you went in that direction. Best wishes. – Steven B. Segletes May 15 '15 at 15:00