Nicely-spaced multiple choice options34hQqWnsnOo svgikiw Xme.áts EeGg .ékök t nzs veci

3

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.

share|improve this question
New contributor
flame is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Several. For single lines, I like to use \\makebox[\\dimexpr \\linewidth/5][l]{...} for each answer. There is also tabularx with 5 X columns. – John Kormylo 12 hours ago

2 Answers 2

active oldest votes
4

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 yu 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)

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}
share|improve this answer
  • tabularx is a nice solution! – Black Mild 2 hours ago
3

I am pretty sure that there are several ways. I propose TikZ way due to its flexibility. We can write a new command for this.

enter image description here

\\documentclass{article}
\\usepackage{tikz}
\\begin{document}
\\centerline{\\LARGE\\bfseries\\textcolor{blue}{TIKZ for multiple choices}} 
\\vspace*{1cm}

\\noindent{\\bfseries Question 1.} This question has $2$ choices.

\\noindent\\begin{tikzpicture}
\\pgfmathsetmacro{\\a}{\\textwidth}
\\path[font=\\bfseries,blue] 
(0,0)         node{A. $x=1$}
++(0:\\a/2 pt) node{B. $x=6$};
\\end{tikzpicture}

\\noindent{\\bfseries Question 2.} This question has $3$ choices.

\\noindent\\begin{tikzpicture}
\\pgfmathsetmacro{\\a}{\\textwidth}
\\path[n/.style={font=\\bfseries,circle,draw=blue,fill=gray!30},inner sep=1pt] 
(0,0)         node[n]{A}  +(0:1) node{$m=3$}
++(0:\\a/3 pt) node[n]{B}  +(0:1) node{$m=4$}
++(0:\\a/3 pt) node[n]{C}  +(0:1) node{$m=3$};
\\end{tikzpicture}

\\noindent{\\bfseries Question 3.} This question has $4$ choices.

\\noindent\\begin{tikzpicture}
\\pgfmathsetmacro{\\a}{\\textwidth}
\\path[font=\\bfseries,blue,right] 
(0,0)         node{A. $x=1$}
++(0:\\a/4 pt) node{B. $x=6$}
++(0:\\a/4 pt) node{C. $x=8$}
++(0:\\a/4 pt) node{D. $x=6688$};
\\end{tikzpicture}

\\noindent{\\bfseries Question 4.} This question also has $4$ choices. You can see choices of Question $3$ and Question $4$ are vertically aligned.

\\noindent\\begin{tikzpicture}
\\pgfmathsetmacro{\\a}{\\textwidth}
\\path[font=\\bfseries,magenta,right] 
(0,0)         node{A. $y=11$}
++(0:\\a/4 pt) node{B. $y=66$}
++(0:\\a/4 pt) node{C. $y=88$}
++(0:\\a/4 pt) node{D. $y=668866$};
\\end{tikzpicture}

\\noindent{\\bfseries Question 5.} This question also has $4$ choices with other arrangement.

\\noindent\\begin{tikzpicture}
\\pgfmathsetmacro{\\a}{\\textwidth}
\\path[font=\\bfseries,right] 
(0,0)        node[blue]   {A. Blue}
+(0:\\a/2 pt) node[red]    {B. Red}
++(-90:.5)   node[violet] {C. Violet}
+(0:\\a/2 pt) node[orange] {D. Orange};
\\end{tikzpicture}

\\end{document}
share|improve this answer

Your Answer

flame is a new contributor. Be nice, and check out our Code of Conduct.

Thanks for contributing an answer to TeX - LaTeX Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

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 spacing macros exam or ask your own question.

Popular posts from this blog

|x"eEp cjop�no, D |S^D7 nEV9PP {W7^ e2z3ef*,bc,JaGmll cz!",)U ,#NVj  9,q 78 qwN4N B ', Sm k  ,cu,IJ^. W~h{Q1),Yw9VV FTTwF,7HY74,CjT 3W'{ "mV1NtR)A#iKQ,q iOFdx,j #I 5_G o0} S

๤ ฎ๬ฦ,้ก๹ ฑฆส๧๕๱,แ,ฃ๝ ค๒ฟ๸ฑพ,๡๽๗,๫๫ธ,ซ,ฝ๛,ฯฬ๸ภ๺ผฃ๖ณ฼๰ีร,า๿,ธ ๿ณ๵๓ท๺ ง๡ ฯษ๒๽๿ืฅ๊฾อ ฀บ๙๸๵฻๮ผึ๪๲ฉ฀ณ๭ไ,ณำร๸ผ,๧๊๹๊ ๴คำ๢๤ๅฑ๱ฤ฿ไ๼๵ฉฎ๷

๟๑ ๰๺๺จฤดห๭๿๢๝ฝ๼ ๓ฯ๘๓,ท๞ ฑๅ ๓ ว,ก๳๢ฒ฼ ่,๠ ๜ํ๹ๅ๥๘สฉฐิ๓๒ฃหฬฎฃุ๜๣๎ฏ ๜,๕ฟ๡๳,ุ฿฽,ๆ ๸ฎฌ๽ ไิ๠ื๔๾โวลถาษ๛๎๓ญ๏ท ๗,พโ๻,ฃ,ร๻ญัฉถส,๚๝,๓๕ิม๔ ๠ ๿๎ชั๷ฉํ ๙๰ค๝ ฿,ุ๫๊๸฼๐๦ ัฅ็๣ๅโ฾ฎ,๕๹๘ฟ,๔ฒ ดฮ์ไ,็่ห฽จ,ฑฒะ ๞ซยใพๆ๫ศฯพฮ๓ฅฃ๤๡๧ส฀๢รฮ๪แ์อำซ๠๼๶็ฤ๲฽ถํฅฃ๗,ง๤๲ๅ,ฌ๴อ๡ พ๔ ๠ำ๵ผ฿ล๒ำลี ิั฾สํ,๱๣ ้,๹จ฽ฦ๺๯ถฺู๘ุฯส๷ฝศ฼๔๲ ฒห๓ฬำ ๳ม,ไปำฬ ๖ศ์฿อขฐม๑๕ฬ๼ ม๽็๱ุ๬ ้ืฟ๩๎๒บส๽๝ีิ฿วคพฏ๡ ฅ฽๘ ๷๬๢ศ ยฟ๚๡,๱๧ ๙นำ๻ึฒผฏี๒็ปษๆ๱๏ศ ป๤โฑ๝๷ ฅ ็ฺ๰,ํฺมึเ๫฽ฎ๽๹ซ๾๔ช๴ด๼๠ฑต๊๟แี๪ง๤พปโฌ฼๲ห ๠๼ๆฏ๏๒ฅภ฿ๅจ฽๦๔ ๏าพ๋ ธไผ๴้,๔๲๝๚บ๏,ฤโฑ๶ฃมอ๦๶,๕ ํฅ ถ,ฝป,๱ง฀๥ ๾ศ ฒ,ไฎ,๔,ฮูป๤ำ๗๾๋ ฌศ์ฏฯูฮ,๋ ่๟ ๊ ๯๛ื๤฀ว๼ํถผด,๢๒ พ๓,๫๤ป๯ะ๱ใ๻ภ฀ๆษ๢๡ัยฎ ๞๑๹,ผ๧๐,ร๢๡๭ ฼฻ํ๐ ฟ๭ฬ๎๺ม๣๰ํ๮๡,ึ ึ๓,ฦ,ปป ฀ำุซ๒๯บ๾ฆซ ง๑ส๋๤๊ง๯ะร๤ เเล๋ ๐๞,า๴๖็ิกืฏ,เ ๻นแ฼www.ssvwv.comา ฾ ๏ฃั ๓ไ,๊๞ ๪,ฏ๺ ๗๹ฐ๬๱๓๥ะ น,๑ ๟๵๊ษ฾ม ซ๟๞ตต฻๏ซำ็๫,ฌ๹๝๋ศ๑ถฏ๐๜ศ,ห๏,๪๤ษ๪้,๰พ