1

I am new to LaTeX. I have been creating a document with four chapters. As I am editing the chapters and compiling the code, sometimes Chapter 4 is being left out from the table of contents. To me, it seems that the chapter beginning after a certain page number is being left out and the problem is not specifically with Chapter 4 itself. For example, when Chapter 4 begins from page 12, it shows up in the table of contents as it should but disappears if it begins after page 12. However, I may be wrong. Also, I tried including Chapter 4 before Chapter 3 and everything worked perfectly.

Kindly help.

Here is the main.tex I am using:

\documentclass[11pt]{report} 
\usepackage{titlesec}
\titleformat{\chapter}
 {\normalfont\fontsize{12}{15}}{\thechapter.}{1em}{}
  \titleformat{\section}
 {\normalfont\fontsize{12}{15}\bfseries}{\thesection}{1em}{}
 \titleformat{\subsection}
 {\normalfont\fontsize{11}{15}\bfseries}{\thesubsection}{1em}{}

\usepackage[a4paper,left=15mm,right=15mm,top=15mm,bottom=20mm, includefoot]{geometry}
\usepackage{helvet}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{cite}
\usepackage{lscape}
\usepackage{indentfirst}
\usepackage{latexsym}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{tabls}
\usepackage{wrapfig}
\usepackage{slashbox}
\usepackage{longtable}
\usepackage{supertabular}
\usepackage{subeqn}
\usepackage{subfigure}
\usepackage{pdflscape}
\usepackage{etoolbox}
\titlespacing*{\chapter}{0pt}{10pt}{10pt}
\fancypagestyle{main}{
\fancyhf{} 
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
  \cfoot{Page \thepage\ of \pageref{LastPage}}
}

\renewcommand{\familydefault}{\sfdefault}
\setlength{\parindent}{.4in}
\setcounter{tocdepth}{0}
\makeatletter
\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother
\patchcmd{\chapter}{plain}{main}{}{}
\pagestyle{main}

\begin{document}

\include{Titlepage}
\setcounter{page}{1}
\renewcommand{\baselinestretch}{1}
\small\normalsize
\tableofcontents
\renewcommand{\baselinestretch}{1}
\small\normalsize
\begingroup
\let\clearpage\relax
\renewcommand{\baselinestretch}{2}
\small\normalsize
\include{Chapter1}
\renewcommand{\baselinestretch}{1}
\small\normalsize
\include{Chapter2}
\include{Chapter3}
\include{Chapter4}
\endgroup
\end{document}

Also, chapter 4 has

\renewcommand{\thechapter}{\textbf{4}}
\chapter{\textbf{ChapterName}}
 All text...
  • 4
    \let\clearpage\relax is dangerous! – user11232 Oct 28 '13 at 10:01
  • 5
    Welcome to TeX.SX! I'd add to Harish's comment that it's not only dangerous, it's wrong if you use \include. – egreg Oct 28 '13 at 10:08
  • 1
    use \input instead of \include – user2478 Oct 28 '13 at 10:45
  • Since you haven't provided the (relevant) contents of Chapter 4, I don't think it's possible to diagnose correctly why including it either before or after Chapter 3 would make such a difference. – Mico Oct 28 '13 at 10:54
  • 1
    For obvious reasons, i VtC – Johannes_B Feb 22 '15 at 18:42