2

This is the code I'm trying :

\documentclass{book}

\begin{document}

\chapter{Chapter one}

\chapter*{\emph{Chapter two}}
\addcontentsline{toc}{chapter}{\setlength\parindent{24pt}Chapter two\\ Explanations on Chapter two}

\tableofcontents

\end{document} 

The problem with \\ is that the new line is indented, I tried \linebreak, but it wont take it

  • why have you \setlength\parindent{24pt} there? there never needs to be any formatting commands in that argument, the whole point of the previous {chapter} argument is that that specifies whatver format you want for chapter level entries. – David Carlisle Nov 10 '17 at 12:28
  • When I asked how to add a title for \chapter*{} in toc someone gave me that line. (it's usually why I have strange code sometimes and you ask me why it's there). I will delete it and see if it's ok. – alfred Nov 10 '17 at 12:37
1

Here is a suggestion using package tocbasic and declaring a new tocentry:

\documentclass{book}

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  level=0,
  beforeskip=1em plus 1pt,
  indent=0pt,
  numwidth=0pt,
  linefill=\hfill,
  entryformat=\textbf,
  pagenumberformat=\textbf,
]{tocline}{bchap}

\begin{document}
\chapter{Chapter one}

\chapter*{\emph{Chapter two}}
\addcontentsline{toc}{bchap}{Chapter two\\Explanations on Chapter two}

\chapter{Chapter three}
\tableofcontents
\end{document}

Result:

enter image description here


If there should be dots between the chapter entries and the page numbers, you can use

\documentclass{book}

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  level=0,
  beforeskip=1em plus 1pt,
  indent=0pt,
  numwidth=0pt,
  entryformat=\textbf,
  pagenumberformat=\textbf,
]{tocline}{bchap}
\DeclareTOCStyleEntry[
  linefill=\TOCLineLeaderFill,
  pagenumberformat=\textbf
]{tocline}{chapter}

\begin{document}
\chapter{Chapter one}

\chapter*{\emph{Chapter two}}
\addcontentsline{toc}{bchap}{Chapter two\\Explanations on Chapter two}

\chapter{Chapter three}
\tableofcontents
\end{document}

Result:

enter image description here

  • how can I add dots to the toc in this case ? – alfred Nov 10 '17 at 16:04
  • @alfred See my updated answer. – esdd Nov 10 '17 at 16:13
  • For some reason in my document where there are 13 chapters, the last \chapter*{} is added at the end below the frame instead of creating a new page. – alfred Nov 10 '17 at 17:46
1

Here is an option with tocloft:

enter image description here

\documentclass{book}

\usepackage{tocloft}
\renewcommand{\cftchapdotsep}{5}% Add dots for \chapters

\begin{document}

\tableofcontents

\chapter{Chapter one}

\chapter*{\emph{Chapter two}}
\addcontentsline{toc}{chapter}{%
  Chapter two \\ \protect\hspace*{-\cftchapnumwidth}Explanations on Chapter two}

\tableofcontents

\end{document}
  • This solution also works fine. – alfred Nov 10 '17 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.