Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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}

enter image description here

share|improve this answer
    
Perfect! Thanks very much -- I wonder why this isn't included in the documentation somewhere. –  Mark Apr 30 '13 at 1:33
1  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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