Usually, when I want to reduce the size of some of my titles in the headers, I use [a short title in brackets]. But, this time, I'd like to use long titles in the TOC, but the headers have to be short. How could I achieve this? This is my MWE:
\documentclass[hidelinks,12pt,twoside,openright,a4paper]{book}
\setlength{\headheight}{14.49998pt}
\addtolength{\topmargin}{-2.49998pt}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{setspace}
\linespread{1.1}
\usepackage[left=5.5cm,right=5.5cm,top=6.5cm,bottom=6.5cm]{geometry}
\usepackage{lipsum}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}
\usepackage{titlesec}
\usepackage{titling}
\titleformat{\section}{\normalsize\itshape}
\titleformat{\subsection}{\normalsize\itshape}
\titleformat*{\subsubsection}{\normalsize\itshape}
\usepackage{tocloft}
\setlength{\cftbeforechapskip}{3pt}%espace entre chapitres
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters
\usepackage{hyperref}
\usepackage[numberedbib,nosectionbib]{apacite}
\usepackage[makeindex]{imakeidx}
\makeindex[name=npr, title=Index des noms]
\makeindex[name=mat, title=Index des matières]
\usepackage{fancyhdr}
\pagestyle{fancy}
% We don't want chapter and section numbers
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{} % sets both header and footer to nothing
\fancyfoot{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[CE]{\textit{A name}} % even pages: chapter title
\fancyhead[CO]{\textit\leftmark} % odd pages: book title
%%%%%%%%%%%%Pas de N° de chapitres%%%%%%%%%%%%%%%%%%%%
\usepackage{titlesec}
\titleformat{\chapter}[display]%
{\centering\Large\bfseries}% format of chapter
{\large\normalfont\MakeUppercase{\chaptertitlename}\enskip\thechapter}% format of the label
{.5\baselineskip}{} % space between the two
\titlespacing*{\chapter}{0pt}{25pt}{35pt} % spaces around \chapter{}, {left}{before}{after}
%\titleformat{\chapter}[display]
%{\normalfont\bfseries}{}{0pt}{\Huge}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%épigraphe%%%%%%%%%%%%
\makeatletter
\renewcommand{@chapapp}{}% Not necessary...
\newenvironment{chapquote}[2][2em]
{\setlength{@tempdima}{#1}%
\def\chapquote@author{#2}%
\parshape 1 @tempdima \dimexpr\textwidth-2@tempdima\relax%
\itshape}
{\par\normalfont\hfill---\
\chapquote@author\hspace{@tempdima}\par\bigskip\par\bigskip}
\makeatother
%%%%%%%%%%%%%Numérotation en chiffres arabes%%%%%%%%%%%%%%%%%%%
\makeatletter
\renewcommand\frontmatter{%
\cleardoublepage
@mainmatterfalse
%\pagenumbering{roman}% Don't reset
}
\renewcommand\mainmatter{%
\cleardoublepage
@mainmattertrue
%\pagenumbering{arabic}% Don't reset
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\begin{document}
\title{A title}
\author{A name}
\date{}
\maketitle
\renewcommand{\contentsname}{Sommaire}
\tableofcontents
\frontmatter
\mainmatter
\chapter[A chapter whose the title is short]{A chapter which has a very very very long title as you can see}
\lipsum
\chapter{A section which has also a very very very long title as you can see}
\lipsum
\backmatter
\chapter{Conclusion}
\end{document}
titlesec, is to load it with option[toctitles]. The optional argument ofchapterwill be used only in the headers (see §3.7 of the documentation). – Bernard Aug 12 '21 at 12:41tocloftfor the formatting of your table of contents. Anyway,titlesechas a companion package for that:titletoc. You should try to see first if it works with the default formatting. Also, another question: did you compile at least twice with this option? – Bernard Aug 12 '21 at 12:57toctitlesoptoin seems to work for sections, not chapters - see workaround at https://tex.stackexchange.com/questions/498592/table-of-contents-to-take-full-name-of-sections-while-header-and-footer-take-sho/498595#498595 . Alternatively, use\chaptermark:\chapter{VERY VERY VERY VERY LONG TITLE} \chaptermark{SHORT TITLE}- see https://tex.stackexchange.com/questions/216144/classicthesis-short-title-not-appear-in-table-of-content-in-lyx – Cicada Aug 13 '21 at 12:36