texblog

Chapter numbers as words in LaTeX

I was asked more than once how to produce words instead of numbers in the chapter heading. This is fairly straight forward, but requires patching the chapter macro. I will show how to do this for chapter. However, this works similarly for part, section, and subsection.

 

Loading the required packages

First we load the fmtcount package and the etoolbox package. The fmtcount package allows printing numbers as words and the etoolbox package implements a simple way to change the behavior of a command.

\usepackage{fmtcount}
\usepackage{etoolbox}

 

From numbers to words

The fmtcount package provides three macros to print numbers as words:

 

Patching chapter

We use the etoolbox package to change the way chapter numbers are printed. Firstly, we replace the numbers in the chapter heading. Secondly, we replace the numbers in the headers of the document.

\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\NUMBERstring{chapter}}{}{}
\patchcmd{\chaptermark}{\thechapter}{\NUMBERstring{chapter}}{}{}
\makeatother

 

Minimal code example

\documentclass{report}
\usepackage{fmtcount,etoolbox,blindtext}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\NUMBERstring{chapter}}{}{}
\patchcmd{\chaptermark}{\thechapter}{\NUMBERstring{chapter}}{}{}
\makeatother

\begin{document}
\chapter{Introduction}
\blindtext
\end{document}

 

Remarks

The package implements numbers as words in different languages (English, French, German, Portuguese, and Spanish). Use babel to set the language in the document preamble. Finally, fmtcount macros work for integer numbers in [0, 99999]. Anything outside of that interval wouldn’t work.

Exit mobile version