## LaTeX forum ⇒ Text Formatting ⇒ Choices Alignment in an Exam Sheet

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
ollydbg
Posts: 2
Joined: Thu Jan 31, 2013 12:06 pm

### Choices Alignment in an Exam Sheet

Hi, I found some LaTeX code to automatically put the multiply choices in the questions, here is the code, I create a minimal sample test.

See the screen shot:
2013-01-31 21 17 31.png (19.39 KiB) Viewed 8418 times

The questions are:

1. Why does the third question's choice A is indent? But all the other choices were aligned correctly, any way to fix this?
2. What does AM BM CM DM means?

Thanks.

Tags:

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
Perhaps it's easier to use a special class like exam to format your exam sheet.
\documentclass[11pt]{exam}\usepackage[T1]{fontenc}\usepackage{multicol} \renewcommand*{\choicelabel}{(\thechoice)} \begin{document}   \begin{questions}     \question First Question      \begin{oneparchoices}       \choice 1       \choice 2       \choice 3       \choice 4     \end{oneparchoices}      \question Another Question      \begin{multicols}{2}       \begin{choices}         \choice hello world, hello wo         \choice hello world, h         \choice hello world, hello wd         \choice hello world, hello world       \end{choices}     \end{multicols}      \question Another Question      \begin{choices}       \choice The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.       \choice The quick brown fox jumps over the lazy dog.       \choice The quick brown fox jumps over the lazy dog.       \choice The quick brown fox jumps over the lazy dog.     \end{choices}   \end{questions} \end{document}

For details regarding its capabilities and for further customization please refer to the class guide.

Alternatives:

Best regards and welcome to the board
Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

cgnieder
Site Moderator
Posts: 1990
Joined: Sat Apr 16, 2011 7:27 pm
Hi ollydbg,

Welcome to the LaTeX community.

Thorsten already mentioned the exsheets package. Here's an example of what you could do:

\documentclass{article}\usepackage{exsheets}\SetupExSheets{   question/type=exam ,   headings=plain} % The following declares an empty question heading. If you don't% want that leave the code alone and load one of the other heading% styles provided by exsheets in the options above.\DeclareInstance{exsheets-heading}{plain}{default}   {     runin = true ,     number-post-code = \space ,     attach = { main[l,vc]points[l,vc](\linewidth+\marginparsep,0pt) }} % The following declares an environment choices' similar to list but% instead of \item you use \choice\NewTasks[   counter-format = (tsk[A]) ,   label-width = 2em]{choices}[\choice] \begin{document} \begin{question}  Question:  % The number in parentheses declares the number of columns that  % is used by the choices' environment:  \begin{choices}(4)   \choice 1   \choice 2   \choice 3   \choice 4  \end{choices}\end{question} \begin{question}  Another Question:  \begin{choices}(2)    \choice hello world, hello wo    \choice hello world, h    \choice hello world, hello wd    \choice hello world, hello world  \end{choices}\end{question} \begin{question}  Third Question:  \begin{choices}   \choice hello world, hello hello world,hello world,hello world, hello world,     hello world, hello world, hello world, hello world, hello world, hello world,     hello world,   \choice hello world, h   \choice hello world, hello wd   \choice hello world, hello world  \end{choices}\end{question} \end{document}

choices.png (24.69 KiB) Viewed 8401 times

Regards
Last edited by cgnieder on Sun Sep 15, 2013 2:12 pm, edited 1 time in total.
Reason: updated according to syntax changes in exsheets
site moderator & package author

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm
cgnieder wrote:[…] the exsheets package. Here's an example […]

I definitely have to take a closer at that package.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

cgnieder
Site Moderator
Posts: 1990
Joined: Sat Apr 16, 2011 7:27 pm
To answer the original question: what you're seeing is the parindent. Every line except the last three is indented by it. Add \setlength\parindent{0pt} to your preamble to see that I'm right.

You might not have expected that but the macros \onech, \twoch and \fourch issue a \par at the beginning by having an empty line in them. I guess that is deliberate but I don't think it's good style. Let's have a look:

\newcommand{\onech}[4]{          (A)~#1 \\ (B)~#2 \\ (C)~#3 \\ (D)~#4}

The line
\newcommand{\onech}[4]{

is ended by an end-of-line character which normally is treated like a space. But since an empty line follows they are together treated as if a \par had been inserted. If this is deliberate I'd favor something like this:

\newcommand{\onech}[4]{%   \par     (A)~#1 \\     (B)~#2 \\     (C)~#3 \\     (D)~#4   \par}

that is issue the par explicitly. It's probably also a good idea to end the command with a \par, just in case. (writing everything in different lines is just my personal preference, there's no need for it).

Regards
site moderator & package author

ollydbg
Posts: 2
Joined: Thu Jan 31, 2013 12:06 pm
Hi, thanks for the reply and help.
I see the exsheets package, but as the code comment said:
\begin{question}  Question:  % The number in parentheses declares the number of columns that  % is used by the choices' environment:  \begin{choices}(4)   \choice 1   \choice 2   \choice 3   \choice 4  \end{choices}\end{question}`

I need to specify the column number of the choices.
What I want is the let the Latex engine to automatically put the choices in a compact way, whether it need one column, two or four columns. I think it is much better than manually specify the column numbers, right? I don't see any packages have such feature.

@cgnieder, thanks for the explanation of the "indent" and "an empty line" issue, I understand now.

cgnieder
Site Moderator
Posts: 1990
Joined: Sat Apr 16, 2011 7:27 pm
ollydbg wrote:What I want is the let the Latex engine to automatically put the choices in a compact way, whether it need one column, two or four columns. I think it is much better than manually specify the column numbers, right? I don't see any packages have such feature.

At least the »exsheets package cannot do that automatically. You can still stick to your original code. Now that you know the cause for the unwanted output you can take measures against it.

Regards
site moderator & package author