I am new to LaTeX and still on the steep learning curve. I am writing some documentation for a school project which has a bibliography and an index, using ShareLaTeX. I am having difficulty getting the index to show in the table of contents. This bare-bones code sample illustrates my problem.
\documentclass[a4paper]{report}
\usepackage{lipsum}
\usepackage{makeidx}
\makeindex
\begin{document}
\tableofcontents
\clearpage{\pagestyle{empty}\cleardoublepage}
\chapter{Introduction}
Some random \index{random} text \index{stuff!text} about fact \cite{fact}.
\clearpage{\pagestyle{empty}\cleardoublepage}
\chapter{Main}
\lipsum[6]
\clearpage{\pagestyle{empty}\cleardoublepage}
\addcontentsline{toc}{chapter}{Bibliography}
\begin{thebibliography}{9}
\bibitem{fact}
Factual stuff,
\emph{The types of Facts}. \\
XXXX, Publisher
\end{thebibliography}
\clearpage{\pagestyle{empty}\cleardoublepage} %Line 1
\addcontentsline{toc}{chapter}{Index} %Line 2
\printindex
\clearpage{\pagestyle{empty}\cleardoublepage}
\end{document}
If I change Line 1 to \clearpage{\pagestyle{empty}}
then the index shows up in the table of contents, however I want to ensure the index starts on an odd page. I have tried using the hyperref
package but doing this with the package:
\phantomsection
\addcontentsline{toc}{chapter}{Index}
\printindex
\clearpage{\pagestyle{empty}\cleardoublepage}
seems to have no effect. I've been looking all over the internet for an answer and I haven't found it. I would appreciate any help and if you need more info please let me know I will do my best :-)