13

I believe it is correct to add the abstract to my TOC but I don't know how. This Answer talking about adding the abstract chapter to the TOC. I'm using Lyx and if I output to .tex file this is what I see.

\documentclass[english]{report}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{babel}

\makeatother

\usepackage{babel}
\begin{document}

\title{My Title}


\author{My Name}

\maketitle
\tableofcontents{}
\begin{abstract} %% This isn't a chapter!

My Abstract isn't a chapter.


Abstract is created with begin{abstract} unlike in questions I LINKED to and have been marked as a duplicate. In that example abstract is a chapter.
Does this affect the correct use of getting my Abstract into the TOC?


Assuming that the abstract and acknowledgement contents is typeset using a \chapter*{...},

Well it isn't, So what do I do in my case?

2
  • Welcome to the site! \addcontentsline will be your friend here :) for example, \addcontentsline{toc}{section}{Abstract} – cmhughes Mar 11 '14 at 22:27
  • Thank you for responding. I think its a bit silly that I have been linked to the question, I had already posted in my own question. So I exchange Chapter with section? because my abstract isn't labeled as a chapter is is identified by begin{Abstract}. – Another Compiler Error Mar 12 '14 at 15:09
12

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).

enter image description here

\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}
2
  • I'm gonna have to read this a couple a times, I'll come back to this in bit. Thank you for your reply. – Another Compiler Error Mar 15 '14 at 16:11
  • 2
    Thanks for the \addcontentsline command. It works like a charm! – Md. Minhazul Haque Jan 1 '16 at 19:17
7

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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