In LaTeX, how do I change the chapter number to display as text? eg:
CHAPTER ONE not CHAPTER 1;
CHAPTER THIRTEEN not CHAPTER 13.
In LaTeX, how do I change the chapter number to display as text? eg:
CHAPTER ONE not CHAPTER 1;
CHAPTER THIRTEEN not CHAPTER 13.
Short answer: put the following code before \begin{document}
.
\usepackage{fmtcount,etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\Numberstring{chapter}}{}{}
\patchcmd{\chaptermark}{\thechapter}{\NUMBERstring{chapter}}{}{}
\makeatother
Change \Numberstring
into \numberstring
if you don't want the number name capitalized.
A longer answer requires more information from you, that you can add to your question.
A quick solution would be also
\usepackage{fmtcount}
\renewcommand{\thechapter}{\Numberstring{chapter}}
but this will have some consequences on the typesetting of the Table of Contents (but also of headers). Choosing a strategy depends on the actual needs (and also on the class used).
fmtcount
.
– Seamus
Nov 3 '11 at 8:47
The memoir
documentclass provides this by default for some of the chapter styles. Consider reading the documentation; specifically section 6.5.1. Defining a chapter style (p 83).
Alternatively, also view some of the self-created code on Vincent Zoonekynd's LaTeX page for Chapters.
numname
package takes the code from the memoir
class and makes it available separately. The documentation is non-existent, but see this answer for details.
– Seamus
Nov 3 '11 at 8:49
I have seen there are other, perhaps smarter answers. BUt I spent quite some time on making this work, so I really wanted to post it. THis allows to convert any number from digits to English words, provided it has absolute value strictly less than a billion. This means it is more powerful than fmtcount
, which, AFAIK, allows no negative numbers, and stops at 99.999. So here goes:
\documentclass[a4paper]{report}
\usepackage{enumitem}
\newcommand{\encount}[1]{%
\ifnum #1>999999999%
\errmessage{Too high number.}%
\errhelp{The number you gave is at least a billion. I cannot count that high. Not in English, at least. Only in digits.}%
\else
\ifnum#1<0%
\count9=#1%
\multiply\count9 by -1%
minus \poscount{\count9}%
\else%
\poscount{#1}%
\fi%
\fi}
\newcommand{\unitcount}[1]{%
\ifcase#1zero\or one\or two\or three\or four\or five\or six\or seven\or eight\or nine\else\errmessage{WTF??}\fi%
}
\newcommand{\underhundredcount}[1]{%
\ifcase#1zero\or one\or two\or three\or four\or five\or six\or seven\or eight\or nine\or ten\or eleven\or twelve\or thirteen\or fourteen\or fifteen\or sixteen\or seventeen\or eighteen\or nineteen\or twenty\or twenty-one\or twenty-two\or twenty-three\or twenty-four\or twenty-five\or twenty-six\or twenty-seven\or twenty-eight\or twenty-nine\or thirty\or thirty-one\or thirty-two\or thirty-three\or thirty-four\or thirty-five\or thirty-six\or thirty-seven\or thirty-eight\or thirty-nine\or fourty\or fourty-one\or fourty-two\or fourty-three\or fourty-four\or fourty-five\or fourty-six\or fourty-seven\or fourty-eight\or fourty-nine\or fifty\or fifty-one\or fifty-two\or fifty-three\or fifty-four\or fifty-five\or fifty-six\or fifty-seven\or fifty-eight\or fifty-nine\or sixty\or sixty-one\or sixty-two\or sixty-three\or sixty-four\or sixty-five\or sixty-six\or sixty-seven\or sixty-eight\or sixty-nine\or seventy\or seventy-one\or seventy-two\or seventy-three\or seventy-four\or seventy-five\or seventy-six\or seventy-seven\or seventy-eight\or seventy-nine\or eighty\or eighty-one\or eighty-two\or eighty-three\or eighty-four\or eighty-five\or eighty-six\or eighty-seven\or eighty-eight\or eighty-nine\or ninety\or ninety-one\or ninety-two\or ninety-three\or ninety-four\or ninety-five\or ninety-six\or ninety-seven\or ninety-eight\or ninety-nine \else\errmessage{WTF??}\fi%
}
\newcommand{\underthousandcount}[1]{%
\count1=#1%
\ifnum#1>99%
\count7=#1%
\divide\count1 by 100%
\divide\count1 by 1%
\unitcount{\count1} hundred%
\multiply\count1 by 100%
\advance\count7 by -\count1\relax%
\ifnum\count7>0%
\ and \underhundredcount{\count7}%
\fi%
\else%
\underhundredcount{#1}
\fi
}
\newcommand{\poscount}[1]{%
\count3=#1%
\count5=\count3%
\ifnum\count3<1000%
\underthousandcount{\count3}%
\else%
\ifnum\count3<1000000%
\divide\count3 by 1000%
\divide\count3 by 1%
\underthousandcount{\count3} thousand%
\multiply\count3 by 1000%
\advance\count5 by -\count3%
\count3=\count5%
\ifnum\count5>0%
\ifnum\count5>99,\else\ and\fi\ \underthousandcount{\count3}%
\fi
\else
\divide\count3 by 1000000%
\divide\count3 by 1%
\underthousandcount{\count3} million%
\multiply\count3 by 1000000%
\advance\count5 by -\count3\relax%
\ifnum\count5>0%
\count3=\count5%
\divide\count3 by 1000\relax%
\ifnum\count5>99, \else\ and \fi%
\ifnum\count3>0%
\underthousandcount{\count3} thousand%
\fi%
\count5=#1%
\count3=\count5%
\divide\count3 by 1000%
\multiply\count3 by 1000%
\advance\count5 by -\count3\relax%
\ifnum\count5>0%
\underthousandcount{\count5}%
\fi%
\fi%
\fi%
\fi
}
\makeatletter
\renewcommand{\thesection}{\encount{\c@section}}
\newcommand{\test}[2]{
\begin{enumerate}
\setcounter{enumi}{#1}\loop\ifnum\c@enumi<#2\item\encount{\the\c@enumi}\repeat
\end{enumerate}
}
\makeatother
\begin{document}
\encount{123456789}
\test{999999}{1001000}
\end{document}
This provides a compilable example, which shows numbers from one million to one million, one thousand, printed as a numbered list. After typesetting one hundred and twenty-three million, four hundred and fifty-six thousand, seven hundred and eighty-nine on a line by itself. The important macros are \encount
, \unitcount
, \underhundredcount
, \underthousandcount
and \poscount
. Only the first one is to be used. The others are internals. Yes, I should use different names with @ to avoid accidental redefinition, and yes, I should use even-numbered counter registers, but hey, I have no time for such small adjustments :). The code can easily be adjusted for uppercase. Giving an option for first letter capitalization is quite tricky, and requires to create a conditional just for that. To use this for chapter numbering, the following line added to the preamble should work
\renewcommand\thechapter{\encount{\c@chapter}}
Of course, it must be wrapped in \makeatletter…\makeatother
. I haven't tested it, but it should work. Goodnight everyone and enjoy my macro :).
Try using this:
\usepackage{titlesec}
\usepackage{fmtcount}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \Numberstring{chapter}
{20pt}
{\fontsize{18pt}{18pt}\selectfont\bfseries}
\titleformat*{\section}{\fontsize{16pt}{16pt}\bfseries}
\titleformat*{\subsection}{\fontsize{14pt}{14pt}\bfseries}
\titleformat*{\subsubsection}{\fontsize{12pt}{12pt}\bfseries}