0

As How to hide the table of content's heading? I am trying to remove the table of contents title in the book class. For this, like @Thorsten:

\newcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
   \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{%
           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }

I delete the \chapter*{} part and renewcommand instead of newcommand

But it doesn't work, the title is still displayed.

Any ideas for removing the title from the book class?

Arnaud
  • 35
  • did you replace \chapter*{\contentsname \@mkboth{% \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% with some thing like \newpage? can you please add MWE? let us know if you're using package like etoc or titletoc ... – touhami Feb 14 '20 at 13:30

2 Answers2

3

The below tags works fine for me:

\documentclass{book}

\makeatletter
\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
   \else
      \@restonecolfalse
    \fi
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }
\makeatother

\begin{document}
\tableofcontents
\chapter{Test}


\end{document}
MadyYuvi
  • 13,693
  • I checked with your code. The problem comes from the tocloft package. Indeed, I seek to make appear the titles of section in sf in the toc. When I remove this package the title of the toc is effectively deleted, but I no longer have my section titles in sf ! – Arnaud Feb 14 '20 at 13:57
  • @Arnaud Until your comment there has been no mention of tocloft. It would really help if you provided an MWE (from \documentclass to \end{document}) that exhibited your problem. We can sometimes be mind readers but usually never try. Did you try \renewcommand{\contentsname}{} ? – Peter Wilson Feb 14 '20 at 18:04
2

Here is an example of mind reading.

% tocnameprob.tex  SE 528429 remove toc title

\documentclass{book}
%\usepackage{tocloft} % don't need this to eliminate ToC title

\renewcommand{\contentsname}{} % blank ToC title

\begin{document}
\tableofcontents
\chapter{One}
\section{One}
\end{document}

Read the tocloft documentation 2.2 Changing the titles which talks about the general \contentsname and other \...name commands.

GOM

Peter Wilson
  • 28,066
  • sorry for forgetting the MWE. By following the recommended documentation it works:

    \usepackage[titles]{tocloft} (I forgot the option titles). I will try to look better next time before posting. Thank you so much.

    – Arnaud Feb 14 '20 at 19:19