Set indentation of choice in exam documentclass

I want to create an multiple choices question with this indenting format

1. ########
A. ###
B. ###
C. ###
2. ########
########
A. ###
B. ###
C. ###


The choices have same indentation as the question text.

But, using the default exam documentclass, I get this format

1. ########
A. ###
B. ###
C. ###
2. ########
########
A. ###
B. ###
C. ###


Hence, I try to set the \leftmargin to 0pt inside the choices environment to get what I want.

\documentclass{exam}
\begin{document}
\begin{questions}
\question
How old are you?
\begin{choices}
\setlength{\leftmargin}{0pt}
\choice 14
\choice 17
\choice 19
\choice 20
\choice 23
\end{choices}
\end{questions}
\end{document}


But, It get nowhere.

So, What is the right way to set indentation of choice in exam documentclass?

Following Section 4.10 of the exam documentation, I believe you are looking for choiceshook, which can be used as follows, for example

\renewcommand{\questionshook}{%
\setlength{\leftmargin}{30pt}%
}
\renewcommand{\choiceshook}{%
\setlength{\leftmargin}{50pt}%
}


Here is a complete MWE- I loaded the geometry package with showframe=true just for demonstration.

% arara: pdflatex
% !arara: indent: {overwrite: true}
\documentclass{exam}
\usepackage[showframe=true]{geometry}

\renewcommand{\questionshook}{%
\setlength{\leftmargin}{30pt}%
}
\renewcommand{\choiceshook}{%
\setlength{\leftmargin}{50pt}%
}
\begin{document}
\begin{questions}
\question
How old are you?
\begin{choices}
\choice 14
\choice 17
\choice 19
\choice 20
\choice 23
\end{choices}
\end{questions}
\end{document}


For reference, here's a quote from the exam documentation

The exam document class defines these as follows:

\newcommand{\questionshook}{}
\newcommand{\partshook}{}
\newcommand{\subpartshook}{}
\newcommand{\subsubpartshook}{}
\newcommand{\choiceshook}{}
\newcommand{\checkboxeshook}{}


Thus, the default is that these commands have no effect, but you can change any of them with a \renewcommand command.

• changing \setlength{\leftmargin}{50pt}% to \settowidth{\leftmargin}{W.\hskip\labelsep\hskip 0em} gives the desired result of indenting that I want. Though I'm pretty confused with the second argument of the \settowidth above. Apr 13, 2013 at 14:52
• I also wasn't able to get the solution here to work, but did get the one in your comment @MasAdit to work. I have no clue why though
– J M
Mar 26, 2017 at 21:33

Try this and see

\uplevel{
\begin{choices}
\choice
\choice
\choice
\choice
\end{choices}}

• Welcome to TeX.SX! To add syntax highlighting in a post, you can select the code and click the button marked {} above the text field. Aug 8, 2014 at 6:40
– user31729
Aug 8, 2014 at 7:01
• @ChristianHupfer I'm not sure a screenshot is always required, but I agree that some explanation should be given. Aug 8, 2014 at 7:34
• @JosephWright: If I would be the OP (although the question is 'old') I would prefer a screen shot as a quick check if this provided solution fulfills the request. That's why I asked about the screen shot.
– user31729
Aug 8, 2014 at 15:08
• @ChristianHupfer 'Prefer' certainly: I was trying to say that one is not 'required' for an answer to be valid Aug 8, 2014 at 15:10
change \settowidth{\leftmargin}{W.\hskip\labelsep\hskip 2.5em}% to \settowidth{\leftmargin}{W.\hskip\labelsep\hskip 0em}%