# How do I use \titledquestion in the exam class with or without points?

When using the exam class, it is possible to have commands like \question[5] or simply \question (i.e. with no points). The former includes the points within parentheses by default, and the latter omits the points and the surrounding parentheses.

To use titled questions within the exam, where the points are surrounded by parentheses, I have used the following command:

\qformat{\bf \thequestiontitle ~(\thepoints) \hfill}


Now, when I use the \titledquestion{my title}[5] and \titledquestion{my title} commands, they do not behave in the same way that the \question[5] and \question commands do. The difference is that the titled versions always end up including parentheses, whether or not points have been specified.

What I want to know is: what is a proper way to modify the argument of \qformat so that the parentheses are only present when a point value has been specified? I was unable to find this in the manual for exam.cls (I assumed it would be somewhere in the section dealing with titled questions).

-

You can use \if@placepoints to conditionally include the parentheses and the value:

\documentclass{exam}

\makeatletter
\qformat{\bfseries\thequestiontitle\if@placepoints~(\thepoints)\else\fi\hfill}
\makeatother

\begin{document}

\begin{questions}
\titledquestion{my title}[5]
\titledquestion{my title}
\end{questions}

\end{document}


-
Perfect! Thanks very much -- I wonder why this isn't included in the documentation somewhere. –  Mark Apr 30 '13 at 1:33
It's weird; the @ suggests the author doesn't want you to use this conditional. Yet it is not any less useful than \ifprintanswers, which is described. –  Ryan Reich Apr 30 '13 at 5:44