33

How can I format the header on every page displaying the title of the current chapter? In one of my chapters the title is too long so it is running out of the page.

Here's a minimal example of my document:

\documentclass[bibliography=totoc,version=first,listof=totoc,BCOR5mm,DIV12,index=totoc,numbers=noenddot]{scrbook}
\usepackage{bibgerm}
\usepackage[english,german]{babel}
\usepackage[utf8]{inputenc}
\usepackage{a4wide}
\usepackage{wrapfig}
\usepackage{caption}

\begin{document}
\frontmatter
\mainmatter
\chapter{Very long title}
\backmatter
\end{document}

Here's a screenshot of my problem:

enter image description here

61

Another alternative might be:

\chapter[medium-length title for TOC, if wanted]{full title name}
\chaptermark{short title for running headers}
16

You could provide a shorter chapter title via the optional argument to \chapter:

\chapter[<short title>]{<long title>}

Note that this will also influence the entry in the table of contents.

4

The solution that seems to work in every situation (even with math) is:

\chapter[\texorpdfstring{TOC title \( inline math A \)
    }{TOC in pdf bookmarks}
]{\chaptermark{header} Chapter title \( inline math A \)}
\chaptermark{header}
\label{CH:Chap}

In this solution the pdf bookmarks are defined by \texorpdfstring{#1}{#2}, where #1 is the title inside the pdf document while #2 is the pdf bookmark.

The [shorter] heading is defined by \chaptermark{header}. The repeated command is not a typo, but it is needed in order to have the right behaviour in every situation (do not ask why since I do not have any idea, just by tentative; if you know the reason, please comment. EDIT (2016-03-22): Some explanations can be found HERE)

Important: the solution also works with \section, just change \chaptermark with \sectionmark.

Disclaimer: I wrote the blog post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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