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.

The memoir class has a number of macros for converting a number to words. For example

 \numtotoname{113}

will print one hundred and thirteen.

Is there an equivalent macro for all caps? Alternatively can one define one?

I am trying to define:

   \def\thechapter{\textsc{\numtoname{\@arabic\c@chapter}}}

This works,

   \textsc{\numtoname{\@arabic\c@chapter}},

but not this one:

   \def\chaptername{chapter}
   \def\thechapter{\textsc{\numtoname{\@arabic\c@chapter}}}

enter image description here

Note:

I am trying to convert chapter numbers to words. My guess is the answer probably need a number of \expandafters, which currently they evade me.

share|improve this question
    
Do you mean "One Hundred and Thirteen" or "ONE HUNDRED AND THIRTEEN"? I guess the former, as the latter could be done either by \MakeUppercase{} or (somewhat?) by \textsc{}. –  Brent.Longborough Apr 25 '12 at 19:11
    
@Brent.Longborough I mean ONE HUNDRED AND THIRTEEN try it with \MakeUppercase{} :) Never thought textsc. This works will you please post the comment as an answer so i can accept it? –  Yiannis Lazarides Apr 25 '12 at 19:12
    
@Brent.Longborough Sorry did not work in the real application. –  Yiannis Lazarides Apr 25 '12 at 19:25
1  
@YiannisLazarides Unfortunately \numtoname uses \n@me@number which starts with \numdigits which is not expandable. So it won't work with any number of \expandafter tokens. One would have to define an "uppercase version" of \n@me@number with different versions of the \nNamezzzz macros. If you don't have a big number of chapters, the easiest way is to go with \ifcase –  egreg Apr 25 '12 at 19:47
1  
There is an interesting insight about expandable macro programming hidden in here. Sometimes it seems moot trying to make an expandable macro by all means, even in contexts where no significant advantage in efficiency is to be gained. But here, with an expandable definition of \n@me@number it would have been super easy to define an all-upper-case version while the way things are it's almost impossible without a complete rewrite. –  Stephan Lehmke Apr 25 '12 at 20:03

3 Answers 3

up vote 8 down vote accepted

The easiest solution is to use fmtcount:

\documentclass{memoir}
\let\ordinal\relax % to avoid a spurious warning
\usepackage{fmtcount}
\renewcommand{\thechapter}{\NUMBERstring{chapter}}


\begin{document}
\mainmatter
\chapter{A}
\end{document}
share|improve this answer

You can use the fmtcount package's \NUMBERstring:

enter image description here

\documentclass{memoir}% http://ctan.org/pkg/memoir
\usepackage{fmtcount}% http://ctan.org/pkg/fmtcount
\renewcommand{\thechapter}{\NUMBERstring{chapter}}
\begin{document}
\setcounter{chapter}{112}
\chapter{A chapter}
\end{document}​
share|improve this answer
    
Thanks. I accepted egreg's answer as he posted 44 seconds earlier than you:) –  Yiannis Lazarides Apr 25 '12 at 20:01
    
@YiannisLazarides: That crazy! ...but fair. :) –  Werner Apr 25 '12 at 20:06
    
if you hover over the answered ... it gives the time:) –  Yiannis Lazarides Apr 25 '12 at 20:10

How about this; perhaps a little more like typography and less like shouting (:-):

{\scshape \NumToName{#1}}
share|improve this answer
    
I would respectfully disagree with you on this one. Many a good book have the CHAPTER TWO, rather than CHAPTER 2, numbers don't always look on headings. It will also not look so good in Camel casing. I will post an image in the main post. –  Yiannis Lazarides Apr 25 '12 at 20:52
    
@YiannisLazarides: I guess we'll just have to agree to differ, but don't forget the smiley. Oh, and of course, "Many a good book spells 'colour' without the 'u'"... (:->>>) –  Brent.Longborough Apr 26 '12 at 10:27

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.