2

I am trying to use different titles and line breaks for the chapter names in toc, the chapter title itself and the header of the page. I found the following code to do that:

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

For some reason the toc uses the title in {} instead of []. I have checked all the code and cannot figure out why something like this would happen.

I would really appreciate if there would be any suggestions. Thanks

  • 2
    Could you please provide a MWE? I am not sure about the double backslash in a title... – nox Jul 3 '18 at 15:43
  • 1
    Wild guess: Do you use a KOMA-Script class with option headings=optiontohead? – esdd Jul 3 '18 at 16:46
  • yes. I do use this option. – Tom Jul 3 '18 at 17:08
6

In a comment of the OP is mentioned that option headings=optiontohead is used.

KOMA-Script options headings=optiontohead, headings=optiontotoc and headings=optiontoheadandtoc activate the advanced functionality of the optional argument of the sectioning commands. If no key is used inside the optional argument then it only sets the header entry (optiontohead), the entry in ToC (optiontotoc) or both header and ToC entry (optiontoheadandtoc). But if one of this options is set, you can also use the keys tocentry, head and reference to get different entries in header and in TOC and with commands like \nameref.

Example:

\documentclass[headings=optiontohead]{scrbook}
\usepackage{lipsum}
\usepackage{nameref}
\begin{document}
\tableofcontents
\chapter[%
  tocentry={medium-length title for TOC, if wanted},
  head={short title for running headers},
  reference={short title for reference}
  ]{full title name:\\ full title}\label{chap:example}
\lipsum
\chapter[short title for running headers]{full title name in text and TOC}
\lipsum
\chapter[tocentry={medium-length title for TOC, if wanted}]{full title name in text and head}
\lipsum
\bigskip
Example for reference: \nameref{chap:example}
\end{document}

Result:

enter image description here

enter image description here

enter image description here

enter image description here

  • This solves the issue. Thank you so much. Impressive how you could come up with this solution with so little information. – Tom Jul 3 '18 at 20:16
1

The memoir class provides this.

\documentclass[...]{memoir}
% ...
\begin{document}
\tableofcontents
\chapter[toc-title][header-title]{body-title}
\section[toc-title][header-title]{body-title}
%...
\end{document}

If no optional arguments are given then body-title is used for the ToC, header, and in the body; with one optional argument then it is used for the ToC and header and body-title for the body; with two optional arguments then the first (toc-title) is used for the ToC, the second, header-title, is used for the header and body-title for the body.

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.