6

I am writing a lab report, and select report class provided by LyX. I use LyX 2.0.3 and MiKTeX 2.9.

My question is, how to change the chapter number to display as text?

eg:

CHAPTER ONE not CHAPTER 1;

Also the same to be appear in the TOC

eg.:

CHAPTER ONE 
1.1...............
   1.1.1.........................
7

Here's one possibility using the \Numberstring command from the fmtcount package to turn the number to its text string; the tocloft package was used to add the word "Chapter" before the chapter number in the ToC:

\documentclass{report}
\usepackage{tocloft}
\usepackage{fmtcount}

\renewcommand\thechapter{\Numberstring{chapter}}
\setlength\cftchapnumwidth{3em}
\renewcommand\cftchappresnum{Chapter~}
\newlength\mylen
\settowidth\mylen{\bfseries\cftchappresnum\cftchapaftersnum} % extra space
\addtolength\cftchapnumwidth{\mylen}

\begin{document}

\tableofcontents
\chapter{Test Chapter}

\end{document}

An image of the ToC:

enter image description here

An image of the first page of the chapter:

enter image description here

  • I got the following error, how I can fix it plz.\documentclass {report} \usepackage{tocloft} \usepackage{fmtcount} Your command was ignored. Type I <command> <return> to replace it with another command, or <return> to continue without it. – MAHMD SHUGRAN Nov 18 '12 at 4:54
  • @MAHMDSHUGRAN are you getting this error with the exact code I posted in my answer? – Gonzalo Medina Nov 18 '12 at 21:08
2

Here is a direct patch of \@chapter - the macro responsible for setting the passing chapter content to the ToC, together with fmtcount for formatting the numbering of the chapter counter. The patch is thanks to xpatch:

enter image description here

\documentclass{report}
\usepackage{xpatch}% http://ctan.org/pkg/etoolbox
\usepackage{fmtcount}% http://ctan.org/pkg/fmtcount
\renewcommand{\thechapter}{\NUMBERstring{chapter}}%
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\makeatletter
\xpatchcmd{\@chapter}% <cmd>
  {\numberline{\thechapter}}% <search>
  {\@chapapp~\thechapter\quad}% <replace>
  {}{}% <success><failure>
\makeatother
\begin{document}
\tableofcontents
\chapter{First chapter}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\chapter{Second chapter}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\chapter{Third chapter}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\chapter{Last chapter}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\section{A section}\subsection{A subsection}\subsubsection{A subsubsection}
\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.