Page LayoutChapter Number Format in ToC

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
cgp
Posts: 3
Joined: Tue Aug 02, 2011 9:51 am

Chapter Number Format in ToC

Post by cgp »

Hello everybody!

I'm writing a book. I'd like that in the table of contents after the chapter number appears a dot (.). I'm trying to use

Code: Select all

\renewcommand{\thechapter}{\arabic{chapter}.}
But thus, I obtain the dot even in each chapter title.

How could I do it only in the table of contents?

Thank you in advance.

Recommended reading 2024:

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

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

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Chapter Number Format in ToC

Post by localghost »

The easiest way is to use the titletoc package with an appropriate option.

Code: Select all

\documentclass[11pt,english]{book}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[dotinlabels]{titletoc}
\usepackage{blindtext}

\begin{document}
  \tableofcontents

  \blinddocument
\end{document}
As alternative you can use the tocloft package. But this solution needs explicit redefinitions for every heading level.

Code: Select all

\documentclass[11pt,english]{book}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{tocloft}
\usepackage{blindtext}

\renewcommand{\cftchapaftersnum}{.}
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
%\renewcommand{\cftsubsubsecaftersnum}{.}

\begin{document}
  \tableofcontents

  \blinddocument
\end{document}
The blindtext package in both cases is only for creating dummy text, thus is not part of the solution.
cgp
Posts: 3
Joined: Tue Aug 02, 2011 9:51 am

Re: Chapter Number Format in ToC

Post by cgp »

Thank you but... Could it be possible change only the format of the number in the title of the chapter?

Thank you again.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Chapter Number Format in ToC

Post by localghost »

Don't know where I had my head. Take the second example and comment every redefinition except for \renewcommand{\cftchapaftersnum}{.}. By the way, that's something you could have found out on your own by reading the corresponding package manual and playing around with the code. It is not recommendable to modify only the ToC entry of the chapter due to inconsistency.
cgp
Posts: 3
Joined: Tue Aug 02, 2011 9:51 am

Re: Chapter Number Format in ToC

Post by cgp »

Thank you for your answer.

However, I obtained error when compiling. Therefore, I'm maintaining my old renewcommands of thechapter, thesection and so on and I'm trying to format only the number of the chapter title. Maybe I should use the titlesec or fancychap packages but I don't find any option in these packages.

Thank you again.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Chapter Number Format in ToC

Post by localghost »

cgp wrote:[…] However, I obtained error when compiling. […]
You should be more specific in your problem description. The log file for sure has the detailed error message(s). Cut down the problem to a minimal example that is reduced to only the relevant code.
Post Reply