0

This is my preamble:

\documentclass[12pt]{report}
\usepackage[left=1.5in, right=1in, top=1in,bottom=1.5in]{geometry}
\usepackage{setspace}
\usepackage{amsbsy}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{textcomp}
\usepackage{lscape}
\usepackage{amsmath}
\usepackage{calc}
\usepackage[rm,tiny]{titlesec} %added this to change the chapter title's font as default regular text font.
\usepackage{titlesec}
\usepackage{sectsty}
\sectionfont{\underline\normalfont\normalsize\centering}

\newlength{\depthofsumsign}
\setlength{\depthofsumsign}{\depthof{$\sum$}}
\newlength{\totalheightofsumsign}
\newlength{\heightanddepthofargument}

\usepackage{pdflscape,booktabs}
\usepackage[flushleft]{threeparttable}
\renewcommand\TPTtagStyle{\textit} 
\usepackage[font=it,skip=0.5\baselineskip]{caption} % italic text for captions

\usepackage{titletoc}
\usepackage{hyperref}

\titlecontents{chapter}
[3pt]                                               % left margin
{}%
{\contentsmargin{0pt}                               % numbered entry format
    \thecontentslabel\enspace%
    }
{\contentsmargin{0pt}\large}                        % unnumbered entry format
{\titlerule*[.99pc]{.}\contentspage}                 % filler-page format (e.g dots)
[]                                                  % below code (e.g vertical space)


%to put page numbers as the header
\fancyhf{}
\fancyhead[C]{\thepage}
\pagestyle{fancy}

\titleformat{\chapter}{\normalfont\centering}{}{0pt}{}
\titlelabel{}

\titlespacing*{\chapter}{0pt}{-25pt}{4pt}

\titleformat{\section}{\normalfont\centering}{}{0pt}{}

%koleygr: Redefining chapter to include \thispagestyle{fancy}
\let\oldchapter\chapter
\makeatletter
\def\chapter{%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}      
\def\@StarredWith[#1]#2{%
\oldchapter*{#2}%
\thispagestyle{fancy}
}
\def\@StarredWithout#1{
\oldchapter*{#1}%
\thispagestyle{fancy}
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\oldchapter[#1]{#2}%
\thispagestyle{fancy}
}
\def\@nonStarredWithout#1{%
\oldchapter{#1}%
\thispagestyle{fancy}
}
\makeatother

\interfootnotelinepenalty=10000
\renewcommand{\contentsname}{TABLE OF CONTENTS}



\begin{document}

I was using this same set of codes earlier, and it was working fine. Then I wanted to change the format of the titles, 'List of figures,' and 'List of tables' into all caps, i.e. "LIST OF FIGURES," and "LIST OF TABLES." So I used a bunch of codes. After they showed error, I undid everything and came back to the original state, but it stopped compiling.

Finally, I got rid of \tableofcontents code, and it compiled. But, now I cannot add the table of contents.

It is showing a ton of errors. Here is the screenshot: enter image description here

For my codes for table of contents, I am just using the normal bunch of codes:

\tableofcontents

\pagebreak

\listoftables

\pagebreak

\listoffigures

\pagebreak

Is there some defect in my codes, somewhere?

Thanks a lot!!

  • I added some chapters and some sections, and then using \tableofcontents doesn't make any errors: I got this output. – user156344 Apr 10 at 5:46
  • You might have put \tableofcontents and other stuff out of scope of \begin{document}..\end{document}. I don't get any error compiling your code. – Majid Abdolshah Apr 10 at 5:50
  • @JouleV, I just made a completely new document, and copy-pasted the entire code, and it works fine. But I went back to the original file, and it would still not compile, unless I get rid of the table of contents code. Not sure why that's happening! May be I will use the new document from now onward. [And I gotta learn how to use this forum better, thanks for your comment :) ] – Samyam Shrestha Apr 10 at 5:52
  • @MajidAbdolshah Yeah, not sure why that's happening just to that one document. – Samyam Shrestha Apr 10 at 5:53
  • 2
    If moving content to fresh file or renaming tex files clears an issue it usually indicates the original file still has borked auxiliaries so try the corresponding editor "clean" command – user170109 Apr 10 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.