# Short title in header but not ToC for document class book

I would like to have a short title of chapters and sections in my headers, but in the ToC there should appear the long title.

I am using the book document class, and package fancyhdr. \section[short title]{long title} gives me the headers I want, but then the short title is also placed in the ToC.

This didn't work out in my case: Short title that is not displayed in the ToC {hyperref}

• Welcome to TeX SX! If you use package titlesec, this is done through the [toctitles] option. – Bernard Nov 9 '18 at 19:12
• Thank you, I didn't see your answer at first, but this is actually the fastest solution! – Anja Nov 13 '18 at 16:45

The following updates the way the marks are used when setting the chapter and sectional titles within the book class:

\documentclass{book}

\usepackage{fancyhdr,lipsum}

\makeatletter

\let\oldchaptermark\chaptermark
\renewcommand{\chaptermark}[1]{\oldchaptermark{\@chaptermark}}% Used stored chapter mark
\let\old@chapter\@chapter
\def\@chapter[#1]#2{%
\def\@chaptermark{#1}% Store chapter mark
\old@chapter[#2]{#2}%
}

\let\oldsectionmark\sectionmark
\renewcommand{\sectionmark}[1]{\oldsectionmark{\@sectionmark}}% Used stored section mark
\let\oldsubsectionmark\subsectionmark
\renewcommand{\subsectionmark}[1]{\oldsubsectionmark{\@subsectionmark}}% Used stored subsection mark
\let\old@sect\@sect
\def\@sect#1#2#3#4#5#6[#7]#8{%
\@namedef{@#1mark}{#7}% Store sectional mark
\old@sect{#1}{#2}{#3}{#4}{#5}{#6}[#8]{#8}%
}

\makeatother

\begin{document}

\tableofcontents

\sloppy % Just for this example
\chapter[Chapter short title]{Chapter long title}
\lipsum[1-50]

\section[Section short title]{Section long title}
\lipsum[1-50]

\end{document}

• Thanks but... then it doesn't know the command \section any more. What could have gone wrong? – Anja Nov 10 '18 at 14:27
• @Anja: In my example there is no problem. Can you elaborate on what packages you use? Perhaps start by taking my example and adding packages you use until something goes wrong. This way you can identify the conflicting package(s). Give some feedback on your findings. – Werner Nov 10 '18 at 15:56
• Actually several of the packages were causing problems, so in my case the solution suggested by Peter Wilson was just faster to get it to run. Thank you still. – Anja Nov 13 '18 at 16:01

If you would care to change to the memoir class (which encompasses the book class and an equivalent of the fancyhdr package) then:

\chapter[<toc-title>][<head-title>]{<title>}

puts <toc-title> in the ToC, <head-title> in the header and <title> in the body of the document. SimIlarly the same constructs are available for \subsection, \subsubsection, etc.
• @Anja Try \OnehalfSpacing and the titllingpage environment. (No need for any packages for these). – Peter Wilson Nov 10 '18 at 20:23