1

I have an issue with my table of contents. The document is structured as follows

\documentclass[a4paper,12pt,twoside]{report}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=3cm]{geometry}

\usepackage[super,comma,numbers,sort&compress]{natbib} %chapter cite + [] part gives 1-3 style instead of 1,2,3.
\usepackage[sectionbib]{chapterbib} % chapter cite
\usepackage{url} % web-citations anable (from bibtex document)
\usepackage{hyperref} %cross-ref

\usepackage{setspace} %line spacing package

\usepackage{graphicx} %pictures package
%\usepackage{subfig} %pic captions etc
\usepackage{subcaption}

\usepackage[tiny,md,sc]{titlesec} %title package

\usepackage{amsmath} %equations and formulas
\usepackage{wasysym} %math symbols
\usepackage{tabularx} %tables

\usepackage{lscape} %page orientation

\usepackage{longtable}
\usepackage{array}
\usepackage{ltxtable} 
\usepackage{siunitx}

\usepackage{tabu}
\usepackage{multirow}
\usepackage{float}


\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}

\usepackage[labelfont={bf,sf,footnotesize,singlespacing},
textfont={sf,footnotesize,singlespacing},
justification={justified,RaggedRight},
singlelinecheck=false,
margin=0pt,
figurewithin=chapter,
tablewithin=chapter]{caption}


\usepackage[titletoc]{appendix}


\tabulinesep = 1.5mm

%\titleformat{\chapter}[display]   
%{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}   
%\titlespacing*{\chapter}{0pt}{0pt}{40pt}

\setcounter{secnumdepth}{4}

\captionsetup[table]{
    labelsep = newline,
    justification=justified,
    singlelinecheck=false,%%%%%%% a single line is centered by default
    labelsep=colon,%%%%%%
    skip = \medskipamount}

\newcommand*\chem[1]{\ensuremath{\mathrm{#1}}} %command to do lower case index (i.e. in H2O 2 will be lower than H and O)
\newcommand{\sectionbreak}{\clearpage}
\newcommand\Tstrut{\rule{0pt}{2.6ex}}
\newcommand\Bstrut{\rule[-0.9ex]{0pt}{0pt}}

\sisetup{detect-shape, detect-weight}



\begin{document}
\include{titlepage}
\include{copyright}
\include{declaration}
\include{acknowledgements}
\include{abstract}
\include{nomenclature}
\tableofcontents
\listoffigures
\listoftables
\include{introduction}
\addcontentsline{toc}{chapter}{Introduction}
\include{chapter1}
\include{chapter2}
\include{chapter3}
\include{chapter4}
\include{chapter5}
\include{chapter6}

\appendix
\include{appendix3}
\include{appendix}
\include{appendix2}

\end{document}

Nomenclature and Introduction are introduced using \chapter*{}. In my table of contents I obviously want Introduction to come before Chapter 1, but this is what I have:

enter image description here

The document compiles with no errors, and I do have all necessary packages. I don't have a clue what might be wrong so would appreciate any help. Thank you!

EDIT - I've updated the code to contain full information.

6
  • 1
    Well, if I understand correctly, what you want to do is make the chapters before 1 appear without numbering. If you use the book class, your MWE is incomplete because you don't give us a preamble; you can use the following comands to do it without complications: \frontmatter and \mainmatter. – Aradnix Sep 10 '17 at 0:56
  • Sorry, I've fixed the preamble. I'm using "report" class. – Iuliia Elizarova Sep 10 '17 at 1:12
  • Welcome! In the file you include, Introduction.tex or whatever, write \chapter*{Introduction}\addcontentsline{toc}{chapter}{Introduction} so that the contents line is added on the first page of the introduction and not the first page of the next chapter, as it is at the moment. – cfr Sep 10 '17 at 1:12
  • Off-topic: you are loading hyperref far too early. It likes to be loaded late - last unless you're using something specifically requiring otherwise, such as cleveref. Also off-topic: tabu: rather you than me. I would not touch this with a barge pole. – cfr Sep 10 '17 at 1:14
  • 1
    @cfr I've deleted \addcontentsline{toc}{chapter}{Introd‌​uction} from preamble and added it to the chapter itself and it worked! Thank you very much! – Iuliia Elizarova Sep 10 '17 at 1:17
0

In the file you include, introduction.tex write

\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introd‌​uction}

so that the contents line is added on the first page of the introduction and not the first page of the next chapter, as it is at the moment. Delete if from you main file to avoid its being added twice, obviously.

When you say \include the file is read in and page breaks are added before anything else in the main file is read. So that's all done, then the \addcontentsline in the main file gets read, as the next chapter is about to be \included. So even if the order was correct, you'd get the wrong page number in the contents for the Introduction.

1

I think you can solve it easily in this way:

\documentclass[a4paper,12pt,openany]{book} %instead of report and the same result    

\begin{document}
\frontmatter
\include{titlepage}
\include{copyright}
\include{declaration}
\include{acknowledgements}
\include{abstract}
\include{nomenclature}
\tableofcontents
\listoffigures
\listoftables
\include{introduction}
\mainmatter
\include{chapter1}
\include{chapter2}
\include{chapter3}
\include{chapter4}
\include{chapter5}
\include{chapter6}

\appendix
\backmatter
\include{appendix3}
\include{appendix}
\include{appendix2}

\end{document}

With the book class and similar (e.g. memoir, scrbook, etc.) you can make use of the commands \frontmatter, \mainmatter, and \backmatter.

What you achieve with this trick is that everything that appears before your first chapter (or the part of the text you consider pertinent) is unnumbered without needing to add asterisks, but is correctly included in your table of contents, with small roman page numbering.

For the main content of the book use \mainmatter and get the default numbering and also you can add ' \backmatter for the final part.

4
  • Feel free to roll back my edit, but I don't think you said what you meant as the chapters aren't numbered in Roman - rather, the chapters are unnumbered and the page numbering is small Roman. – cfr Sep 10 '17 at 1:39
  • Of course not, but it's an additional piece of information, the trick of my answer is to be able to add the front matter without altering the numbering of the chapters. – Aradnix Sep 10 '17 at 1:44
  • 1
    I was just explaining why I edited. I knew what you meant, but somebody not familiar with this probably wouldn't. That was all. As I say, you can roll-back if you disagree. – cfr Sep 10 '17 at 1:49
  • I see... I won't roll-back, I always learn something here. For me it's fine. – Aradnix Sep 10 '17 at 5:51

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.