TransWikia.com

Table of Contents Title Overlapping Header

TeX - LaTeX Asked by Ryan Vedros on October 12, 2020

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
newfontfamilyheadingfont[]{Arial}
titleformat{section}[block]{headingfontfontsize{20pt}{0pt}bfseriesfilcentercolor{title}}{thesection}{}{}
titleformat{subsection}[hang]{headingfontfontsize{14pt}{0pt}bfseriescolor{h1}}{thesubsection}{}{}
titleformat{subsubsection}[hang]{headingfontfontsize{12pt}{0pt}bfseriescolor{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

One Answer

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}

newfontfamilyheadingfont{Roboto}
titleformat{section}[block]{headingfontfontsize{20pt}{0pt}bfseriesfilcentercolor{title}}{thesection}{}{}
titleformat{subsection}[hang]{headingfontfontsize{14pt}{0pt}bfseriescolor{h1}}{thesubsection}{}{}
titleformat{subsubsection}[hang]{headingfontfontsize{12pt}{0pt}bfseriescolor{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}

renewcommandcontentsname{
    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.

Answered by user1146332 on October 12, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP