0

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: enter image description here

But after adding \usepackage{hyperref}, the string "red" appears before the section number of each entry in the Table of Contents:

enter image description here

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
  • you should make sure that 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? – T. Pluess Jun 3 at 4:45
  • @T.Pluess, yeah, it is currently the very last package that I load. Thanks for the idea though – Rasputin Jun 3 at 6:17
  • Untested but I doubt very much that the stripped down class actually triggers your problem - there is nowhere something looking like "red" and hyperref doesn't invent such a word. You will have to show a real minimal example that actually demonstrates the problem. – Ulrike Fischer Jun 3 at 7:28
  • 1
    The article class does not have \chapters, so this cannot work. But report and book 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. – DLichti Jun 3 at 8:14
  • There isn't enough information to reproduce your problem, but random guess: Does \tableofcontents end up inside of \AtBeginDocument by any chance? – David Purton Jun 3 at 9:37
0

THE PROBLEM HAS BEEN SOLVED BY INSERTING

\RequirePackage{hyperref}

AFTER THE

\RequirePackage{setspace}

LINE OF CODE IN THE CLASS FILE!!!!!!!!! :D

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.