[Tex/LaTex] Chapters not showing in right order in PDF [solved]

chaptersinputthesis

I'm new to LaTex and decided to start writing my thesis on it.

I've structured the basics of my main.tex file and created corresponding chapter tex files, adding them to the main file using /input. However, after I started writing chapter 3, it kept showing up as chapter four in the PDF compiled. Then I started writing chapter 4 in its corresponding file and now the PDF isn't even getting compiled anymore. I get the error message below:

error when compiling PDF

I'm not sure what might be wrong. Any ideas? Thanks for your help! Please let me know if I should provide any more info.

*edit: Thnaks for your help so far! I fixed the typos in chapter 4 and am now able to generate the PDF again, also fixed the fancyheadr issue. However, the issue with the chapters continues… Now chapter 3 is showing up as chapter 4 and chapter 4 is showing as chapter 6! I'm adding \chapter to the beginning of each chapter file, followed by the chapter title between {}. Also added this line to the top of each chapter file: %!TEX root=main.tex

Here's the code as requested (and thanks for any further help!):

   \documentclass[12pt, twoside]{report}
    \usepackage{natbib}
    \bibliography{references}
  \bibliographystyle{apa}
  \usepackage[a4paper,width=150mm,top=25mm,bottom=25mm, bindingoffset=6mm]{geometry}
  \usepackage[utf8]{inputenc}
  \usepackage{graphicx}
  \graphicspath{ {Images/} }

  \usepackage{fancyhdr}
  \pagestyle{fancy}
  \fancyhead{}
  \fancyhead[RO,LE]{thesis title}
  \fancyfoot{}
  \fancyfoot[LE,RO]{\thepage}
  \fancyfoot[LO,CE]{Chapter \thechapter}
  \fancyfoot[CO,RE]{} 
  \renewcommand{\headrulewidth}{0.4pt}
  \renewcommand{\footrulewidth}{0.4pt}
  \setlength{\headheight}{14.5pt}

  \title{
      {title}\\
      {\large institute}\\
      {\includegraphics{}} %insert logo uni later
  }
  \author{deb}
  \date{Day Month Year} %insert date

  \begin{document}

  \input{Chapters/titlepage}

  \input{Chapters/abstract}  

  \chapter*{Dedication}

  \chapter*{Declaration}

  \chapter*{Acknowledgements}

  \tableofcontents

  \listoftables

  \listoffigures

  \chapter{Introduction}
  \input{Chapters/introduction}

  \chapter{Chapter Two Title}
  \input{Chapters/chapter02}

  \chapter{Brazilian context and the 2013 and 2014 protests in Fortaleza}
  \input{Chapters/chapter03}

  \chapter{Literature review on media practices}
  \input{Chapters/chapter04}

  \chapter{Chapter Five Title}
  \input{Chapters/chapter05}

  \chapter{Chapter Six Title}
  \input{Chapters/chapter06}

  \chapter{Chapter Seven Title}
  \input{Chapters/chapter07}

  \chapter{Conclusion}
  \input{Chapters/conclusion}

  \appendix
  \chapter{Appendix}
    \input{chapters/appendix}

    \end{document}

This is the code from both chapters (3 and 4):

    %!TEX root=main.tex

    \chapter{Brazilian context and the 2013 and 2014 protests in Fortaleza}

    \section{Why were people taking to the streets?} %this is an item for broader, structural contextualization


    \section{Who were the protesters in 2013 and 2014?} %this is an item for contextualization of the movements themselves and changes between both years through their lenses, which take into account the sociopolitical changes

    \section{The Brazilian media landscape}%ver também docs com citações para meu MA e outros artigos que tratam do assunto, mas não pegar os textos em si

    \section{Internet use and digital inclusion}

    \section{Alternative media: past and present}%ver também docs com citações para meu MA e outros artigos que tratam do assunto, mas não pegar os textos em si

    \section{Nigéria, Na Rua and the people around them}%ver o que posso aproveitar do exposé na descrição geral, principalmente dos dois coletivos

    \section{Interim summary}

chapter 4:

    %!TEX root=main.tex

    \chapter{Literature review on media practices}

    \section{Practice theory}
    *origins of the concept, canon literature

    \section{Practice Theory in the Context of Media Studies}
    \section{Media practices in protest movements}
    \section{Adaption of media practices}
    \subsection{Policitization of everyday media practices}
    \subsection{Activismization of professional journalistic practices}
    \subsection{Modification/creation of media practices as a reaction to changes in conjuncture}
    \section{Interim summary}

And this is what the Table of Contents looks like now:

table of contents

Best Answer

From the error message, I assume there is something like this in the code:

\section{Activismization of professional journalistic practices
\subsection{...}

Then the reason is the missing closing curly brace of the section title.


Also the \headheight warning of fancyhdr should be fixed:

  • If package geometry is used, then add option:

    \usepackage[
      ...,
      headheight=14.5pt,
    ]{geometry}
    
  • Manually (and with fixes of other vertical layout lengths, maybe):

    \setlength{\headheight}{14.5pt}
    

If this is not fixed, the layout will be inconsistent, the first pages will have a smaller \headheight, the following pages will have a larger header, which causes the text body to move down a little.


The chapter number problem should be analyzed further: Compare the information about chapters of the .log file with the output and the TeX sources. The you should be able to narrow down the problem and post some relevant code, if the problem cannot be solved.

Related Question