# How to rename chapters in Table Of Content in French document?

My document is in French. I added appendices to the document, appendices use \chapter{}, hence I would like that these chapters to be names "Annexe" (which is the French word for "Appendice" in table of content.

But I my current document I don't manage to do that.

I expect it has to do with the cutomization of my table of content. Which I want to keep as well.

working example:

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

\usepackage[french]{babel}

\usepackage{hyperref}
\hypersetup{
filecolor=magenta,
urlcolor=cyan
}
\usepackage{lastpage}
\usepackage{lipsum}

\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{Chapitre }

\usepackage{datetime}

\usepackage[toc]{appendix}
\begin{document}

\tableofcontents

\part{main}
\chapter{Lorem ipsum}
\lipsum[1-2]

\renewcommand{\appendixname}{Annexe}
\renewcommand{\appendixtocname}{Annexe}
\renewcommand{\appendixpagename}{Annexe}

\part{appendices}
\begin{appendices}
\chapter{Some appendice}
\lipsum[1-2]
\chapter{Some appendice}
\lipsum[1-2]
\end{appendices}

\end{document}


I know that this question has been closed and pointing to \chaptername is used even for appendix chapters in ToC but that didn't help me at all. Another answer is marked as solutions under this question. That one helped me solve the issue.

• See the babel manual you need to add your name changes to the language it self somthing like \addto\captionsfrench{.....} where you supply the ... part Jun 15 '21 at 8:40
• Does this answer your question? \chaptername is used even for appendix chapters in ToC Jun 15 '21 at 9:02
• Your question has an answer here: tex.stackexchange.com/q/56839/118712 (BTW: The approach from daleif will not work with the renewcommand of cftchappresnum.) Jun 15 '21 at 9:03
• Unrelated: It is generally advisable to load the hyperref package LAST, unless another package specificially and explicitly requires being loaded after hyperref. Jun 15 '21 at 9:05
• Yet another question "closed" as "Already has an answer" ... then pointing to an answer that didn't help me solve the problem... I'm not sure how I should react... I have already marked an answer as solution in this case anyway...
– TTT
Jun 15 '21 at 22:37

You can tweak the \addcontentsline macro as it is done in the appendix package (when using the titletoc option).

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

\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{tocloft,calc}

% a command to tweak \addcontentsline for chapters
\newcommand{\chapitretocentry}{%
\def\tempa{##1}\def\tempb{toc}% store ##1 and toc in temp vars
\ifx\tempa\tempb % check if they are "equal"
\def\tempa{##2}\def\tempb{chapter}%
\ifx\tempa\tempb % check if ##2 is "equal" to chapter
% in the other cases, just apply the original \addcontentsline
\else
\oldacl{##1}{##2}{##3}%
\fi
\else
\oldacl{##1}{##2}{##3}%
\fi
}
}
\AtBeginDocument{\chapitretocentry} % invoke the command at the beginning

\usepackage{datetime}
\usepackage[titletoc]{appendix}
\usepackage[french]{babel}

\usepackage{hyperref}
\hypersetup{
filecolor=magenta,
urlcolor=cyan
}
\begin{document}

\tableofcontents

\part{main}
\chapter{Lorem ipsum}
\lipsum[1-2]

\renewcommand{\appendixname}{Annexe}
\renewcommand{\appendixtocname}{Annexes}
\renewcommand{\appendixpagename}{Annexe}

\part{Annexes}
\let\addcontentsline=\oldacl % reset the original def
\begin{appendices}
\chapter{Some appendice}
\lipsum[1-2]
\chapter{Some appendice}
\lipsum[1-2]
\end{appendices}

\end{document}


• This looks like it works when I copy your whole answer, but I tried to "inject it" in my example and it didn't work... trying again...
– TTT
Jun 15 '21 at 9:32
• Ok, got it working. Currently I'm half-lost in what it does but it works, thanks.
– TTT
Jun 15 '21 at 9:41
– NBur
Jun 15 '21 at 9:52

You have to tell LaTeX that when processing the appendices in the TOC, \chaptername should become \appendixname.

The setting will disappear as soon as the TOC has been typeset, because this happens inside a group.

\documentclass[a4paper,french,oneside,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\usepackage{hyperref}
\hypersetup{
filecolor=magenta,
urlcolor=cyan
}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{tocloft,calc}
\usepackage{datetime}
\usepackage[toc]{appendix}

\renewcommand{\cftchappresnum}{\chaptername\ }
}

\begin{document}

\tableofcontents

\part{main}

\chapter{Lorem ipsum}

\lipsum[1-2]

\part{appendices}
\begin{appendices}

\chapter{Some appendice}

\lipsum[1-2]

\chapter{Some appendice}

\lipsum[1-2]

\end{appendices}

\end{document}