0

Using exam class I can assign points to questions, parts and subparts with

\documentclass{exam}
\begin{document}
    \begin{questions}
        \question[20]
        \begin{parts}
            \part[8]
            \begin{subparts}
                \subpart[3]
            \end{subparts}
        \end{parts}
    \end{questions}
\end{document}

These points appear in the margin which is nice.

Now, I need to have more points in the margin that are not attached to a \question, \part or \subpart and that don't come with their own question/part/subpart number. So the only thing that I want to achieve is to have extra points in the margin without any other change in the text.

How can I add these points to the margin?

2
  • Are you taking about bonus points? Those too are attached to questions etc. Otherwise, exam class will pretty much ignore them. May 2, 2022 at 21:03
  • I could use something like bonus points, but I don't want to have any number in the text. Say if I have parts, 1.1, 1.2, 1.3,... that's fine, but for the extra points I only want points in the margin not any part numbers in the text. May 2, 2022 at 22:00

1 Answer 1

2

\setpoint{<q, p or s>}{<text>} will put a short text in the margin emulating the question points.

UPDATE after follow up question.

Use \setpoint{q}{<text>} inside \question to match the indentation of the question; idem with

\setpoint{p}{<text>} inside parts and

\setpoint{s}{<text>} inside subparts.

c

\documentclass{exam}
    
\usepackage{ifthen}
\newlength{\mypoints}
\newlength{\marginindent}   

\newcommand{\pointsstyle}{\scriptsize}% use small font size
\pointsinmargin          % points in the margin    
\pointformat{\pointsstyle \thepoints} 

\newcommand{\setpoints}[2]{%  added <<<<<<<<<<<<<< \setpoint{q p s}{<text>}
    \ifthenelse{\equal{#1}{q}}{\setlength{\marginindent}{6ex}}{}
    \ifthenelse{\equal{#1}{p}}{\setlength{\marginindent}{11ex}}{}
    \ifthenelse{\equal{#1}{s}}{\setlength{\marginindent}{15ex}}{}
    \parindent0pt\par%
    \settowidth{\mypoints}{\pointsstyle #2}
        \hspace*{\dimexpr-\mypoints-\the\marginindent} %changed <<<<<<<<
        {\pointsstyle #2}%
    }
    
  \begin{document}
    \begin{questions}
        \question[20]
        xxx         
        \setpoints{q}{100 points} % <<<<<<<<<<<<<<<<<<<<<<<<<<< 
                            
        \begin{parts}
            \part[8]
            www                             
            \setpoints{p}{34 points} %
                
            \begin{subparts}
                \subpart[3]
                qqq
                
            \setpoints{s}{42 bonus pts.} %
                
            \end{subparts}
        \end{parts}
    \end{questions} 

\end{document}
3
  • This works fine OUTSIDE of the questions environment. However I need this feature inside the questions environment. If I use it inside questions, it messes up the formatting of the text (maxes everything small). May 4, 2022 at 20:57
  • @user1583209 Please see the updated answer. May 4, 2022 at 22:31
  • Excellent! It works. In case anybody is wondering what this is good for, I have an official exam where the total number of points per question (or part or subpart) is given. However the number of points is still large and I want to split it among several subtasks that are included in each question (but which are not numbered). May 5, 2022 at 13:10

You must log in to answer this question.

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