Page LayoutHow to prevent TOC header to print after the TOC?

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
alyx
Posts: 4
Joined: Sat Jun 12, 2010 9:37 am

How to prevent TOC header to print after the TOC?

Post by alyx »

Hello,

I'm using LyX to write a book based on the koma-script class.
A table of contents is inserted, followed by a non-numbered chapter:

Code: Select all

\tableofcontents{}
\chapter*{\newpage{}Avant-Propos}
The title "Table of contents" prints in the page headers of the "Avant-Propos" chapter. How can I make this header stop on the page where the TOC ends?

Thanks.

Recommended reading 2024:

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

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

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

How to prevent TOC header to print after the TOC?

Post by localghost »

Use the features of KOMA Script.

Code: Select all

\tableofcontents\clearpage
\addchap{Avant-Propos}
See the manual for details.


Best regards and welcome to the board
Thorsten
alyx
Posts: 4
Joined: Sat Jun 12, 2010 9:37 am

How to prevent TOC header to print after the TOC?

Post by alyx »

Thanks. It works.

A more general solution is to insert this after the not-numbered chapter titles:

Code: Select all

\markboth{left-page-header}{right-page-header}
The second pair of curly brackets (here empty) are for the header to print on the right pages (i.e. odd pages), typically a section name.

The benefit of using \addchap{} is that you don't have to edit the first argument of \markboth{} if the name of the chapter changes. The drawback is that chapter titles are not displayed like chapters inside LyX, but as LyX code. This is a minor drawback for the writer. It is worth mentioning that \addchap{} is valid for KOMA-Script only, which is not the case of \markboth.

Here are two interesting links about \markboth.

1) http://www.mail-archive.com/lyx-users@l ... 02583.html

For French speakers:
2) http://www.developpez.net/forums/d60370 ... -leftmark/
Last edited by alyx on Sun Jun 13, 2010 2:37 pm, edited 1 time in total.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to prevent TOC header to print after the TOC?

Post by localghost »

alyx wrote:[...] The benefit of using \addchapter{} is that you don't have to edit the first argument of \markboth{} if the name of the chapter changes. The drawback is that chapter titles are not displayed like chapters inside LyX, but as LyX code. This is a minor drawback for the writer. It is worth mentioning that \addchapter{} is valid for KOMA-Script only, which is not the case of \markboth. [...]
I don't see where the talk was of this »\addchapter« command (which doesn't exist).
alyx
Posts: 4
Joined: Sat Jun 12, 2010 9:37 am

How to prevent TOC header to print after the TOC?

Post by alyx »

I don't see where the talk was of this »\addchapter« command (which doesn't exist).
Oops! Sorry, I meant "\addchap". I corrected in my previous message.
alyx
Posts: 4
Joined: Sat Jun 12, 2010 9:37 am

How to prevent TOC header to print after the TOC?

Post by alyx »

So, to summarize the issue is thus of correct page headers after a table of contents (TOC), when the content that follows is not a numbered chapter and using the KOMA-Script book class, i.e. scrbook.cls.

If what follows the TOC is a not-numbered chapter like a foreword, we can either use:

Code: Select all

\addchap{Foreword}
or

Code: Select all

\chapter*{Foreword}
\markboth{Foreword}{}
:!: With the first solution, the "Foreword" will be printed as an entry in the table of contents. This is not the case if we choose the second solution.

The second solution also gives a correct preview of the chapter title if you're working with LyX.

It can also be adapted if the text that follows the table of contents is not a chapter. Assuming that the TOC ends on an odd page and we want the Foreword to print as a sub-section on the next odd page, we can use

Code: Select all

\newpage \markboth{}{} \null 
\newpage
\subsection*{Foreword}
\markboth{Foreword}{}
Code above adds a blank even page (without header). Then it creates an even page with a subsection titled "Foreword". Even pages after this subsection will be headed with the text "Foreword".

Hope this can help others.
Post Reply