# How to get rid of unwanted line - multiple table of contents in "report" class using titletoc package

I'm writing my thesis, and have stumbled upon a problem, I don't know how to fix. I want two tables of contents - one for the actual thesis and one just before the appendix. As the headline says, I'm writing in the report class with a separate file for each chapter of the thesis.

I have managed to get overleaf to create the two tables of contents that I want, but for some reason the first ends with a 'fun' line of the appendix content, while the last appendix table on contents starts with a line referencing to a bunch of chapters and sections. It's a little hard to explain - so I have attached some pictures - I have marked the unwanted lines with a red oval-thingy.

How can I get rid of these lines?

I have tried \startcontents and \stopcontents without any changes happening.

Here is the code (since it is long document, I have narrowed it down to just a few chapters for exemplification):

\documentclass[a4paper, 12pt]{report}

%%%%%%%%%%%%
% Packages %
%%%%%%%%%%%%

\usepackage[danish]{babel}
\usepackage{packages/sleek-title}
\usepackage{packages/sleek-theorems}
\usepackage{packages/sleek-listings}
\usepackage{subfiles}
\usepackage{pdfpages}
\usepackage{booktabs}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{float}
\usepackage{comment}
\usepackage{biblatex}
\usepackage{titletoc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{etoolbox}
\usepackage{lipsum}

%%%%%%%%%%%%
% Document %
%%%%%%%%%%%%

\begin{document}
\setcounter{secnumdepth}{3} % default value for 'report' class is "2"
\maketitle
\pagenumbering{Roman}
\chapter*{Summary}

\startcontents[main]
\printcontents[main]{}{-1}{\chapter*{Indholdsfortegnelse}}
%\romantableofcontents %commented out since it provides the full table of content including all chapters and sections of appendix - which is not wanted %
\chapter{Introduktion}
\pagestyle{fancy}
\fancyhf{}
\rfoot{Side \thepage \hspace{1pt} af \pageref{LastPage}}
\pagenumbering{arabic}
\lipsum[1]
\chapter{Litteraturreview}
\lipsum[]
\chapter{Afhandlingens teorivalg}
\lipsum[]

\stopcontents[main]
\cleardoublepage
%%%%%%%%%%%%
% Appendix %
%%%%%%%%%%%%

\appendix

\chapter*{Bilagsoversigt}

\startcontents[bilag]
\printcontents[bilag]{}{-1}{}

\chapter{Interviewguides}
\lipsum[]

\chapter{Operationalisering af spørgeskema}
\lipsum[]
\section{SurveyXact spørgeskemaet}
\lipsum[]

\chapter{Kvalitativ analyse}
\section{Totaloversigt over NVivo koder}

\stopcontents[bilag]

\end{document}


I think the problem is something in the correlation between the sleek-packages and the titletoc, since the line doesn't show, if I remove the sleek-packages. But then I don't have the wished design of the document. So I seek a solution, where I can keep the sleek-packages for the document style.

If it's possible to get the first table of content (main document) to also contain the appendix-chapters (but not sections), that would be very nice.

If something needs to be elaborated please don't hesitate to tell me so, this is my first time posting a question - since the thesis is my first time working with overleaf.

Have a nice day and thanks in advance for any help :).

• Please make sure to provide something others can test. Your example contains many files we do not have access to May 18, 2021 at 11:12
• @daleif I have removed the different files and replaced with \lipsum[]. Is it better now? May 18, 2021 at 11:42
• Well, you've narrowed down the problem. But since sleek isn't in a normal TeX distribution, there's not much we can do. What are the parts of sleek that you're interested in? May 18, 2021 at 11:46
• BTW: does this actually compile without errors in overleaf? We have seen multiple times that OL users overlook compilation errors because a PDF was created. The header in the image very much looks like the result of a compilation with errors. May 18, 2021 at 12:03
• Looking at the overleaf project the issue seems to be a badly coded template that loads a lot of packages including hyperref and thus if one adds packages later on things can go completely haywire. May 18, 2021 at 12:42

It all comes down to https://da.overleaf.com/latex/templates/sleek-template/hrksrrdywhfk being a sub optimal template, or at least not explaining it self very well.

\usepackage[noheader]{packages/sleek}


loads a lot of packages, including several the OP is also loading later on. Included in this OPs list if titletoc but packages/sleek autoloads hyperref and we all know that with a few exceptions hyperref should always be loaded last. Is hyperref last in packages/sleek? nope, but it did not end in catastrophe.

The issue here seems to be titletoc being loaded after hyperref. If we move all the OPs packages up above the sleek packages (and remove biblatex as sleek loads it), the project seems to at least compile without error.

That is, this seems to help

\usepackage{subfiles}
\usepackage{pdfpages}
\usepackage{booktabs}
% \usepackage[utf8]{inputenc} % sleek
\usepackage{tabularx}
\usepackage{float}
\usepackage{comment}
% \usepackage{biblatex} % sleek
\usepackage{titletoc}
% \usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{etoolbox}
\usepackage{lipsum}
\usepackage[danish]{babel}
`