0

I am trying to add a subtitle to toc's title.

Here is what I have done so far :

\documentclass[12pt,twoside]{book}
\usepackage{fontspec}
\usepackage{xltabular}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[newparttoc]{titlesec}%
\usepackage{titletoc}
\usepackage{supertabular}


% **************************
% Change toc's title ("Contents")
% **************************

\renewcommand{\contentsname}{\begin{center}
    \fontsize{25}{12}\selectfont My new title
\end{center}
}


% **************************
% Two column's toc :
% **************************

\usepackage{pgffor}

\makeatletter
\newcommand{\twocolumntoc}{%
  \chapter*{\contentsname
    \@mkboth{%
      \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{toc}%
}
\makeatother

I have tried doing this :

\renewcommand{\contentsname}{\begin{center}
    \fontsize{25}{12}\selectfont My new title \\ My subtitle
\end{center}
}

But my toc won't generate after that.

Thank you all for your help !

Johannes_B
  • 24,235
  • 10
  • 93
  • 248
Guliup
  • 96

1 Answers1

1

Using the tocloft package, you can put the \contentsname in a \parbox{\linewidth}{}, and then horizontally center with \centerline{} and break lines with ~\\ (why the ~?):

\documentclass{book}
\usepackage{tocloft}

% Uncomment the two lines below if you want a two-column ToC
%\usepackage[toc]{multitoc}
%\renewcommand*{\multicolumntoc}{2}

\renewcommand{\contentsname}{%
\parbox{\linewidth}{%
\centerline{Nice ToC}~\\[-1em]%
\centerline{\Large Some Subtitle}%
}}

\begin{document}

    \tableofcontents

    \section{Some Section}\section{Some Other Section}

\end{document}

Output:

screenshot

Now, what exactly's going on behind the scenes here, I don't know. But hopefully this still helps.

steve
  • 2,154