General ⇒ Adding "Chapter" and "Appendix" to ToC
Adding "Chapter" and "Appendix" to ToC
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!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Adding "Chapter" and "Appendix" to ToC
Best regards and welcome to the board
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Adding "Chapter" and "Appendix" to ToC
Adding "Chapter" and "Appendix" to ToC
Code: Select all
\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
Code: Select all
\makeatletter
\renewcommand*\cftchappresnum{\@chapapp\ }
\makeatother
Re: Adding "Chapter" and "Appendix" to 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
Code: Select all
\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
\renewcommand\cftchaptername{\chaptername~}
\renewcommand\cftappendixname{\appendixname~}
Adding "Chapter" and "Appendix" to ToC
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
\renewcommand *\cftchappresnum {Chapter\ }
\renewcommand *\cftchappresnum {Appendix\ }