18

I followed Mike's solution from my first question:

Roman numeral page numbering

My next question is how to add entries (for the abstract and acknowledgements pages) into the table of contents.

3 Answers 3

18

Assuming that the abstract and acknowledgement contents is typeset using a \chapter*{...}, you could do the following:

\chapter*{Abstract}%
\addcontentsline{toc}{chapter}{\numberline{}Abstract}%
...
\chapter*{Acknowledgements}%
\addcontentsline{toc}{chapter}{\numberline{}Acknowledgements}%
...

This will add a chapter-level (chapter) entry to the table of contents (toc) without a chapter number (\numberline{}).

4
  • what do i do if i am adding abstract.tex to my main thesis.tex file ? in this case how do i add page numbering in roman ?
    – creative
    Commented Mar 21, 2016 at 7:40
  • @Hirak: Either \renewcommand{\thepage}{\roman{page}} or \pagenumbering{roman}. The latter also resets the page counter. However, I'm not sure whether this is what you're asking about.
    – Werner
    Commented Mar 21, 2016 at 15:28
  • While this is the accepted answer and technically correct, the hyperlinks in the TOC will not go to the correct location without \phantomsection. See Stefan's answer for a complete solution.
    – jds
    Commented May 13, 2021 at 15:33
  • @gwg: Correct, if you're using hyperref (which there is no mention of in the OP).
    – Werner
    Commented May 13, 2021 at 15:49
15

While you can manually add an entry to the TOC by \addtocontents or \addcontentsline, the order of commands can be important, especially

  • if you use hyperref, to get the hyperlink above the heading, not below
  • or if you add a section to the TOC, which is done by a macro but several pages long, such as by \listoffigures, \listoftables or \bibliography. A wrong order would add the last page to the TOC

So

  • use \addtocontents or \addcontentsline before \chapter* of \listof...
  • ensure the required page break before \addtocontents or \addcontentsline
  • for hyperref, add an anchor for the target

    \cleardoublepage
    \phantomsection
    \addcontentsline{toc}{chapter}{Abstract}
    \chapter*{Abstract}
    

If you need that several times, you could define a macro for it.

Regarding the commands:

  • \cleardoublepage ends the page, prints out remaining floats if necessary, and ensures that the following text starts on a right hand page, as chapters in books commonly do, if in twoside mode. \clearpage, in contrast, would start the new page on a left or a right side.
  • \phantomsection is a command of the hyperref package, which creates an anchor at this location, similar to \hypertarge, which can be referred to - \addcontentsline does it implicitely. Without \phantomsection, \addcontentsline would refer to the previous anchor which could be undesired.

The package tocbibind makes putting commonly added chapters/sections (bibliography, TOC, index) to the TOC easier. It's integrated in the memoir class, while KOMA-Script classes support this purpose by class options such as bibliography=totoc.

3
  • You've used \cleardoublepage, \phantomsection - could you be more specific about those two ? Commented Feb 1, 2012 at 18:47
  • 1
    @GrzegorzWierzowiecki I updated my answer and explained the commands.
    – Stefan Kottwitz
    Commented Feb 1, 2012 at 19:04
  • Thank you, it's educative piece of tex code for learning latex :). Commented Feb 1, 2012 at 19:11
7

Instead of tinkering with \cleardoublepage, \phantomsection, and \addcontentsline, I suggest to

  • use \chapter (the non-starred version) also for the Abstract and Acknowledgements,

  • set the secnumdepth counter to -2 (i.e., no sectioning level is numbered) before the Abstract,

  • resetsecnumdepth to 2 (default for the report class) before the first proper chapter.

Works also with hyperref.

\documentclass{report}

\usepackage{hyperref}

\begin{document}

\tableofcontents

\setcounter{secnumdepth}{-2}% default for "report" is 2

\chapter{Abstract}

\chapter{Acknowledgements}

\setcounter{secnumdepth}{2}

\chapter{First}

\end{document}

enter image description here

You must log in to answer this question.

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