1

I'm trying to print the chapter number of a cross referenced labelled chapter, not as an Arabic or Roman numeral, but written out as a word.

I have managed to find some information here, which advises me to use fmtcount and refcount packages: http://www.dickimaw-books.com/cgi-bin/faq.cgi?action=view&categorylabel=fmtcount#ftmrefcount

Here is what I have:

\documentclass{report}
\usepackage{fmtcount}
\usepackage{refcount}
\begin{document}
\chapter{Introduction}
\label{ch:introduction}
\newcounter{chintroduction}\setcounterref{chintroduction}{ch:introduction}

Chapter~\numberstring{chintroduction} is the introduction.

Chapter~\numberstring{chmain} is the main chapter.

Chapter~\numberstring{chconclusion} is the conclusion.

\chapter{Main}
\label{ch:main}
\newcounter{chmain}\setcounterref{chmain}{ch:main}

\chapter{Conclusion}
\label{ch:conclusion}
\newcounter{chconclusion}\setcounterref{chconclusion}{ch:conclusion}
\end{document}

I realise that in order for labels to work I have to compile twice.

What I want (as the body of the introduction chapter):

Chapter one is the introduction.

Chapter two is the main chapter.

Chapter three is the conclusion.

What I get after second compilation:

Chapter one is the introduction.

Chapter zero is the main chapter.

Chapter zero is the conclusion.

I also get the following two error messages during compilation:

! You can't use `\relax' after \the.
<recently read> \c@chmain 

l.11 Chapter~\numberstring{chmain} 
                                   is the main chapter.
? 
! You can't use `\relax' after \the.
<recently read> \c@chconclusion 

l.13 Chapter~\numberstring{chconclusion} 
                                         is the conclusion.
? 

It seems like my method works for chapter labels preceding the attempt to reference them, but not those that come after. Why doesn't this work, and how can I fix it?

2

Here is a solution

\documentclass{report}
\usepackage{fmtcount}
\usepackage{refcount}
\newcommand\mtnumberstring[1]{\numberstringnum{\getrefnumber{#1}}} 
\begin{document}
\chapter{Introduction}
\label{ch:introduction}

Chapter~\mtnumberstring{ch:introduction} is the introduction.

Chapter~\mtnumberstring{ch:main} is the main chapter.

Chapter~\mtnumberstring{ch:conclusion} is the conclusion.

\chapter{Main}
\label{ch:main}

\chapter{Conclusion}
\label{ch:conclusion}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.