153

I am writing a book and one of my chapters has a very long title. As it can't be displayed correctly on the top of even pages, I provide a "short title name" via the

\chapter[short title]{long title}

command. But then, "short title" appears in the table of contents instead of the original/true/long one.

How can I have the "short title" in the header of even pages, and the "long title" in the ToC and in the "Title header"?

For reference, here is the code I use:

\documentclass[11pt,a4paper]{book}
\begin{document}
\tableofcontents 
\chapter[Short title]{Very vey very very very very very very long title
    i can't display in the header}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{document}
0

6 Answers 6

205
\chapter[toc version]{doc version}
\chaptermark{version for header}

Helpful link with more information (also for similar or different use-cases):

https://texfaq.org/FAQ-runheadtoobig

6
  • 1
    you were faster. :-) BTW, is this your third account? If yes, have you thought about asking a moderator to merge your accounts?
    – lockstep
    Dec 10, 2010 at 13:39
  • 2
    Thanks! For future readers: the link also provides very useful information for section headers, and notes the easy solution with the [toctitles] package option if you're using the {titlesec} package.
    – phfaist
    Feb 25, 2016 at 19:28
  • 1
    Extra points should be given for such short answers =) Sep 1, 2017 at 19:27
  • 1
    Aren't you life saver! Sep 21, 2018 at 13:00
  • The link in this answer no longer works, a working link can be found in @BrianD's answer below Jun 20, 2022 at 12:10
37

The sectioning commands of the memoir class feature a second optional argument:

\documentclass[11pt,a4paper]{memoir}

\begin{document}

\tableofcontents*% Starred form for not including the ToC in the ToC

\chapter[Title displayed in ToC][Title displayed in header]{Title}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\clearpage\null

\end{document}

EDIT: Since v3.10, the KOMA-Script classes allow to specify the usage of the optional argument of sectioning commands. The class options are headings=optiontohead, headings=optiontotoc, and headings=optiontoheadandtoc.

\documentclass[headings=optiontohead]{scrbook}

\begin{document}

\tableofcontents

\chapter[Title displayed in header]{Title; also displayed in ToC}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\clearpage\null

\end{document}
14

Another option is to use the truncate package, with fancyhdr, which truncates the header if it's too long, and adds an elypsis at the end:

 \usepackage[fit]{truncate}
 \usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhead[RO,LE]{\truncate{.95\headwidth}{\leftmark}}
 \fancyfoot[C]{\thepage}
8

the ams document classes behave this way by default -- the optional argument is used only for the running head, and the long form is used in the toc.

because adjustments such as line breaks must sometimes be applied to the long form, the ams classes provide an "in-title" modification mechanism to allow different changes to apply to the header itself vs. what goes into the toc.

two commands are provided:

  • \for{toc}{...} includes the specified material in the toc entry;

  • \except{toc}{...} uses the material in the header itself, but excludes it from the toc.

this mechanism works also for lof and lot entries. additional commentary can be found in the ams author faq.

1

The URL for the top answer no longer works. You can find the content now at https://texfaq.org/FAQ-runheadtoobig

0

You can update the sectional units to include a second optional argument (akin to what is provided by memoir) that allows you to specify the mark explicitly and distinctly from the ToC or main document entry.

enter image description here

\documentclass{book}

\NewDocumentCommand{\UpdateSectionalUnit}{ m }{%
  % Store original sectional unit
  \expandafter\expandafter\expandafter\let\expandafter\csname old#1\expandafter\endcsname\csname #1\endcsname
  \expandafter\RenewDocumentCommand\csname #1\endcsname{ s o o m }{%
    \expandafter\let\expandafter\oldmark\csname #1mark\endcsname
    \expandafter\expandafter\expandafter\let\expandafter\csname #1mark\expandafter\endcsname\csname @gobble\endcsname
    \IfBooleanTF{##1}
      {% \<cmd>*
        \csname old#1\endcsname*{##4}% Sectional unit
        \IfValueT{##2}{\addcontentsline{toc}{#1}{##2}}% Add sectional unit to ToC
      }{% \cmd
        \IfValueTF{##2}
          {% \cmd[.]
            \csname old#1\endcsname[##2]{##4}% Sectional unit
          }{% \cmd{.}
            \csname old#1\endcsname{##4}% Sectional unit
          }%
      }%
    \expandafter\let\csname #1mark\endcsname\oldmark
    \IfValueTF{##3}% Update/add mark
      {\csname #1mark\endcsname{##3}}
      {\csname #1mark\endcsname{##4}}%
  }%
}

\UpdateSectionalUnit{chapter}
\UpdateSectionalUnit{section}

\begin{document}

\tableofcontents 

\chapter
  [Chapter ToC title]
  [Chapter header title]
  {Very very very very very very very very long title I can't display in the header}

\mbox{}\newpage
\mbox{}\newpage

\section
  [Section ToC title]
  [Section header title]
  {Very very very very very very very very long title I can't display in the header}

\end{document}

You must log in to answer this question.