1

In book class the table of contents appears as follows, with the first line having the chapter number.

toc

As you see, the chapter numbering appears horribly at the side of the chapter's name, since every chapter's name is a date and, thus, begins with a number as well.

Being these lessons, I'd like the chapter's number to appear this way instead: "Lesson X. Date". Example: "Lesson 1. 04 Giugno 2018".

I suppose it should be enough to renew the command that the table of contents uses to recall the number of the chapter, but I can't find which command it is.

Do you have a clue about how should I proceed?

Edit 1

The class I'm using is book. The packages I'm using are babel, inputenc, ulem, url, eurosym, fancyhdr, graphicx, wrapfig, geometry.

I don't think a MWE is needed, but that would be:

\documentclass[a5paper, openany]{book}

\usepackage[italian]{babel}
\usepackage[utf8]{inputenc}
\usepackage[normalem]{ulem}
\usepackage{url}
\usepackage{eurosym}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{tocloft}
\usepackage{geometry}

\frenchspacing

\begin{document}
    \tableofcontents

    \chapter{4th June}
    \chapter{5th July}
\end{document}

Apparently the package tocloft could be the solution, but there must be some kind of conflict because here's what happenes if I use it as indicated in the related answer by Peter Wilson:

tocloft

As you see, it also modifies the space between lines.

  • 1
    This depends on your \documentclass and/or other packages you might be loading. There are options. Can you provide the community with a complete, minimal example that starts with \documentclass and ends with \end{document}, replicating your current setup? – Werner Oct 16 '18 at 16:18
2

Use the tocloft package. For example (after eliminating any typos)

\documentclass[...]{...}
\usepackage{tocloft}
\renewcommand{\cftchappresnum}{Lesson } % Put Lesson before chapter number
\renewcommand{\cftchapaftersnum}{.} % Put a period after the number
% add extra space for Lesson
\newlength{\tocl}% a scratch length
\settowidth{\tocl}{\bfseries\cftchappresnum\cftchapaftersnum}% extra space
\addtolength{\cftchapnumwidth}{\tocl}% add the extra space 
...
\begin{document}
...
\tableofcontents
...
\chapter{04 Giugno 2018}
...
\end{document}

Read the manual (> texdoc tocloft) for more information. I should have done that before posting as I initially forgot to allow for the extra space required for Lesson.

  • This works great but the words I add this way don't "move" the chapter's name in the toc; as a consequence all the pieces before and after the chapter's name, and the chapter's name itself, overlap themselves. I checked and the package's documentation doesn't specify conflicts with other packages I'm using, nor it mentions this occurrance. I'll put a screenshot in the opening post. Might this be a bug? I see that this package is quite recent – il mietitore Oct 17 '18 at 9:42
  • 1
    @ilmietitore My apologies, in my initial posting I forgot to allow for the extra space required for Lesson. I originally developed tocloft in 1998. It was a posting bug, not a package bug. – Peter Wilson Oct 18 '18 at 18:38
  • Now it works. Still, the lineskip becomes shorter, as shown in the screenshots above. Is there a way to leave it as it as by default? The package documentation doesn't mention this occurrance. – il mietitore Oct 28 '18 at 13:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.