Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

(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?

share|improve this question
add comment

1 Answer 1

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!

share|improve this answer
1  
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.) –  barbara beeton Jul 2 '12 at 17:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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