0

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? Example of the unwanted line in the bottom of first table of content (the 'main' table)

Example of the unwanted line in top of second table of content (bilag = appendix)

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[noheader]{packages/sleek}
\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 :).

7
  • 2
    Please make sure to provide something others can test. Your example contains many files we do not have access to
    – daleif
    May 18, 2021 at 11:12
  • @daleif I have removed the different files and replaced with \lipsum[]. Is it better now?
    – Christina
    May 18, 2021 at 11:42
  • 1
    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?
    – Teepeemm
    May 18, 2021 at 11:46
  • 1
    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.
    – daleif
    May 18, 2021 at 12:03
  • 1
    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.
    – daleif
    May 18, 2021 at 12:42

1 Answer 1

0

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}
\usepackage[noheader]{packages/sleek}
\usepackage{packages/sleek-title}
\usepackage{packages/sleek-theorems}
\usepackage{packages/sleek-listings}

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.