Text Formatting ⇒ Table of Content: add "Chapter" in ToC
Table of Content: add "Chapter" in ToC
I have the following issue regarding the way Table of Content looks:
This is what the table of contents pages currently looks like:
Table of Contents
1 Introduction ....... Page #
1.1 Really Introducing ....... Page #
2 The Data ....... Page #
2.1 About the Data ....... Page #
But I wouldlike to have the following style:
Table of Contents
Chapter 1 Introduction ....... Page #
1.1 Really Introducing ....... Page #
Chapter 2 The Data ....... Page #
2.1 About the Data ....... Page #
That means I would like to have the word "Chapter" printed in front of the chapter index in the Table of Contents. By the way, the word "Chapter" should not appear in front of the indexes of the sections and the subsections.
Is this do-able? How can I achieve this?
Isix
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Re: Table of Content: add "Chapter" in ToC
\renewcommand\cftchaptername{\chaptername~}
in the preamble
If you are not able to use memoir, then tocloft may be able to do this, but it has been a while since I had a look at that package.
Table of Content: add "Chapter" in ToC
how to make this looks like:daleif wrote:depends on your document class. The memoir class supports this out of the box by placing
\renewcommand\cftchaptername{\chaptername~}
in the preamble
If you are not able to use memoir, then tocloft may be able to do this, but it has been a while since I had a look at that package.
Chapter One: instead of Chapter 1?
Table of Content: add "Chapter" in ToC
In the ToC you have have to do some hacking
Code: Select all
\documentclass[a4paper]{memoir}
\let\oldchapternumberline\chapternumberline
\renewcommand\chapternumberline[1]{%
\oldchapternumberline{\numtoName{#1}}}
\renewcommand\cftchaptername{\chaptername~}
\addtolength\cftchapternumwidth{1em}
\begin{document}
\tableofcontents*
\chapter{test}
\end{document}
Table of Content: add "Chapter" in ToC
Thanks. But how to make the chapter name directly follows the chapter number. For example, in my case, the ToC appears like this:daleif wrote:In the ToC or in the text?
In the ToC you have have to do some hacking
note that this is not a general solution, as it does not take appendices into account (i.e. chapter numbering that are not numbers)Code: Select all
\documentclass[a4paper]{memoir} \let\oldchapternumberline\chapternumberline \renewcommand\chapternumberline[1]{% \oldchapternumberline{\numtoName{#1}}} \renewcommand\cftchaptername{\chaptername~} \addtolength\cftchapternumwidth{1em} \begin{document} \tableofcontents* \chapter{test} \end{document}
Chapter One:....Name1
Chapter Two:....Name2
Chapter Three: Name3
The dots are used just to fill the spaces
I want this to look like this:
Chapter One: Name1
Chapter Two: Name2
Chapter Three: Name3
Thanks in dvance
Table of Content: add "Chapter" in ToC
Code: Select all
\makeatletter
\renewcommand\chapternumberline[1]{%
\@chapapp@head\@cftbsnum \numtoName{#1}\@cftasnum~}
\renewcommand\cftchaptername{\chaptername~}
\makeatother
Table of Content: add "Chapter" in ToC
Ok, now it is working just fine.daleif wrote:Then you will have to change \chapternumberline
would be enoughCode: Select all
\makeatletter \renewcommand\chapternumberline[1]{% \@chapapp@head\@cftbsnum \numtoName{#1}\@cftasnum~} \renewcommand\cftchaptername{\chaptername~} \makeatother
Thank you very much.
Regards
Table of Content: add "Chapter" in ToC
Code: Select all
\documentclass[a4paper]{memoir}
\renewcommand\cftchaptername{\chaptername~}
\begin{document}
\tableofcontents*
\chapter{Intro}
\section{History}
\chapter{Theory}
\section{The Equation}
\chapter{Hypothesis}
\section{Our Claim}
\chapter{Analysis}
\section{Tne Work}
\chapter{Results}
\section{Suprises}
\chapter{Conclusion}
\section{Next Stuff}
\end{document}
Code: Select all
[LaTeX] test-toc-formating.tex => test-toc-formating.dvi (latex)
[LaTeX] finished with exit status 1
./test-toc-formating.tex:3:\cftchaptername undefined. \renewcommand\cftchaptername
[LaTeX] 1 error, 0 warnings, 0 badboxes
Code: Select all
\usepackage{tocloft}
Isix6
Re: Table of Content: add "Chapter" in ToC
try adding \listfiles before \documentclass, and then look in the log file.
You seem to be using an old memoir
Table of Content: add "Chapter" in ToC
Code: Select all
*File List*
memoir.cls 2004/04/05 v1.61 configurable document class
mem10.clo 2002/07/27 v0.2 memoir class 10pt size option
mempatch.sty 2005/02/01 v3.5 Patches for memoir class v1.61
***********