My document has a table of content in it. As i found out, after inserting one (\tableofcontents
) LaTeX does a \clearpage
by default.
A method to ignore \clearpage
is the command \let\clearpage\relax
, witch ignores it till the end of the document. Although i have no other command in my doc, my last page got erased. So i want to reactive \clearpage
right after the toc was generated.
I am searching for something like:
\let\clearpage\relax
\tableofcontents
\*reactive it*
One try to do it with \begingroup
failed.
\begingroup
\let\clearpage\relax
\tableofcontents
\endgroup
Any ideas?
Best Answer
At least with the document class
book
, quick testing suggests that\tableofcontents
doesn't insert a\clearpage
, but\chapter
does. Thus, you have to put your group with\let\clearpage\relax
around the first\chapter
command (or whatever you have that's similar) after your\tableofcontents
. The following example, for instance, typesets on one page:The old answer, which answers the asked question but doesn't solve the problem (and anyway, you should usually use
\begingroup
…\endgroup
instead).You can save and restore
\clearpage
:\let
just defines a command to be a duplicate of an existing one, so:\let\oldclearpage\clearpage
makes\oldclearpage
equivalent to\clearpage
.\let\clearpage\relax
makes\clearpage
equivalent to\relax
, which is a do-nothing command.\tableofcontents
runs, with its\clearpage
s doing nothing.\let\clearpage\oldclearpage
makes\clearpage
equivalent to\oldclearpage
, which is equivalent to the original\clearpage
.