1

Today, I'm writing my question with the exam.cls. I would like to format the questions like that :

What expected

But, unfortunately, it is not possible to keep points in the left margin with the \qformat command. So, I proceed with \renewcommand{\questionlabel}{\textbf{Question \thequestion}} to keep \pointsinmargin usable as pointed in this topic : Formatting - How can I place points in the left margin while using qformat of exam class? .

But this leads to overlap the \thepoints and the label of question as you can say on this picture (zoom of the previous one btw). Also the points don't appear for question. Zoom to see the overlap

What I expect :

  • Points in the left margin with the format : /\thepoints
  • Label of the question : Question \thequestion with arabic number.
  • Label of the partno : \thepartno) with letter.
  • If it is possible, points for a part has to be indented with respect to the questions points.

Here is my MWE :

\documentclass[addpoints, 12pt, a4paper]{exam}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}

\usepackage[top=1cm, left=2cm, right=2cm, bottom=1cm]{geometry}

%% Structure Exam.cls
\renewcommand{\partlabel}{\thepartno)}
\renewcommand{\questionlabel}{\textbf{Question \thequestion}}

\pointname{}
\pointformat{/\thepoints}
\bonuspointformat{/+\thepoints}

\pointsinmargin

\begin{document}


        \begin{questions}
        \question Définissez ce qu'est la force de pesanteur :
        \begin{parts}
            \part[2] Première question
            \part[2] Première question
        \end{parts}\vspace{2cm}

        \question[1] Définissez ce qu'est la force de pesanteur :\vspace{2.5cm}
    \end{questions}


\end{document}

Thanks for your help !

2

Since the questions environment is just a list, we can play around with the list parameters \leftmargin and \labelwidth. We change them for the questions and parts using hooks provides by the exam class:

\newlength{\mywidth}
\settowidth{\mywidth}{Question 10}
\newlength{\mywidthii}
\settowidth{\mywidthii}{Question 1000}
\renewcommand{\questionshook}{%
\addtolength{\leftmargin}{\mywidth}%
\setlength{\labelwidth}{\mywidthii}%
}

\renewcommand{\partshook}{%
\setlength{\leftmargin}{-0.5\mywidth}%
}

MWE:

\documentclass[addpoints, 12pt, a4paper]{exam}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}

\usepackage[top=1cm, left=2cm, right=2cm, bottom=1cm]{geometry}

%% Structure Exam.cls
\renewcommand{\partlabel}{\thepartno)}
\renewcommand{\questionlabel}{\textbf{Question \thequestion}}
%\renewcommand{\questionlabel}{\thequestion...}

\pointname{}
\pointformat{/\thepoints}
\bonuspointformat{/+\thepoints}

\newlength{\mywidth}
\settowidth{\mywidth}{Question 10}
\newlength{\mywidthii}
\settowidth{\mywidthii}{Question 1000}
\renewcommand{\questionshook}{%
\addtolength{\leftmargin}{\mywidth}%
\setlength{\labelwidth}{\mywidthii}%
}

\renewcommand{\partshook}{%
\setlength{\leftmargin}{-0.5\mywidth}%
}

\pointsinleftmargin

\begin{document}

        \begin{questions}

        \question Définissez ce qu'est la force de pesanteur:
        \begin{parts}
            \part[2] Première question Première question Première question Première question Première question Première question Première question 
            \part[2] Première question
        \end{parts}\vspace{2cm}

        \question[1] Définissez ce qu'est la force de pesanteur :

        \question[1]
        \question[1]
        \question[1]
        \question[1]
        \question[1]
        \question[1]
        \question[1]
        \question[1]
        \question[1]
    \end{questions}


\end{document}

enter image description here

|improve this answer|||||
  • Ow, very nice ! When i tried to change commands, the / for the points was always present although no points were assigned to the questions. I guess there is still many things i do not understand about this class. Thanks to highlight that the questions environment is a list. I did not catch it. Thanks for your help, it's what i wanted to do ! There is still one question about exam i'll write on another topic. This one is solved :) ! – Piroooh Oct 30 '18 at 19:27
  • After use, it seems like the text do not wrap around the label. Some questions look like a block. Do you think it is possible to set the options wide of the enumitem package to those list ? I tried but i was unable to solve this problem. Maybe it is not possible to keep question and text on the same line and to wrap the text around the label. – Piroooh Oct 30 '18 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.