I'm using the plain book style. The problem is that I would like to see in the table of contents the long names of chapters, sections and subsections:

\chapter[shortname]{longname}
\section[shortname]{longmane}


To push LaTeX to use the long names of the chapters (or parts) I can modify the line

\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%


in the book.cls file and replace the number of the argument to #2

But there is no \addcontentsline{toc}... lines in the *.sty file for sections, subsection etc.

I have read the previous topics on similar problems, such as

and the problem itself is solved at the moment, but how the format of \addcontentsline commands is defined for sections and subsections in LaTeX files by default? I can not find it!

• Since the only purpose of the short title is to be put in the table of contents, why are you even creating them? Jul 15 '16 at 12:45

The \usepackage[toctitles]{titlesec} package will place the long section titles in the table of contents.

As for the chapter, in case you just need the short version for the header, set it separately.

\documentclass{book}

\usepackage{titletoc}
\usepackage[toctitles]{titlesec}

\begin{document}

\tableofcontents

\chapter{Longchap}
\chaptermark{shortchap}

\section[short]{long}

\end{document}


• Wow :) Thanks allot! It works fine. But could I somehow edit the default style? To reach the same effect? Jul 15 '16 at 13:16
• @DmitryZlenko Why do you want to do this? You could read the source of the titlesec package and see how they do it. But please remember: to adhere the latex licence, don't just modify book.cls but rename it. Jul 15 '16 at 13:41
• Yes. I already has my own one cls :) Thanks for the advice. I not need it, I just want to understand. Jul 15 '16 at 15:25