# Indentation in enumerate for exam class

I am using the exam document class. In my solution, I am using an enumerate environment. However, new lines in each item are not aligned with the first line in that item (see item 1 below). How can I use the enumitem package to deal with this alignment? I want to keep the item labels (1., 2., etc.) just where they are; I only want to align any additional lines in each item with the first line in that item.

\documentclass[answers]{exam}
\usepackage{amsmath, amssymb, amsfonts, amstext}
\usepackage{enumitem}
\usepackage{xpatch} % for horizontal spacing between choices in multiple-choice problems

\xpatchcmd{\oneparchoices}{\penalty -50\hskip 1em plus 1em\relax}{\qquad}{}{} % for multiple-choice problems

%%%%%%%%%%%%%%%%%%%%%%%
%http://tex.stackexchange.com/questions/278345/changing-indent-after-question-exam-class
%
% Make question numbers align to the left margin
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}

% Change margins for choices and parts
\renewcommand{\partshook}{%
\setlength{\leftmargin}{1.2cm}%
%\setlength{\labelwidth}{0pt}%
\renewcommand\makelabel[1]{\rlap{##1}\hss}%
}
%%%%%%%%%%%%%%%%%%%%%%%

\parindent=0pt

\begin{document}
\begin{questions}
\question
Problem here.
\begin{solution}
Some text.
\begin{enumerate}
\item \textsc{First Step}

Here is stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff.

\item \textsc{Second Step}

Here is a stuff.
\end{enumerate}
\end{solution}
\end{questions}
\end{document}


• Can you elaborate where is the indentation issue – subham soni Dec 10 '17 at 5:37
• I want the item labels (1., 2., etc.) to stay in their default positions. In each item, I want all the text aligned on the left. So in item 1 in the picture above, I want "Here" and the rest of that paragraph lined up with "FIRST" in the line above the paragraph. – Mark Twain Dec 10 '17 at 13:57

You can use the calc package and

\begin{enumerate}[leftmargin=\leftmargin+\labelsep, itemindent=-\labelsep]


This indents the whole item to the right by the desired amount (\labelsep) and then shifts the first line to the left by the same amount to obtain the desired effect (i.e., label in the default place, rest of the lines beginning where the first line's text begins).

\documentclass[answers]{exam}
\usepackage{amsmath, amssymb, amsfonts, amstext}
\usepackage{enumitem}
\usepackage{xpatch} % for horizontal spacing between choices in multiple-choice problems
\usepackage{calc}

\xpatchcmd{\oneparchoices}{\penalty -50\hskip 1em plus 1em\relax}{\qquad}{}{} % for multiple-choice problems

%%%%%%%%%%%%%%%%%%%%%%%
%http://tex.stackexchange.com/questions/278345/changing-indent-after-question-exam-class
%
% Make question numbers align to the left margin
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}

% Change margins for choices and parts
\renewcommand{\partshook}{%
\setlength{\leftmargin}{1.2cm}%
%\setlength{\labelwidth}{0pt}%
\renewcommand\makelabel[1]{\rlap{##1}\hss}%
}
%%%%%%%%%%%%%%%%%%%%%%%

\parindent=0pt

\begin{document}
\begin{questions}
\question
Problem here.
\begin{solution}
Some text.
\begin{enumerate}[leftmargin=\leftmargin+\labelsep, itemindent=-\labelsep]
\item \textsc{First Step}

Here is stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff. Here is a stuff.

\item \textsc{Second Step}

Here is a stuff.
\end{enumerate}

\end{solution}
\end{questions}
\end{document}


• That fixes the indentation issue, but it moves the item labels leftward. I was hoping to keep the item labels fixed (in the default positions). – Mark Twain Dec 10 '17 at 13:51
• @MarkTwain I added a shift to \leftmargin to achieve the desired effect. It is not extremely clean but should do the job. – wimi Dec 10 '17 at 15:23
• Excellent! I'm sure this was an obvious solutions, so I apologize. I always get confused when messing with the different options in the enumitem package. Thank you! – Mark Twain Dec 10 '17 at 18:42

The problem is caused by your \questionshook as it redefines labelwidth. You can fix this by adding

\setlist[enumerate]{labelwidth=*}


With this in place you get what (I think) you want:

Here is the full code:

\documentclass[answers]{exam}
\usepackage{amsmath, amssymb, amsfonts, amstext}
\usepackage{enumitem}
\usepackage{xpatch} % for horizontal spacing between choices in multiple-choice problems

\xpatchcmd{\oneparchoices}{\penalty -50\hskip 1em plus 1em\relax}{\qquad}{}{} % for multiple-choice problems

\parindent=0pt

\setlist[enumerate]{labelwidth=*}
\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}
% Change margins for choices and parts
\renewcommand{\partshook}{%
\setlength{\leftmargin}{1.2cm}%
%\setlength{\labelwidth}{0pt}%
\renewcommand\makelabel[1]{\rlap{##1}\hss}%
}

\begin{document}
\begin{questions}
\question
Problem here.
\begin{solution}
Some text.
\begin{enumerate}[labelwidth=*]
\item \textsc{First Step}

Here is stuff. Here is a stuff. Here is a stuff. Here is a stuff.
Here is a stuff. Here is a stuff. Here is a stuff. Here is a
stuff. Here is a stuff.

\item \textsc{Second Step}

Here is a stuff.
\end{enumerate}
\end{solution}
\end{questions}
\end{document}

• That fixes the indentation issue, but it moves the item labels leftward. I was hoping to keep the item labels fixed (in the default positions). – Mark Twain Dec 10 '17 at 13:51
• @MarkTwain You didn't explain clearly in your question what the indentation problem was and I thought that the item labels was the issue... To be honest, I don't see the difference between what I did and the answer that you accepted. – user30471 Dec 10 '17 at 20:37