0

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
Sebastiano
  • 54,118
TTT
  • 173
  • 7
    You can use the optional argument of \section to define a short version for the header.(and the table of contents). – Bernard Mar 07 '20 at 21:15
  • Thanks I didn't know you could write this: \section[test]{Section 4} – TTT Mar 07 '20 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 '20 at 19:19
  • I found a solution to this new problem here: https://tex.stackexchange.com/questions/343188/fancyhdr-chapter-and-section-titles-overlap-when-titles-are-long – TTT May 16 '20 at 18:49
  • @TTT -- This sounds like a candidate for closing as a duplicate. Do you agree? – barbara beeton Aug 20 '22 at 20:22
  • @barbarabeeton : Sorry, this is a bit old for me to remember everything very precisely, but if I wrote that the linked question solves the "new" problem, I likely meant that it did not solve the initial problem. I guess that my solution was a combination of Bernard's answer and of the linked answer. So no, it doesn't seem like a duplicate. – TTT Aug 21 '22 at 20:56
  • @TTT -- Thanks for following up. – barbara beeton Aug 22 '22 at 02:39

0 Answers0