6

I'd like to modify the qformat so that the points of the questions appear in line with and at the end, but not in the right margin.

Like in this word example.

enter image description here

I've tried modifying qformat, but it looks like it's made to always start the question on a new line, like in this MWE:

\documentclass[a4paper]{exam}

\qformat{\thequestion. \hfill (\thepoints)}

\begin{document}
\begin{questions}
\question i will give you no points
\begin{parts}
    \part[3] This is a part 
    \part[3] This is another part 
    \part[3] This is A part 
\end{parts}

\question[5] This question will give you some points

\noqformat
\question[1] Are you happy this is over?

\end{questions}

\end{document}
| improve this question | | | | |
3

You can do this using the \titledquestion command (section 4.5.1, page 33). I included a top-aligned \parbox to limit the width of the question text, which offsets the point value. To me, that makes the point value easier for you and your students to see. You can adjust the width of the \parbox as needed.

I also created a second \qformat option that puts the points one the same line as the end of the question. This more closely resembles your example but I do not think it looks as good as the above option. In addition, my macro can sometimes lead to the point value being placed on the left side of the page if the question takes a full line. Unfortunately, I do not know how to correct this.

The \renewcommand macro is necessary only if you are using a combination of \qformat and \noqformat questions because the question numbers did not align properly without it.

\documentclass[a4paper]{exam}

\renewcommand{\questionshook}{%
  \setlength{\leftmargin}{0pt}%
  \setlength{\labelwidth}{\labelsep}%
}

% Places points on first line of question. You can adjust text width to suit your needs.
\qformat{\thequestion. \parbox[t]{0.8\textwidth}{\thequestiontitle}\hfill(\thepoints)}

% Use this if you want the points to occur on the last line of the question. 
% Caveat: If your question occupies a full line, the points will appear on the left side
% of the new line. Plus, I don't think it looks as good.
%\qformat{\thequestion. \parbox[t]{\textwidth}{\thequestiontitle\hfill(\thepoints)}\hfill}

\begin{document}
\begin{questions}
\titledquestion{i will give you no points}[0]
\begin{parts}
    \part[3] This is a part 
    \part[3] This is another part 
    \part[3] This is A part 
\end{parts}

\titledquestion{This question will give you some points}[5]

\titledquestion{This question works fine for the second \qformat. text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text}[5]

\titledquestion{This question puts the points at the left side fo the page. text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text }[5]

\noqformat
\question[1] Are you happy this is over?

\end{questions}

\end{document}

Here's the results of the first \qformat.

enter image description here

Here's the results of the second \qformat that shows the problem if the question occupies ends with a full line. If you prefer this format, then careful rewording of a problematic question to shorten or lengthen it would put the points where you need.

enter image description here

| improve this answer | | | | |
  • Can you try using the normal \question with this code, because this works with \titledquestion{} but when I try to use normal \questions in the same document something weird happens. – piptin Sep 16 '14 at 19:39
  • @piptin I tried for a long time to figure out how to make this work with \question but was not successful. I do not know Tex well enough to understand the complete inner workings of the exam class. However, what you wanted works very well with \titledquestion. You'd have to use \titledquestion question through or use \noqformat before the places you use \question, as I did for Question 4 in the example output. Sorry, but I do not know of another solution. – Michael S Taylor Sep 16 '14 at 20:08

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.