2

I am writing exercises with the exam packages and I notice the question title, the text and the parts have different indentations. How to make everything ragged right?

\documentclass[french,a4paper,addpoints,11pt]{exam}
\usepackage[a4paper, total={165mm,250mm}]{geometry}
\usepackage{lipsum}

\qformat{\textbf{Exercise \thequestion}\hfill}

\begin{document}
\begin{questions}
\question
\lipsum[1]
\begin{parts}
    \part \lipsum[2]
    \answerline[42]

    \part \lipsum[3]
    \begin{checkboxes}
        \choice Foo
        \choice Bar
        \CorrectChoice Baz
    \end{checkboxes}

\end{parts}
\end{questions}
\end{document}

How to remove at least the spacings between the exercise title and the text?

enter image description here

1 Answer 1

4

You could use the hooks provided by the class, see its documentation, Section 4.10.

\documentclass[french,a4paper,addpoints,11pt]{exam}
\usepackage[a4paper, total={165mm,250mm}]{geometry}
\usepackage{lipsum}

\qformat{\textbf{Exercise \thequestion}\hfill}

% code added vvv
\renewcommand{\questionshook}{%
    \setlength{\leftmargin}{0pt}%
    \setlength{\labelwidth}{-\labelsep}%
    }
\renewcommand{\partshook}{%
    \renewcommand\makelabel[1]{\rlap{##1}\hss}% this line is from https://tex.stackexchange.com/a/285767/101651
    \setlength{\leftmargin}{\itemindent}%
    \addtolength{\leftmargin}{\labelwidth}%
    \addtolength{\leftmargin}{\labelsep}%
    }
\renewcommand{\checkboxeshook}{%
    \setlength{\leftmargin}{0pt}%
    \setlength{\labelwidth}{-\labelsep}%
    }
% code added ^^^

\begin{document}
\begin{questions}
\question
\lipsum[1]
\begin{parts}
    \part \lipsum[2]
    \answerline[42]

    \part \lipsum[3]
    \begin{checkboxes}
        \choice Foo
        \choice Bar
        \CorrectChoice Baz
    \end{checkboxes}
\end{parts}
\end{questions}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .