I am working with a LaTeX template and am noticing a big difference between the compiled document after adding \usepackage{hyperref} at the top. Before adding it, the Table of Contents section is exactly how I want it, with nothing weird going on before each line:
But after adding \usepackage{hyperref}, the string "red" appears before the section number of each entry in the Table of Contents:
Does anyone know why this is happening or how I can fix it?
Edit: here's a MWE.
\documentclass{MyUniversityThesisTemplate.cls}
%(article class doesn't work, doc wouldn't even have table of contents)
\usepackage{hyperref}
\begin{document}
\chapter{Chapter 1}
\section{Section 1}
\chapter{Chapter 2}
\section{What do we want to measure?}
\section{Variables}
\section{Actors}
\section{Causal Relationships}
\section{Interdependencies}
\end{document}
And here's a MWE for the class document (might not be working though):
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{MyUniversityThesisTemplate}[2011/02/16 v1.4.2 My University Thesis class]
\RequirePackage{setspace}
%here I skip some code
\DeclareOption{myorder}{
\renewcommand*{\begincmd}{\doublespacing}}
\DeclareOption{lot}{\renewcommand*{\makelot}{
\addcontentsline{toc}{section}{List of Tables}\listoftables}}
\DeclareOption{lof}{\renewcommand*{\makelof}{
\addcontentsline{toc}{section}{List of Figures}\listoffigures}}
\DeclareOption{los}{
\renewcommand*{\makelos}{
\RequirePackage{losymbol}
\section*{List of Symbols\@mkboth {LIST OF SYMBOLS}{LIST OF SYMBOLS}}
\@starttoc{los}
\addcontentsline{toc}{section}{List of Symbols}
}
}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions
%here I skip some code
\AtBeginDocument{\begincmd}
\endinput
hyperref
is the very last package you load, so put it at the bottom of your preamble, just before\begin{document}
. Have you tested that?article
class does not have\chapter
s, so this cannot work. Butreport
andbook
have. And if I use one of those and add\tableofcontents
to your MWE, then I even get a table of contents and everything is fine.\tableofcontents
end up inside of\AtBeginDocument
by any chance?