General ⇒ Adding "Chapter" and "Appendix" to ToC
Adding "Chapter" and "Appendix" to ToC
Hello, I have just joined and I'm having trouble finding a solution to my problem.
For my Master's Thesis, I am apparently required to have the words "Chapter" and "Appendix" before the respective number and letter on the Table of Contents. For example "Chapter 1 - Introduction" instead of "1 - Introduction". Now, I was able to find somewhere that it might be done with some addon package, but since I'm doing this remotely on the school's LINUX computer using sftp, I do not have permission to install anything.
Is there *any* way to get this result without having to install anything? The deadline is getting close, and I'm beginning to get desperate!
Thanks for any help that can be given!
For my Master's Thesis, I am apparently required to have the words "Chapter" and "Appendix" before the respective number and letter on the Table of Contents. For example "Chapter 1 - Introduction" instead of "1 - Introduction". Now, I was able to find somewhere that it might be done with some addon package, but since I'm doing this remotely on the school's LINUX computer using sftp, I do not have permission to install anything.
Is there *any* way to get this result without having to install anything? The deadline is getting close, and I'm beginning to get desperate!
Thanks for any help that can be given!
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Adding "Chapter" and "Appendix" to ToC
Search the forum for the tocloft package and take look at its documentation. But I'm sure that already some solutions exist here in the forum. The package should already be part of the system you are using.
Best regards and welcome to the board
Thorsten¹
Best regards and welcome to the board
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Adding "Chapter" and "Appendix" to ToC
Great! For some reason I had assumed tocloft was an addon. I'll give it a try and see what happens.
Adding "Chapter" and "Appendix" to ToC
Ok, I found this thread very useful. I used the following code:
And it works wonders for adding the "Chapter" before the listing int he ToC. However, it also adds "Chapter" where it should say "Appendix", such that it actually says:
Chapter 1 - ....
Chapter 2 - ....
Chapter A - ....
instead of
Chapter 1 - ....
Chapter 2 - ....
Appendix A - ....
Any suggestions? I'm looking through the documentation, and I can't seen to find a way to do this.
Thanks!
Code: Select all
Code, edit and compile here:
\usepackage{tocloft}\renewcommand{\cftchapfont}{\bfseries}\renewcommand{\cftchappagefont}{\bfseries}\renewcommand{\cftchappresnum}{Chapter }\renewcommand{\cftchapaftersnum}{:}\renewcommand{\cftchapnumwidth}{6em}\begin{document}\tableofcontents\chapter{First chapter}...\appendix\chapter{Appendix Name}\end{document}
Chapter 1 - ....
Chapter 2 - ....
Chapter A - ....
instead of
Chapter 1 - ....
Chapter 2 - ....
Appendix A - ....
Any suggestions? I'm looking through the documentation, and I can't seen to find a way to do this.
Thanks!
Adding "Chapter" and "Appendix" to ToC
Try this:
Code: Select all
Code, edit and compile here:
\makeatletter\renewcommand*\cftchappresnum{\@chapapp\ }\makeatother
Re: Adding "Chapter" and "Appendix" to ToC
phi ...
I tried that, and while it seemed like a great idea, it did not work. Still have "Chapter A" in the ToC.
I tried that, and while it seemed like a great idea, it did not work. Still have "Chapter A" in the ToC.
Adding "Chapter" and "Appendix" to ToC
Oh yes, I see the problem. This is an old one which I came across several times: the definition that is active during \tableofcontents matters, not the one that was active during \chapter. You have to write to the TOC file directory:
Code: Select all
Code, edit and compile here:
\documentclass{report}\usepackage{tocloft}\renewcommand{\cftchapfont}{\bfseries}\renewcommand{\cftchappagefont}{\bfseries}\renewcommand{\cftchapaftersnum}{:}\renewcommand{\cftchapnumwidth}{7em}\makeatletter\newcommand*\updatechaptername{%\addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{\@chapapp\ }}}\makeatother\begin{document}\tableofcontents\updatechaptername\chapter{First chapter}...\appendix\updatechaptername\chapter{Appendix Name}\end{document}
Re: Adding "Chapter" and "Appendix" to ToC
If you were using memoir (same author as tocloft) then it would have been as easy as
\renewcommand\cftchaptername{\chaptername~}
\renewcommand\cftappendixname{\appendixname~}
\renewcommand\cftchaptername{\chaptername~}
\renewcommand\cftappendixname{\appendixname~}
Adding "Chapter" and "Appendix" to ToC
phi ...
I tried that, and now my ToC looks like:
1:_____Introduction
2:_____Chapter Name
.
.
.
A:_____Appendix Name
with large spaces between the number and chapter name, and nothing before the number.
EDIT: In the .toc file, I note that it adds
in the respective places where \updatechaptername was used. Is this syntax correct?
I tried that, and now my ToC looks like:
1:_____Introduction
2:_____Chapter Name
.
.
.
A:_____Appendix Name
with large spaces between the number and chapter name, and nothing before the number.
EDIT: In the .toc file, I note that it adds
Code: Select all
Code, edit and compile here:
\renewcommand *\cftchappresnum {Chapter\ }\renewcommand *\cftchappresnum {Appendix\ }
Re: Adding "Chapter" and "Appendix" to ToC
I tested the code, and it works on my system (TeXLive 2007). Do you use exactly the same code?