[Tex/LaTex] Changing indent after question exam class

examindentation

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}{}
    \labelwidth\leftmargin\advance\labelwidth-\labelsep%
}

\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.
enter image description here

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.

Best Answer

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.

enter image description here

Related Question