Page LayoutBook: Long title in CONTENTS but short title in HEADER

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
bierholen
Posts: 2
Joined: Fri Jan 16, 2009 9:30 pm

Book: Long title in CONTENTS but short title in HEADER

Post by bierholen »

Hi,

The title of one of my book chapters is too long to be displayed correctly in the RUNNING HEADER. I know that I can add a short title by doing

\chapter[Short title]{Long title}

Then, however, the short title also appears in the TABLE OF CONTENTS where I would like the long title to be displayed. Therefore, I'm simply looking for a way to have the short title in the RUNNING HEADER but the long title in the TABLE OF CONTENTS.

Does anybody have an idea how to solve this easily?

Thanks!

pdfTEX-1.40.3
book class

Recommended reading 2024:

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

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

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Book: Long title in CONTENTS but short title in HEADER

Post by phi »

you have to redefine an internal macro:

Code: Select all

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#2}%
                       \else
                         \addcontentsline{toc}{chapter}{#2}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#2}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Book: Long title in CONTENTS but short title in HEADER

Post by gmedina »

Hi,

you could use the fancyhdr package, as the following example suggets:

Code: Select all

\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{lipsum}% just to generate some text

\begin{document}
\tableofcontents

\chapter{A chapter with a really relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly relly long title}
\fancyhf{}
\fancyhead[RO,LE]{\MakeUppercase{\chaptername\ \thechapter. A short title}}
\fancyhead[RE,LO]{\thepage}
\lipsum[1-40]

\chapter{Test}
\fancyhf{}
\fancyhead[RO,LE]{\leftmark}
\fancyhead[RE,LO]{\thepage}
\lipsum[1-40]

\end{document}
Please refer to the package User's manual for further information.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
bierholen
Posts: 2
Joined: Fri Jan 16, 2009 9:30 pm

Book: Long title in CONTENTS but short title in HEADER

Post by bierholen »

phi wrote:you have to redefine an internal macro:
Thanks phi. That did the trick. Thanks to gmedina as well.
francois
Posts: 1
Joined: Tue Aug 11, 2009 3:36 am

Book: Long title in CONTENTS but short title in HEADER

Post by francois »

Hi,

I'm facing the same problem as "bierholen" and was just wondering if "phi's" marco also works for "sections", and, therefore, whether it would be possible just to replace "chapter" with "section" within that macro. If that works: fine -- if not, does somebody have suggestions on how a macro that allows for short sections in the header and long sections in TOC would have to look like?

Although

Code: Select all

\section[short title]{long title\sectionmark{header}}
\sectionmark{header}
may work fine in a typical bookclass it did not work for me using the option "oneside". While the short title appears on subsequent pages, it does not, however, appear on the first page on which the section initially begins.

One possibility how to circumvent these difficulties can be found @ http://www.developpez.net/forums/d52725 ... titre-long and consists of:

Code: Select all

\newcommand{\mysection}[2]{%
    \sectionmark{#1}%
    \section{#2}%
    \sectionmark{#1}%
    }
Sections that are too long can be redefined by \mysection{short title}{long title}. Any other suggestions? Thanks!
François
vasil
Posts: 2
Joined: Mon Aug 31, 2009 1:48 pm

Book: Long title in CONTENTS but short title in HEADER

Post by vasil »

a bit too late, but isnt it easier to just manually specify the marks for the problematic chapters, like this:

Code: Select all

\chapter{very long title bla bla bla}
\markboth{very long title}{}
ofc you have to adjust it to the header/footer type you're using, but it doesnt effect the TOC entry at all. in my case it does the trick :)
and ofc its identical to what gmedina suggested, but you just redefine the mark.
Post Reply