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}

\begin{thebibliography}{9}
\bibitem{fact}
Factual stuff,
\emph{The types of Facts}. \\
XXXX, Publisher
\end{thebibliography}
\clearpage{\pagestyle{empty}\cleardoublepage} %Line 1

\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
\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 :-)

• Welcome to TeX.SX. Do you want all chapters to start on odd pages? – Torbjørn T. Nov 11 '13 at 21:56
• Thank you. Yes I do, I'd also like the index to start on an odd page (as long as that does not break typesetting convention. – neoDaedalus Nov 12 '13 at 22:24

To have chapters start on odd pages, you can add twoside,openright to the options of the class. This will change the layout to fit twosided printing, and cause all chapters to start on a right/recto/odd pages.

\usepackage[nottoc]{tocbibind}


to the preamble. nottoc means that the ToC itself does not end up in the ToC.

Also, I just noticed that the index does not seem to start on an odd page even with twoside,openright, add a \cleardoublepage just before \printindex to take care of that. Complete code example:

\documentclass[a4paper,openright,twoside]{report}

\usepackage{lipsum}
\usepackage{makeidx}
\usepackage[nottoc]{tocbibind}

\makeindex
\begin{document}
\tableofcontents

\chapter{Introduction}
Some random \index{random} text \index{stuff!text} about fact \cite{fact}.

\chapter{Main}
\lipsum[6]

\begin{thebibliography}{9}
\bibitem{fact}
Factual stuff,
\emph{The types of Facts}. \\
XXXX, Publisher
\end{thebibliography}

\cleardoublepage\printindex

\end{document}

• First of all, thank you very much for the twoside, openright tip, that's very efficient. Secondly, when I tried the source code you provided in ShareLaTeX,the index did not show up in the ToC. Should I try another distribution of LaTeX (I have a portable version of MikTeX as a backup)? – neoDaedalus Nov 12 '13 at 22:27
• @neoTexDalus Please try in MikTeX. It works fine for me with TeX Live 2013, while ShareLaTeX uses TeX Live 2011. I guess that there is something that has changed between the two versions. – Torbjørn T. Nov 12 '13 at 22:46
• @neoTexDalus By the way, I just noticed that the index does not start on an odd page even with twoside,openright, so add a \cleardoublepage just before \printindex to fix that (I've updated my answer.) – Torbjørn T. Nov 12 '13 at 22:56
• @ Torbjørn T. I tried it in TexLive 2013 (MikTex had some problem with missing fonts or something) and it worked just beautifully. I think maybe ShareLaTeX isn't doing either enough or misordered runs of pdfLaTeX, BibTex and MakeIndex. I'll keep using it and just compile using TexLive 2013 when I need to submit. As a note to you and others I found an emptypage package which combined with your suggestion is a more efficient way to get \clearpage{\pagestyle{empty}\cleardoublepage. – neoDaedalus Nov 14 '13 at 20:14
• @TorbjørnT. When I added the tocbibind package as per above, it threw the following error: Option clash for package tocbibind. – SuperAl Dec 14 '19 at 17:57