考试:将数字转换为字符串并将结果大写

考试:将数字转换为字符串并将结果大写

此处,\bfseries\MakeUppercase{\numberstringnum\numpoints}结果为一5代替十五

此外,大写字母不适用于其余元素(例如\MakeUppercase{\numberstringnum\numquestions}应该给予代替

\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}

在此处输入图片描述

答案1

以下补丁使用etoolbox确保在使用字符串打印数字时不会出现任何错误。此外,它还\NAME为三个\num-macros 定义了 -companions,允许您在其他地方继续使用\num-macros:

在此处输入图片描述

\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}

使用\MakeUppercase已明确涵盖在fmtcount 文档\NUMBERstring,因此/的定义\NUMBERstringnum\numberstring/相对应\numberstringnum

相关内容