# Changing indent after question exam class

A friend of me had to change her exam style, so everybody uses the same lay-out. As she works in TeX, and has no experience with Word, she needs some help.

Some problems are solved:

\documentclass[12pt,a4paper,addpoints]{exam}
\usepackage{inputenc}
\pointpoints{punt}{punten}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{geometry}
\geometry{a4paper}
\geometry{margin=2.5cm}

%%%%%% Toegevoegd door AT
\usepackage{lipsum}
\renewcommand{\baselinestretch}{1.6}
\renewcommand{\questionlabel}{\thequestion}
\renewcommand\partlabel{\thequestion.\arabic{partno}}

\renewcommand{\partshook}{%
\settowidth{\leftmargin}{}
}

\parindent=0pt %dit zorgt ervoor dat er nergens een insprong is van de alinea's

\begin{document}
\lipsum[12]
\begin{questions}
\question[6] Stel de formule op voor de afgeleide van de sinusfunctie. hlqksdhflkqsdhflqsdhf lqshlkqsd lkqsdflksjhfl  lkhlk
\question[10] Bereken de afgeleide van de functies met onderstaande voorschriften:
\begin{parts}
\part $f(x)=2\tan(4x)$
\part $\displaystyle{f(x)=\frac{3}{\cos^4(2x)}}$
\part $\displaystyle{f(x)=\frac{1+2\cos x}{\sin^3x}}$
\part $f(x)=4x^3\,\sin(5x)$
\end{parts}

\end{questions}
\end{document}


Resulting in no point after the question number, and every question and parts should start at the left margin. But looking closely the question number is not aligning correctly to the left margin.

So the questions are:

1. How to align correctly the question number so it is (vertical) in line with the text.

2. The text of the question (or part) hast start at 1cm from the left margin.

3. If a question (or part) is longer then one line, the next line should also start against the left margin.

The following seems to work:

\renewcommand{\questionlabel}{\makebox[1cm][l]{\thequestion}}
\renewcommand\partlabel{\makebox[1cm][l]{\thequestion.\arabic{partno}}}

\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelsep}{0pt}
\setlength{\labelwidth}{0pt}%
}

\renewcommand{\partshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelsep}{0pt}
\setlength{\labelwidth}{0cm}%
\def\makelabel##1{##1}%
}


Setting \leftmargin to 0pt arranges it so that when a question occupies more than one line, the lines after the first will begin at the left margin.

Setting \labelsep and \labelwidth to 0pt arranges it so that the label will stick out to the right of the 0pt space reserved for it, and no extra space will be left between the label and the beginning of the question.

Setting \questionlabel and \partlabel as above arranges it so that they'll take up 1cm of space, which will stick out to the right of the (zero) space reserved for the label.

The redefinition of \makelabel is needed for the parts environment to counteract the definition of \makelabel in exam.cls, which would otherwise make the label stick out to the left of the margin.

In the manual 4.10 Customizing the list parameters page 40, it states

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

For your question, you can add the following commands in the preamble

\renewcommand{\partshook}{%
\settowidth{\leftmargin}{-1pt}
}

\renewcommand{\questionshook}{%
\setlength{\leftmargin}{0pt}%
\setlength{\labelwidth}{-\labelsep}%
}


The result is

I hope I understood your question correctly.

• almost perfect. Except that if the parts are longer then one rule, there is an indent, and the real question (Stel de form...) should start at 1cm from the left margin (your red line); same for the parts. Nov 15, 2015 at 15:30
• @Arne, can you add this \renewcommand{\partshook}{% \settowidth{\leftmargin}{-1pt}% \setlength{\labelwidth}{-1cm}% %\labelwidth\leftmargin\advance\labelwidth-\labelsep% } and let me if this is what you are looking for so that I can update my answer. Nov 15, 2015 at 15:40