Page LayoutWhat's wrong with this ToC ?

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What's wrong with this ToC ?

Post by Cham »

I'm getting an error message for this "simple" ToC, and I need to know why. What is wrong ?

Error message : Undefined control sequence.

Compilable code :

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[]{tocbibind}
\usepackage{tocloft}
\usepackage[pagestyles,medium]{titlesec}

\newpagestyle{toc}{
	\sethead[\thepage][][\itshape\small\MakeUppercase{Table des matieres}]{\itshape\small\MakeUppercase{Table des matieres}}{}{\thepage}
	\headrule
}

\begin{document}

\pagestyle{toc}
\tableofcontents

\end{document}
It's apparently an interaction between the tocloft and titlesec packages, but I don't know how to solve the problem.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

What's wrong with this ToC ?

Post by Stefan Kottwitz »

Defining the missing \ttl@savemark by yourself directly before the table of contents would fix it.

Code: Select all

\pagestyle{toc}
\makeatletter
\gdef\ttl@savemark{\chaptermark{Table des matieres}}
\makeatother
\tableofcontents
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What's wrong with this ToC ?

Post by Cham »

What's this ? Why adding this ? Sorry, I really don't understand here.

EDIT : using

Code: Select all

\makeatletter\gdef\ttl@savemark{}\makeatother
instead solves also the issue, so why repeating the title ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

What's wrong with this ToC ?

Post by Stefan Kottwitz »

The error said, \ttl@savemark is undefined. So I defined it in a way I know that titlesec does in chapter heading commands. Obviously tocloft interferes with that, without that package it works.

I repeated the title so be on the safe side, at least it would not be incorrect.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: What's wrong with this ToC ?

Post by Cham »

O boy ! There's no way in this universe I could know this by myself, without asking someone. Thanks for the explanation, Stefan.

I'm trying to debug my preamble, since adding the modifications to the list of listings you gave me in another topic is causing major issues. I suspect there are lots of other problems like the previous one.

I'm begining to despair with this castle made of cards... Everything is starting to fall apart ! :cry:
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: What's wrong with this ToC ?

Post by Stefan Kottwitz »

Documents with common styles usually work very well in LaTeX. Special requirements or wishes may require some programming. While many tasks can be solved using packages, there are sometimes conflicts between packages, especially when their features overlap.

As everything is open source, most of the time problems can be solved after reading the source code. That's what I often do here. And it's not too hard with some experience. And unexperienced users can get help here.

With MS Word etc. in contrast, I cannot solve problems with crashes or fix formatting issues as there's no source code we can read.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

What's wrong with this ToC ?

Post by Cham »

And problems are actually much worst with MS Word (Office, or any usual word processors, actually), when it's about technical writings (maths, figures, etc). That's why I migrated to LaTeX a year ago, after yelling, shooting and crying at M$ crap and other WP.

I must admit that my project may be too ambitious : a very large book on relativity theory. Adding the Mathematica listings is what appears to cause the most problems to my cards castle... O well.

Thanks anyway for all the help, Stefan, it's greatly appreciated.

I may very well add your name to the thanks-list at the beginning of the book, since without your help, this book coulnd't be (almost) a reality by now. I'm almost there !
Post Reply