# Section title gets too long in header

On page 9 of the generated document, you can see that the section title is so long that is gets on two lines and overrides the chapter title. In some programming languages, I would think of including some kind of "truncate" version in my header definition. I also read things about having shorter versions of chapter/section title, (something like \sectionmark) , but this was not recognised by my compiler.

What would be a way to have a shorter title in header.

Code: Main.tex

    %Preamble
\documentclass[a4paper,french,oneside,openright]{book}

\usepackage{afterpage}
\newcommand{\blankpage}{
\null
\thispagestyle{empty}
\addtocounter{page}{-1}
\newpage
}

\usepackage[french]{babel}
\usepackage{fancyhdr}
\usepackage{lipsum}

\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{Chapter }
\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapter }}}

\title{Title}
\author{Name}
\date{2020}

\begin{document}
\input{Pages/TitlePage.tex}
\input{Pages/Thanks.tex}

\tableofcontents

\pagestyle{fancy}
\lfoot{Title}
\rfoot{Page \thepage/\pageref{LastPage}}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.1pt}

\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[L]{Title}%
\fancyfoot[R]{Page \thepage/\pageref{LastPage}}%
\renewcommand{\headrulewidth}{0pt}% Line at the header invisible
\renewcommand{\footrulewidth}{0.1pt}% Line at the footer visible
}

\chapter{Introduction}
\section{Introduction}
\lipsum
\chapter{Chapter title}
\section{This section title is toooooooooooooooooooooooooooo long}
\lipsum
\chapter{Chapter title}
\section{SectionTitle}
\lipsum
\chapter{Chapter title}
\section{SectionTitle}
\lipsum
\chapter{Chapter title}
\section{SectionTitle}
\lipsum
\chapter{Chapter title}
\section{SectionTitle}
\lipsum
\chapter{Chapter title}
%\section{SectionTitle}  %Testing what happens in table of contents when there is a chapter without section.
\lipsum
\chapter{Chapter title}
\section{SectionTitle}
\lipsum
\end{document}


Pages\TitlePage.tex

\begin{titlepage} \newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\HRule \\[0.9cm]
\begin{center}
\textsc{\Huge Title}\\[1cm]
\textsc{\LARGE Subtitle}\\[1.5cm]
\end{center}
\HRule \\[1.5cm]

\begin{center} \Large
\begin{tabular}{ l r }
\emph{Text} & Text\\
\emph{Text} & Text
\end{tabular}
\end{center}

\vfill

\begin{center} \large
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l r @{}}
\ Text & Text\\
\ Text & Text\\
\ Text & Text\\
\ Text & Text\\
\ Text & Text
\end{tabular*}
\end{center}
\afterpage{\blankpage}
\end{titlepage}


Pages\Thanks.tex

\pagestyle{empty}
\part*{Thanks}
\blankpage

• You can use the optional argument of \section to define a short version for the header.(and the table of contents). – Bernard Mar 7 at 21:15
• Thanks I didn't know you could write this: \section[test]{Section 4} – TTT Mar 7 at 21:20
• Hello, I back working on this document ... I notice 2 problems with this solution: I get titles overlapping on two lines ... I truncate what I think would be enough from section optional name, then both titles get condense on one single line. And I come to situations where I cannot have a single word in my section name without overlapping the chaptername. Hence I tried removed the shortened title like this: \section[]{Section X title} ... but then my sections don't have a title in my table of content... I don"t think that the shortened title should be impacting the table of content at all... – TTT May 14 at 19:19
• I found a solution to this new problem here: tex.stackexchange.com/questions/343188/… – TTT May 16 at 18:49