wspr / herries-press

A collection of LaTeX packages by Peter Wilson
http://wspr.github.com/herries-press/
29 stars 5 forks source link

[Tocloft] Can't change title of tableofcontents #41

Closed Doc73 closed 4 years ago

Doc73 commented 4 years ago

Dear Dev, with this MWE I'd expect to have the word Sommario instead of Indice as title of table of contents, but this is not working anymore. I don't know when this problem appeared.

% !TeX TS-program = xelatex
% !TeX spellcheck = it_IT
% !TeX encoding = UTF-8
% !TeX root = main.tex
% !BIB TS-program = biber

\documentclass[11pt,b5paper]{book}

\usepackage{polyglossia}
\setmainlanguage[babelshorthands=true]{italian}

\usepackage[titles]{tocloft}
\renewcommand{\contentsname}{Sommario}

\usepackage{lipsum}

\begin{document}
\tableofcontents

\chapter{kjlkklj}
\section{lkjlklkj}
\lipsum
\section{lkjlklkj}
\lipsum
\section{lkjlklkj}
\lipsum
\section{lkjlklkj}
\lipsum

\chapter{kjlkklj}
\section{lkjlklkj}
\lipsum
\section{lkjlklkj}
\lipsum
\section{lkjlklkj}
\lipsum
\section{lkjlklkj}
\lipsum
\end{document}

Best regards, DC

FrankMittelbach commented 4 years ago

you blame the wrong package :-) this is polyglossia that prevents it. But I doubt that it has ever worked. According to the polyglossia manual

\gappto\captionsitalian{\renewcommand{\contentsname}{Sommario}}

changes the captions in your document.

\captionsitalian is executed at begin document so therefore it undoes your change. Thus a version that would have also worked is to move the redef after begin document, but this only works if you don'tt switch languages, so the right approach with polyglossia is the above.

Doc73 commented 4 years ago

Perfect! Thank you so much! Your suggestion solves this issue!

BTW, latest versions of Polyglossia added so many features that broke compatibility with other packages. It's not the first time I've hit my head on problems related to polyglossia and it's not the first time that ... I blame the wrong package! :laughing:

Best regards and thank you very much again!