0

I'm trying to get the Table of Contents title to sit correctly on the contents page. All other section titles are formatting correctly but for some reason the Table of Contents title sits over the header.

I wasn't sure which packages I could cut from the example code so I included all the packages we are using. The issue is resolved when I put all four author names on the same line in the header, but then the author names overlap with the class section. When I add a line break in the header to compensate for the names, it overlaps the ToC title. Relevant Code:

\documentclass[letterpaper,12pt]{article}

\usepackage{amsfonts}
\usepackage{cite}
\usepackage{graphicx} % For images
\usepackage{indentfirst}
\usepackage{gensymb}
\usepackage[nottoc]{tocbibind}
\usepackage{varwidth}
\usepackage{float}    % For tables and other floats
\usepackage{verbatim} % For comments and other
\usepackage{amsmath}  % For math
\usepackage{amssymb}  % For more math
\usepackage{fullpage} % Set margins and place page numbers at bottom center
\usepackage{listings} % For source code
\usepackage{subfig}   % For subfigures
\usepackage{color}   %May be necessary if you want to color links
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{titlesec}
\usepackage{titling}
\usepackage{fontspec}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage{ulem}
\usepackage[table]{xcolor}
\usepackage{gensymb}
\usepackage[document]{ragged2e}

%equation captioning
\DeclareCaptionType{mycapequ}[][List of Equations]
\captionsetup[mycapequ]{labelformat=empty}

%color setup
\definecolor{title}{RGB}{128,2,3}
\definecolor{h1}{RGB}{31,73,125}
\definecolor{h2}{RGB}{0,0,0}

%font setup

%headings setup
\newfontfamily\headingfont[]{Arial}
\titleformat{\section}[block]{\headingfont\fontsize{20pt}{0pt}\bfseries\filcenter\color{title}}{\thesection}{}{}
\titleformat{\subsection}[hang]{\headingfont\fontsize{14pt}{0pt}\bfseries\color{h1}}{\thesubsection}{}{}
\titleformat{\subsubsection}[hang]{\headingfont\fontsize{12pt}{0pt}\bfseries\color{h2}}{\thesubsubection}{}{}

\titlespacing{\section}{0pt}{12pt}{12pt}
\titlespacing{\subsection}{0pt}{12pt}{12pt}
\titlespacing{\subsubsection}{0pt}{12pt}{0pt}

%header and footer
\pagestyle{fancy}
\fancyhf{}
\rhead{Author1, Author2, \\ Author3, and Author4}
\lhead{Design Project 1}
\chead{MEEN 450C-002}
\cfoot{Page \thepage}
\setlength{\headsep}{25pt}

\renewcommand{\sfdefault}{ptm}

\begin{document}
%table of contents
\newpage
\setcounter{secnumdepth}{0} % sections are level 1, no section numbers shown
\begin{center}
\renewcommand*\contentsname{Table of Contents}
\tableofcontents
\newpage
%\listoffigures
%\listoftables
\end{center}
\end{document}

enter image description here

5
  • 1
    Hi and welcome! It's more likely that someone looks into your issue if you post a minimal working example. It's a cumbersome task to rearrange your code snippets into a document that will compile. – user1146332 Apr 1 '20 at 20:22
  • Got it, thank you! – Ryan Vedros Apr 1 '20 at 20:36
  • Edited to provide working example, thanks user1146332. – Ryan Vedros Apr 1 '20 at 20:43
  • There's a warning that the headheight should be set to 27.41803pt at least. Add to your preamble \setlength{\headheight}{28pt} seems to solve it. Unrelated: hyperref should be loaded last, with very few exceptions (most notable cleveref. Also: don't load color when yiu load xcolor (and load the latter only once). Last: you forgot to load caption. – Bernard Apr 1 '20 at 21:20
  • Thank you so much! That fixed it up – Ryan Vedros Apr 1 '20 at 21:25
1

Although your example is far from minimal i worked something out for you.

The fault is that u put the whole table of contents into the center environment, even the \newpage command. This is not only bad typography but also not recommended because the center environment shouldn't be applied to center the content of multiple pages.

The key to fix your issue is the correct redefinition of \contentsname like:

\documentclass[letterpaper,12pt]{article}

\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{fontspec}
\usepackage{fullpage} 
\usepackage{fancyhdr}

\definecolor{title}{RGB}{128,2,3}
\definecolor{h1}{RGB}{31,73,125}
\definecolor{h2}{RGB}{0,0,0}

\newfontfamily\headingfont{Roboto}
\titleformat{\section}[block]{\headingfont\fontsize{20pt}{0pt}\bfseries\filcenter\color{title}}{\thesection}{}{}
\titleformat{\subsection}[hang]{\headingfont\fontsize{14pt}{0pt}\bfseries\color{h1}}{\thesubsection}{}{}
\titleformat{\subsubsection}[hang]{\headingfont\fontsize{12pt}{0pt}\bfseries\color{h2}}{\thesubsubection}{}{}

\pagestyle{fancy}
\rhead{Author1, Author2, \\ Author3, and Author4}
\lhead{Design Project 1}
\chead{MEEN 450C-002}
\cfoot{Page \thepage}
\setlength{\headsep}{25pt}
\setlength{\headheight}{2.5em}

\begin{document}

\renewcommand\contentsname{
    \begin{center}
        Table of Contents
    \end{center}
}

\setcounter{secnumdepth}{0} % sections are level 1, no section numbers shown
\tableofcontents

\newpage
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}
\section{test}

\end{document}

Besides that i highly recommend to study the basics of good typography. I can see in your "minimal" working example that you violate basic typographical rules.

For a good introduction i suggest you to read the documentation of the memoir or koma-script document classes.

I know that it's tempting to customize every detail of the output by hand and reinvent the wheel. Stop following this path. The result isn't worth it. Until now i never saw a good example of this approach.

By the way the result of such endeavours is almost always optimized for a computer screen and not for a printed paper. If you want to typeset digital documents that are meant to read on a computer screen there are far better solutions than tex/latex.

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.