Page LayoutWord "Chapter" in ToC Entries

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
eroeurbano
Posts: 5
Joined: Mon Oct 31, 2011 9:17 pm

Word "Chapter" in ToC Entries

Post by eroeurbano »

Dear all,
I'm writing a PhD thesis in Latex and everything works well
except that I can't have the table of contents the way I like.
Now it looks like:

Code: Select all

1 First chapter
  1.1 first section
2 Second Chapter
What I would prefer is to add the word "chapter" before the chapters, but not to the sections so that it looks like:

Code: Select all

Chapter 1: First chapter
  1.1 first section
Chapter 2: Second Chapter
(the comma are preferred but not required)

As far as I have understood the package titlesec might help but I couldn't figure how to use it exactly.

Can some of you guys give me some help?
Thanks a lot in advance, every hint is really appreciated!
Last edited by eroeurbano on Tue Nov 01, 2011 10:16 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

5gon12eder
Posts: 126
Joined: Sun Feb 13, 2011 8:36 pm

Word "Chapter" in ToC Entries

Post by 5gon12eder »

You could do something like this:

Code: Select all

\documentclass{report}
\usepackage{titletoc}

\titlecontents{chapter}
              [0pt]% indent from left (mandatory!)
              {\vspace{2ex}\bfseries}% material before the entry
              {Chapter \thecontentslabel:\quad}% material before the chapter
                                               % title of a numbered entry
              {}% material before the chapter title of an unnumbered entry
              {\hfill\contentspage}% material after the chapter title
              [\vspace{1ex}]% material after the entry

\begin{document}
  \tableofcontents
  
  \chapter{Lorem Ipsum}
  \section{Suspendisse Varius Dolor}
  \section{Ut Tristique Egestas}
  \chapter{Dolor Nibh Sagittis Erat}
  \section{Ac Suscipit}
  \subsection{Odio Risus at Ante}
  \section{Sed Placerat Fermentum}
  % Just for demonstration purpose an entry without a number:
  \addcontentsline{toc}{chapter}{Vivamus eu Quam Dui}
  \chapter*{Vivamus eu Quam Dui}
  
\end{document}
The macro is explained in section 7.1 of the titletoc manual.
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).
eroeurbano
Posts: 5
Joined: Mon Oct 31, 2011 9:17 pm

Word "Chapter" in ToC Entries

Post by eroeurbano »

5gon12eder wrote:You could do something like this:
The macro is explained in section 7.1.
Thanks a lot 5gon12eder it worked like a champ!
That's exactly what I wanted.
I'm sorry I missed the example in the manual and had to bother people
in the forum!
Thank you very much again!
Post Reply