0

I am writing my thesis in Latex and a have problem when I add all sections together, I cannot have them in the order I wish and appear in the table of contents. Is there a trick to this? I am fairly new to this so any hints or corrections would be great.

I would like to have a table of contents like this:

Abstract

lists of tables etc (not numbered)


Chapters (numbered)


Appendix (not numbered)


Bibliography (not numbered)

I can have all sections print in this order i.e. the pdf compiles in the right order but the bibliography does not appear in the table of contents. If I switch the code around so that the bibliography is printed before the appendix then all appear in the table of contents.

Here is a MWE. Just switch the bibliography to before and after the appendix to see the results.

\documentclass[12pt,a4paper,hidelinks,twoside]{report}
\raggedbottom
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[greek,spanish,english]{babel}
\usepackage{textgreek}
\usepackage[version=3]{mhchem}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}
\usepackage{amsmath, amsfonts, amssymb, pifont, float, color, url}
\usepackage[pdftex]{graphicx}
\usepackage[style=nature,backend=biber,sorting=none]{biblatex}
\addbibresource{references.bib}
\usepackage[pdftex, plainpages=false, pdfpagelabels, bookmarks=true]{hyperref}
\usepackage{fancyhdr}
\usepackage[center,font={it,small},skip=5pt]{caption}
\usepackage{parskip}
\usepackage{tikz}
\usepackage{afterpage}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{lscape}
\usepackage{textcomp}
\usepackage{listings}
\lstset{basicstyle=\scriptsize\ttfamily,
  frame=tb,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  commentstyle=\color{red},
  keywordstyle=\color{blue}
}
\usepackage{datetime}
\usepackage{longtable}
\usepackage{lipsum}
\usepackage{dcolumn}
\newcolumntype{d}{D{.}{.}{2}}
\usepackage{makeidx}
\makeindex
\usepackage{nomencl}
\makenomenclature 
\usepackage{tocloft}
\usepackage{soul}
\pretolerance=10000 %% prevents words from being hyphenated when the line splits.
\usepackage{todonotes}
\pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>} %correct viewing in adobe reader
\DeclareUnicodeCharacter{FB01}{fi}
\DeclareUnicodeCharacter{00A0}{~}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Use packages above and set them up %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\pagestyle{fancy} %\pagestyle{plain} to have just page numbers restate fancy afterwards or all pages from that point will be plain.
\fancyhf{}
\cfoot{\thepage}
\graphicspath{ {Pictures/} }
\renewcommand{\headrulewidth}{0.4pt}
\newcommand{\etal}{\textit{et al. }}
\renewcommand{\nomname}{List of Abbreviations}

%% an equation caption solution from the web by Heiko Oberdiek
\newcommand{\capequ}[1]{\begin{center} #1 \end{center}}
\usepackage{aliascnt}
\newaliascnt{eqfloat}{equation}
\newfloat{eqfloat}{h}{eqflts}
\floatname{eqfloat}{Equation}

\newcommand*{\ORGeqfloat}{}
\let\ORGeqfloat\eqfloat
\def\eqfloat{%
  \let\ORIGINALcaption\caption
  \def\caption{%
    \addtocounter{equation}{-1}%
    \ORIGINALcaption
  }%
  \ORGeqfloat
}

\newenvironment{tightcenter}{%
  \setlength\topsep{0pt}
  \setlength\parskip{0pt}
  \begin{center}
}{%
  \end{center}
}

\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\setlength{\cftmyequationsnumwidth}{2.5em}% Width of equation number in List of Equations

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% Document variables above and user defined commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% BEGIN THE DOCUMENT %
\sloppy
\color{black}
\begin{document}
\begin{titlepage}
    \begin{center}
        \vspace*{0.25cm}

        \Huge
        \textbf{Thesis}

        \vspace{0.5cm}
        %\LARGE
        %Thesis Subtitle

        \vspace{1.0cm}
        A logo
        \vspace{1.0cm}

        \textbf{}

        \normalsize This thesis is submitted in partial fulfilment for the degree of\\ Doctor of Philosophy\\ 
        \vspace{0.3cm}
        \today
        %%\vspace{0.5cm}

        \Large
        School of Chemistry\\
        University of St Andrews\\


    \end{center}
\end{titlepage}
\pagestyle{headings}
\setcounter{page}{1}
\pagenumbering{roman}

\addcontentsline{toc}{chapter}{\protect\numberline{}Contents}\tableofcontents

\newpage

\chapter*{\centerline{Abstract}}\label{Abstract}
\addcontentsline{toc}{chapter}{\protect\numberline{}Abstract}
In this thesis
\newpage

\chapter*{\centerline{Dedication}}\label{dedication}
\addcontentsline{toc}{chapter}{\protect\numberline{}Dedication} 
\begin{center}
\large
\vspace*{\fill}
For my Family and Friends
\vspace*{\fill}
\end{center}
\newpage

\chapter*{\centerline{Declaration}}\label{Declaration}
\addcontentsline{toc}{chapter}{\protect\numberline{}Declaration} 
........... Declares that ......  
\newpage

\chapter*{\centerline{Acknowledgements}}\label{Acknowledgements}
\addcontentsline{toc}{chapter}{\protect\numberline{}Acknowledgements}
I would like to thank ......
\newpage

\chapter*{\centerline{Publications}}\label{Publications}
\addcontentsline{toc}{chapter}{\protect\numberline{}Publications}
Publication 1 ......
\newpage

\clearpage
\phantomsection\addcontentsline{toc}{chapter}{\protect\numberline{}List of Figures}
\listoffigures
\newpage

\clearpage
\phantomsection\addcontentsline{toc}{chapter}{\protect\numberline{}List of Tables}
\listoftables
\newpage

\clearpage
\phantomsection\addcontentsline{toc}{chapter}{\protect\numberline{}List of Equations}
\listofmyequations
\newpage

\printnomenclature[5cm]
\addcontentsline{toc}{chapter}{\protect\numberline{}List of Abbreviations}
\newpage

\thispagestyle{plain}
\begin{center}
\large
\vspace*{\fill}
\textit{Quote}
\vspace*{\fill}
\end{center}

\newpage

\setcounter{page}{1}
\pagenumbering{arabic}

\chapter{Introduction}
\label{chap:introduction}
\input{Chapters/Introduction}

\chapter{Theory and Methods}
\label{chap:Theory and Methods}
\input{Chapters/Chapter_2}

%\cleardoublepage
%\phantomsection
%\addcontentsline{toc}{chapter}{\protect\numberline{}Bibliography}
%\printbibliography

\appendix
\clearpage
\phantomsection\addcontentsline{toc}{chapter}{\protect\numberline{}Appendices}  
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\input{chapters/appendix}

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\protect\numberline{}Bibliography}
\printbibliography


%\newpage


\end{document}

After some quick changes and a useful comment below, this can be fixed simply by adding \addtocontents{toc}{\protect\setcounter{tocdepth}{0}} before the bibliography is printed.

  • 1
    You need to give some input. Run the Code as is, there is no bibliography as nothing is citet. Why do you set the counter tocdepth to minus one? – Johannes_B Oct 1 '14 at 13:00
  • Hi Johannes, The problem is not printing the bibliography if one is provided it is printed in the pdf, the issue is having the bibliography listed in the table of contents. Using the code as is a Chapter_2, Introduction and appendix file is additionally required to see the issue. The $tocdepth$ is set to -1 so that the only line added to the table of contents is appendix. – James Oct 1 '14 at 13:11
  • @Johannes_B, thanks for pointing out the tocdepth, I hadn't considered it before. I have fixed the code by resetting the tocdepth to 0. Thanks for your comment. – James Oct 1 '14 at 13:22
  • A little hint, when something seems strange and you can't figure out the reason. Try to boil down the code by commenting out parts of the document. At the end, there are only a few lines left and the reason gets obvious. This is called making a Minimal working example. – Johannes_B Oct 1 '14 at 13:24
  • 1
    @James Can you make that final paragraph into a proper answer? – Joseph Wright Nov 1 '14 at 23:00
2

Sorry for answering my own question after a pointer from Johannes_B. I have fixed the code by resetting the tocdepth to 0. Thanks Johannes_B for your comment. The changes is,

\appendix
\clearpage
\phantomsection\addcontentsline{toc}{chapter}{\protect\numberline{}Appendices}  
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\input{chapters/appendix}

\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\protect\numberline{}Bibliography}
\printbibliography
\end{Document}
  • I think it is perfectly fine to answer your own question :) – Zero3 Dec 17 '15 at 5:36

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.