3

I'm using the exam document class, and have played around with the options for points placement. Essentially, I want something that works like \pointsdroppedatright. The only problem is that it creates a margin. I was hoping to avoid the margin altogether, such that the text appears much in the same way using \hfill would push it rightwards. I believe this can be done with qformat, but I don't know how to do it for parts, subparts, etc.

Here's a minimum working example of what I have now:

\documentclass{exam}

\pointsdroppedatright \marksnotpoints

\begin{document} \begin{questions} \question Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \begin{parts} \part[4] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \droppoints \end{parts} \end{questions} \end{document}

What I have at the moment

Here's what I want:

What I want

1 Answers1

3

A simple solution:

\documentclass{exam}
\usepackage{xpatch}

\pointsdroppedatright \marksnotpoints \makeatletter \def\mydroppoints{% \leavevmode\unskip\nobreak\hfill (@points~marks) \par } % show marks automatically % \xpretocmd{\endparts}{\mydroppoints}{}{} \makeatother

\begin{document} \begin{questions} \question Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \begin{parts} \part[4] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \mydroppoints \end{parts} \end{questions} \end{document}

enter image description here

EDIT

According to @David Purton, there is a better solution which allow line break if there is not enough space.

\def\mydroppoints{%
  {\unskip\nobreak\hfil\penalty50
   \hskip2em\hbox{}\nobreak\hfil(\@points~marks)
      \parfillskip=0pt \finalhyphendemerits=0 \par}}

Response to the comment

When point is 1, show 1 mark rather than 1 marks.

\def\mydroppoints{%
  {\unskip\nobreak\hfil\penalty50
    \hskip2em\hbox{}\nobreak\hfil
    (\@points~mark\expandafter\ifx\@points1\else s\fi)
    \parfillskip=0pt \finalhyphendemerits=0 \par}
}
ZhiyuanLck
  • 4,516
  • 1
    Small improvement suggestion: Use \def\mydroppoints{{\unskip\nobreak\hfil\penalty50\hskip2em\hbox{}\nobreak\hfil(\@points~marks)\parfillskip=0pt\finalhyphendemerits=0\par}} which allows the marks to go on the next line if there isn't room for it. See https://tex.stackexchange.com/a/459615/87678 – David Purton Jun 20 '20 at 11:24
  • @DavidPurton I am wondering what is the effect of \finalhyphendemerits=0 . – ZhiyuanLck Jun 21 '20 at 08:10
  • I don't know :). The code is taken from The TeX Book and the only explanation given is the one in the linked question. Many things in The TeX Book are beyond me... – David Purton Jun 21 '20 at 09:18
  • @ZhiyuanLck I just noticed that this seems to say (1 marks) rather than (1 mark). Can that be fixed? – zenofpython Jun 29 '20 at 01:36
  • 1
    @zenofpython sure, fixed. – ZhiyuanLck Jun 29 '20 at 02:21