Graphics, Figures & Tables ⇒ Add table of contents to table of contents
Add table of contents to table of contents
I want have the table of contents actually appear as an entry in the table of contents.
I've tried \addcontentsline{toc}{chapter}{Contents} with no joy.
I'm sorry if this is a ridiculous question, but have mercy I'm a newbie...
P
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Add table of contents to table of contents
you forgot to mention the document class that you are using (crucial information not to be forgotten again). The tocbibind package could be useful for you:
Code: Select all
\documentclass{book}
\usepackage{tocbibind}
\begin{document}
\tableofcontents
\end{document}
Re: Add table of contents to table of contents
Add table of contents to table of contents
Code: Select all
\documentclass[twoside]{tcd-phd-thesis}
\usepackage[breaklinks]{hyperref}
\usepackage{cite}
\usepackage[style=altlist,
nonumberlist,
acronym,
toc]
{glossaries}
\input{acronyms}
\makeglossaries
\begin{document}
\input{title}
\frontmatter
\cleardoublepage
\input{declaration}
\addcontentsline{toc}{chapter}{Declaration}
\cleardoublepage
\input{summary}
\addcontentsline{toc}{chapter}{Summary}
\cleardoublepage
\input{acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}
\mainmatter
\renewcommand{\contentsname}{Table of Contents}
\tableofcontents
\renewcommand{\acronymname}{Abbreviations}
\printglossaries
\input introduction
\input crawling_and_classification
\input indexing
\input open_source_tools
\input research
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Bibliography}
\bibliographystyle{apalike}
\bibliography{references}
\end{document}
Add table of contents to table of contents
When I tried the line above it just added an entry "Contents" to the toc, but it wasn't the actual table of contents - it listed the wrong page, and when clicking on the link it went to a blank page rather the the start of the toc.frabjous wrote:Could you be a little more specific about your lack of joy? What happened when you tried that line?
Add table of contents to table of contents
Code: Select all
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Acknowledgements}
\input{acknowledgements}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Contents}
\renewcommand{\contentsname}{Table of Contents}
\tableofcontents
\mainmatter
Code: Select all
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Acknowledgements}
\input{acknowledgements}
\mainmatter
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Contents}
\renewcommand{\contentsname}{Table of Contents}
\tableofcontents
Add table of contents to table of contents
I went with your first code example - and it works! - it think it was the addition of the \phantomsection that did it, many thanks!frabjous wrote:You don't want \mainmatter to be in between this, and where you actually insert the table of contents. You'll also need a \cleardoublepage and \phantomsection before it. Depending on what kind of page numbering you want for the TOC, you want either:
orCode: Select all
\cleardoublepage \phantomsection \addcontentsline{toc}{chapter}{Acknowledgements} \input{acknowledgements} \cleardoublepage \phantomsection \addcontentsline{toc}{chapter}{Contents} \renewcommand{\contentsname}{Table of Contents} \tableofcontents \mainmatter
I can't test though, since a MWE is useless if it's using input commands to call documents we don't have access to.Code: Select all
\cleardoublepage \phantomsection \addcontentsline{toc}{chapter}{Acknowledgements} \input{acknowledgements} \mainmatter \cleardoublepage \phantomsection \addcontentsline{toc}{chapter}{Contents} \renewcommand{\contentsname}{Table of Contents} \tableofcontents
Peter.