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.


%(article class doesn't work, doc wouldn't even have table of contents)



\chapter{Chapter 1}

\section{Section 1}

\chapter{Chapter 2}

\section{What do we want to measure?}



\section{Causal Relationships}



And here's a MWE for the class document (might not be working though):


\ProvidesClass{MyUniversityThesisTemplate}[2011/02/16 v1.4.2 My University Thesis class]


%here I skip some code




  \addcontentsline{toc}{section}{List of Tables}\listoftables}}


  \addcontentsline{toc}{section}{List of Figures}\listoffigures}}




    \section*{List of Symbols\@mkboth {LIST OF SYMBOLS}{LIST OF SYMBOLS}}


    \addcontentsline{toc}{section}{List of Symbols}





%here I skip some code


  • 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 '19 at 4:45
  • @T.Pluess, yeah, it is currently the very last package that I load. Thanks for the idea though – Rasputin Jun 3 '19 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 '19 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 '19 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 '19 at 9:37






| improve this answer | |

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.