2

(NB: not the same question as How to remove “Contents” line from table of contents [closed])

Please consider the following MWE, compiled with pdflatex test.tex:

\documentclass[twoside,a4paper]{book}

\begin{document}

\section{TOC}

\tableofcontents

\cleardoublepage

\section{Sect 1}

\section{Sect 2}

\section{Sect 3}

\end{document}

This gives me:

  • pg 1: "0.1 TOC" heading
  • pg 2: blank
  • pg 3: "Contents" heading (+ toc)
  • pg 4: blank
  • pg 5: "0.2 Sect 1"; "0.3 Sect 2" and "0.4 Sect 3" (as expected)

Now, what I would like to do, is have the heading for the table of contents set by a \section command (the \section{TOC}) - and I'd like the contents table to continue as a paragraph would continue after a \section; or - my expected result would be:

  • pg 1: "0.1 TOC" heading (+ toc)
  • pg 2: blank
  • pg 3: "0.2 Sect 1"; "0.3 Sect 2" and "0.4 Sect 3" (as expected)

Obviously, in the example above, the \tableofcontents command first clears a double page - then inserts its own heading.

In other words, I'd like to suppress this heading inserted by \tableofcontents - however, not merely by \renewcommand\contentsname{}; because I'd also like to reclaim the vertical space that the toc heading usually claims (because it's actually a \chapter, I guess). How do I do that?

1 Answer 1

6

OK, I think I got it, thanks to answer #47241 How to remove the self-reference of the ToC from the ToC?:

... found that I can simply not use \tableofcontents, and instead use:

\makeatletter
\@starttoc{toc}
\makeatother

This doesn't create a section for the table of contents, so the problem goes away.

And indeed, seems to work for above MWE too:

\documentclass[twoside,a4paper]{book}

\begin{document}

\section{TOC}

% \tableofcontents
\makeatletter
\@starttoc{toc}
\makeatother

\cleardoublepage

\section{Sect 1}

\section{Sect 2}

\section{Sect 3}

\end{document}

Hope this is the way to do this :) Cheers!

1
  • 2
    if that works, go with it. i would probably have just used \renewcommand{\tableofcontents} and substituted the definition from article.cls, which uses \section* and also "does the right thing" for running heads . (comparing the code for \tableofcontents in book.cls and article.cls would be instructive though; even better, look at the file from which the class files were generated (classes.dtx in the source/latex/base branch of the tex live tree) where there are some comments about how the code is constructed.) Jul 2, 2012 at 17:52

You must log in to answer this question.

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