[Tex/LaTex] Nicely-spaced multiple choice options

exammacrosspacing

I am maxing an exam using LaTeX and use this command for making multiple-choice options:

\newcommand{\mc}[5]{(\textbf{A}) #1 \qquad \qquad (\textbf{B}) #2 \qquad \qquad (\textbf{C}) #3 \qquad \qquad (\textbf{D}) #4 \qquad \qquad (\textbf{E}) #5}

However, for small answer choices (like 1 or 2) or for long ones (like names, etc.), the answer choices don't fit all the way across the screen, since I have the space between each option hard-coded in with \qquad.

Is there a way to automatically make the options space themselves out correctly so that they fit exactly across the page?

Thanks in advance.

Best Answer

Here is an alternative using the tasks package:

enter image description here

\documentclass{article}
\usepackage{tasks}
\setlength{\parindent}{0pt}

\begin{document}

\textbf{Question}: Here is the question text. Answers are arranged in 4 columns.
\begin{tasks}(4)
\task first answer
\task second answer
\task third answer
\task fourth answer
\end{tasks}

\bigskip

\textbf{Question}: Here is the question text. Answers are arranged in 2 columns.
\begin{tasks}(2)
\task first answer
\task second answer
\task third answer
\task fourth answer
\end{tasks}

\bigskip

\textbf{Question}: Here is the question text. Answers are arranged in 2 columns and are longer than a single line.
\begin{tasks}(2)
\task first answer first answer first answer first answer
\task second answer second answer second answer
\task third answer 
\task fourth answer
\end{tasks}

\end{document}

If you want your answer to spread across the whole textwidth, you could use tabularx as follows: (The red vertical lines indicate the width of the textblock). Please note that with this method, the spaces between the first and second , as well as between the second last and the last column will be bigger than the spaces between the other columns. (See also this comment)

enter image description here

\documentclass{article}
\usepackage{tabularx}
\setlength{\parindent}{0pt}
\begin{document}

\textbf{Question}: Here is the question text. Answers are arranged in 4 columns and take up the entire textwidth.

\begin{tabularx}{\textwidth}{@{}X>{\centering\arraybackslash}X>{\centering\arraybackslash}X>{\raggedleft\arraybackslash}X@{}}
 \textbf{A} first answer &
 \textbf{B} second answer &
 \textbf{C} third answer &
 \textbf{D} fourth answer
\end{tabularx}

\end{document}

Using tabular* in combination with \extracolsep{\fill} one can achieve the following output.Here, the horizontal white spaces between adjacent columns will be equal. If your answers are too long and need a linebreak, you might want to switch to p type columns instead. Please also note, that with this method, the width each answer takes up is different.

enter image description here

\documentclass{article}
\setlength{\parindent}{0pt}
\begin{document}

\textbf{Question}: Here is the question text. Answers are arranged in 4 columns and take up the entire textwidth.

\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ccccc}
 \textbf{A} 1 &
 \textbf{B} 2 &
 \textbf{C} 3 &
 \textbf{D} 4 &
 \textbf{E} 5
\end{tabular*}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ccccc}
 \textbf{A} 1 &
 \textbf{B} 2 &
 \textbf{C} 3 &
 \textbf{D} 4 &
 \textbf{E} longer text
\end{tabular*}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ccccc}
 \textbf{A} 1 &
 \textbf{B} long text &
 \textbf{C} 3 &
 \textbf{D} 4 &
 \textbf{E} longer text
\end{tabular*}

\end{document}