How can I add abstract to table of contents
Within report
, the abstract
environment is set using within a titlepage
, which defaults to putting the content on its own page. So you have to insert the ToC-writing piece using some patching (supported via etoolbox
).
\documentclass{report}
\usepackage[paper=a6paper]{geometry}% Just for this example
\usepackage{lipsum,etoolbox}% http://ctan.org/pkg/{lipsum,etoolbox}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\abstract}{\titlepage}{\titlepage% Insert ToC-writing after starting a titlepage
\addcontentsline{toc}{chapter}{Abstract}}{}{}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\begin{document}
\title{My Title}
\author{My Name}
\maketitle
\tableofcontents
\begin{abstract}
\lipsum[1]
\end{abstract}
\chapter{A chapter}
\end{document}
I've written the ToC-entry as a chapter
, just so the formatting seems consistent
\addcontentsline{toc}{chapter}{Abstract}
However, that can be changed to whatever you like.
Another way would be to write the ToC-entry within the abstract
environment - this ensures that it falls on the same page as the Abstract:
\begin{abstract}
\addcontentsline{toc}{chapter}{Abstract}
...
\end{abstract}
As abstract is neither a chapter nor a section so for abstract you should use
\begin{abstract}....\end{abstract}
as shown below:
\begin{abstract}
\addcontentsline{toc}{chapter}{abstract}
abstract content here
\end{abstract}
Line below is used to show abstract in list of contents:
\addcontentsline{toc}{chapter}{abstract}