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 !

1 Answer 1

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.

3
  • Hello ! Thank you for your help. But it seems that your solution doesn't work with a two-columns toc.
    – Guliup
    Commented Apr 17, 2020 at 9:40
  • @Guliup it does if you use package multitoc (see edited answer, inspired by this blogpost). I hope that works for you
    – steve
    Commented Apr 17, 2020 at 10:11
  • @Guliup I suspect this question is also related to this other question of yours; see my answer there for more details.
    – steve
    Commented Apr 17, 2020 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .