TransWikia.com

Table of contents ignores bottom margin

TeX - LaTeX Asked by ledex on December 16, 2020

When my TOC spans across multiple pages, the bottom margin is ignored.

documentclass[12pt]{article}

%Packages
usepackage[table,xcdraw]{xcolor}
usepackage{graphicx}
usepackage{fancyhdr}
usepackage[hidelinks]{hyperref}
usepackage{csquotes}
usepackage[colorinlistoftodos,prependcaption,textsize=tiny]{todonotes}
usepackage{caption}
usepackage{listings} % used for code-snippets
usepackage[english]{babel} % the main document language is the last one
usepackage[toc,page]{appendix}
usepackage{adjustbox}
usepackage{rotating}
usepackage{xargs}                
usepackage{tabularx}      
usepackage{lscape}
usepackage{ltablex}
usepackage{siunitx}

%Bibliography
usepackage[style=iso-authoryear]{biblatex}
addbibresource{./bibliography/bibliography.bib}

%Glossary
usepackage[acronym,shortcuts,automake]{glossaries}
glspatchtabularx
makeglossaries

%Formatting
    %Margins
    usepackage[a4paper,
    left=4cm,right=2cm,top=4cm,bottom=2cm]{geometry}

    %Line-spacing
    usepackage{setspace}
    onehalfspacing
    
    %Linenumbers
    usepackage{lineno}
    %linenumbers
    
    %Margins
    usepackage{showframe}
    
    %Header
    pagestyle{fancy}
    fancyhf{}
    fancyhead[R]{thepage}
    renewcommand{headrulewidth}{0pt}
    
%Abbreviations
[...]

begin{document}
    pagenumbering{Roman}   
    
    todo{Remove list of todos}
    listoftodos
    newpage
    
    %Titlepage
    input{content/titlepage}
    
    %Table of contents
    todo{Bottom-margin does not apply to toc}
    setcounter{page}{2}
    tableofcontents
    
    [...]

end{document}

This is how my TOC looks like:
TOC with margin error.

Am I missing something? Thanks in advance!

One Answer

Please try this code first and see what happens. It is a 19 page long simulated article. Use a new directory to run it. Run LaTeX multiple times if your installation doesn't do it automatically. Then add the titlepage to check that it is not messing something up.

I kept all your preamble but added the kantlipsum package to generate dummy text. I also commented input{content/titlepage}.

If your original document still exhibits the unwanted behavior

1 Delete all auxiliary files.

2 Run LaTeX at least 3/4 times (sometimes more is needed) to allow cross references to accommodate and also the bibliography, until everything seems stable. I found that sometimes the intermediate states will produce a bad TOC similar to what you found.

3 If the problem persists, you should probably update your LaTeX installation and packages.

My .log shows

(MiKTeX 20.7)

LaTeX2e <2020-02-02> patch level 5

L3 programming layer <2020-08-07>

("C:/Program Files/MiKTeX/tex/latex/base/article.cls" Document Class: article 2019/12/20 v1.4l Standard LaTeX document class

documentclass[12pt]{article}

%Packages
usepackage[table,xcdraw]{xcolor}
usepackage{graphicx}
usepackage{fancyhdr}
usepackage[hidelinks]{hyperref}
usepackage{csquotes}
usepackage[colorinlistoftodos,prependcaption,textsize=tiny]{todonotes}
usepackage{caption}
usepackage{listings} % used for code-snippets
usepackage[english]{babel} % the main document language is the last one
usepackage[toc,page]{appendix}
usepackage{adjustbox}
usepackage{rotating}
usepackage{xargs}                
usepackage{tabularx}      
usepackage{lscape}
usepackage{ltablex}
usepackage{siunitx}

%Bibliography
usepackage[style=iso-authoryear]{biblatex}
addbibresource{./bibliography/bibliography.bib}

%Glossary
usepackage[acronym,shortcuts,automake]{glossaries}
glspatchtabularx
makeglossaries

%Formatting
    %Margins
    usepackage[a4paper, left=4cm,right=2cm,top=4cm,bottom=2cm]{geometry}
 
    %Line-spacing
    usepackage{setspace}
    onehalfspacing
    
    %Linenumbers
    usepackage{lineno}
    %linenumbers
    
    %Margins
    usepackage{showframe}
    
    %Header
    pagestyle{fancy}
    fancyhf{}
    fancyhead[R]{thepage}
    renewcommand{headrulewidth}{0pt}
    
%Abbreviations
%[...]

usepackage{kantlipsum} %dummy text added <<<<

begin{document}
  pagenumbering{Roman}   
    
    todo{Remove list of todos}
    listoftodos
  newpage
    
    %Titlepage
%    input{content/titlepage}
    
    %Table of contents
    todo{Bottom-margin does not apply to toc}
    setcounter{page}{2}
    tableofcontents
  
  %%%*************************** added a simulated long paper 
newpage 
pagenumbering{arabic} 

section{A1}
kant[1]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{B1}
kant[2]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{C1}
kant[3]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{D1}
kant[4]
subsection{a}
subsection{b}
subsection{c}
subsection{d}

section{A2}
kant[1]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{B2}
kant[2]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{C2}
kant[3]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{D2}
kant[4]
subsection{a}
subsection{b}
subsection{c}
subsection{d} 

section{A3}
kant[1]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{B3}
kant[2]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{C3}
kant[3]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{D3}
kant[4]
subsection{a}
subsection{b}
subsection{c}
subsection{d}

section{A4}
kant[1]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{B4}
kant[2]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{C4}
kant[3]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{D4}
kant[4]
subsection{a}
subsection{b}
subsection{c}
subsection{d}

section{A5}
kant[1]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{B5}
kant[2]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{C5}
kant[3]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{D5}
kant[4]
subsection{a}
subsection{b}
subsection{c}
subsection{d}

appendix
section{AA6}
kant[1]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{AB6}
kant[2]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{AC6}
kant[3]
subsection{a}
subsection{b}
subsection{c}
subsection{d}
section{AD6}
kant[4]
subsection{a}
subsection{b}
subsection{c}
subsection{d}

end{document}

enter image description here

Answered by Simon Dispa on December 16, 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