2

Here, \bfseries\MakeUppercase{\numberstringnum\numpoints} results in one5 instead of FIFTEEN.

Additionally, the capitalization doesn't work for the rest of the elements (e.g. \MakeUppercase{\numberstringnum\numquestions} should give TWO instead of two.).

\documentclass[addpoints]{exam}
\usepackage{fmtcount}

\begin{document}
    This exam contains {\bfseries\MakeUppercase{\numberstringnum\numquestions}} questions, {\bfseries\MakeUppercase{\numberstringnum\numpages}} pages (including the cover) for the total of {\bfseries\MakeUppercase{\numberstringnum\numpoints}} marks.
    \begin{questions}
        \question[10] some question
        \question[5] another question
    \end{questions}
\end{document}

enter image description here

1 Answer 1

2

The following patch using etoolbox ensures that you don't get any errors while still printing the number using a string. Additionally, it defines \NAME-companions for the three \num-macros, allowing you to still use the \num-macros elsewhere:

enter image description here

\documentclass[addpoints]{exam}

\usepackage{fmtcount,etoolbox}

\makeatletter
\let\NAMEquestions\numquestions
\patchcmd{\NAMEquestions}{\exam@numquestions}{{\NUMBERstringnum\exam@numquestions}}{}{}
\let\NAMEpages\numpages
\patchcmd{\NAMEpages}{\exam@lastpage}{{\NUMBERstringnum\exam@lastpage}}{}{}
\let\NAMEpoints\numpoints
\patchcmd{\NAMEpoints}{\exam@numpoints}{{\NUMBERstringnum\exam@numpoints}}{}{}
\makeatother

\begin{document}

This exam contains \textbf{\NAMEquestions} questions, 
  \textbf{\NAMEpages} pages (including the cover) 
  for a total of \textbf{\NAMEpoints} marks.

\begin{questions}
  \question[10] some question
  \question[5] another question
\end{questions}

\end{document}

The use of \MakeUppercase is explicitly covered in the fmtcount documentation, hence the definition of a \NUMBERstring/\NUMBERstringnum counterpart to \numberstring/\numberstringnum.

2
  • What if I would like to not permanently change these macros?, i.e. I would like to later use \numquestions to get 2 instead of TWO? So, can I create new macros and keep the original intact?
    – Diaa
    Commented Aug 31, 2018 at 20:53
  • 1
    @Diaa: I've updated it to use \NAME-macros, leaving the \num-macros untouched.
    – Werner
    Commented Aug 31, 2018 at 21:15

You must log in to answer this question.

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