2

I'm using this template http://www.latextemplates.com/template/masters-doctoral-thesis

\documentclass[
11pt, % The default document font size, options: 10pt, 11pt, 12pt
english, % ngerman for German
singlespacing, % Single line spacing, alternatives: onehalfspacing or doublespacing
]{MastersDoctoralThesis} % The class file specifying the document structure

\usepackage{amsmath,tensor} % matrix, vector
\usepackage{cleveref} 

\begin{document}

\begin{equation}\label{eq:a}
{{\rm{a}}_{r,c,l}} \in \{ 0,1, \ldots ,n\}
\end{equation}

Just ref \ref{eq:a}

Clever \Cref{eq:a} 

\end{document}

Gives me an error

Reference `eq:a' on page 1 undefined on input line 62.

My minimal example: https://www.overleaf.com/read/ktmqbhnvsdww


Add content of MastersDoctoralThesis.cls

\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\newcommand{\classname}{MastersDoctoralThesis}
\ProvidesClass{\classname}[2016/11/22 v1.5 LaTeXTemplates.com]
\providecommand{\baseclass}{book}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
\newbool{hyperrefsupport}
\booltrue{hyperrefsupport}
\newbool{headsepline}

\DeclareOption{nohyperref}{\boolfalse{hyperrefsupport}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\baseclass}}

\ProcessOptions\relax

\LoadClass{\baseclass}

%----------------------------------------------------------------------------------------
%   REQUIRED PACKAGES
%----------------------------------------------------------------------------------------

\RequirePackage{babel} % Required for automatically changing names of document elements to languages besides english

\RequirePackage{scrbase} % Required for handling language-dependent names of sections/document elements

\RequirePackage{scrhack} % Loads fixes for various packages

\RequirePackage{setspace} % Required for changing line spacing

\RequirePackage{longtable} % Required for tables that span multiple pages (used in the symbols, abbreviations and physical constants pages)

\RequirePackage{siunitx} % Required for \SI commands

\RequirePackage{graphicx} % Required to include images
\graphicspath{{Figures/}{./}} % Specifies where to look for included images

\RequirePackage{booktabs} % Required for better table rules

\RequirePackage{caption} % Required for customising the captions
\captionsetup{justification=centerlast,font=small,labelfont=sc,margin=50pt}

%----------------------------------------------------------------------------------------
%   MARGINS
%----------------------------------------------------------------------------------------

\RequirePackage{geometry}
\geometry{
    headheight=27.2pt,
    includehead,
    includefoot
}

\raggedbottom


%----------------------------------------------------------------------------------------

\ifbool{hyperrefsupport}{% If the nohyperref class option has not been specified
\AtEndPreamble{\RequirePackage{hyperref}
\hypersetup{
pdfpagemode={UseOutlines},
bookmarksopen=true,
bookmarksopenlevel=0,
hypertexnames=false,
colorlinks=true,% Set to false to disable coloring links
citecolor=blue,% The color of citations
linkcolor=blue,% The color of references to document elements (sections, figures, etc)
urlcolor=blue,% The color of hyperlinks (URLs)
pdfstartview={FitV},
unicode,
breaklinks=true,
}

\pdfstringdefDisableCommands{% If there is an explicit linebreak in a section heading (or anything printed to the pdf-bookmarks), it is replaced by a space
    \let\\\space%
}
    }
}{%nothing
}

%----------------------------------------------------------------------------------------

\endinput
% lazyLizardTracer

4
  • Post the complete minimal example here, links will be dead at some time and then the question is no longer useful for others. Apr 16, 2019 at 8:59
  • But I'm not sure which part in the class file is relevant. Content of the main tex file is already posted in the question.
    – Mzq
    Apr 16, 2019 at 9:02
  • I won't follow a link to debug a large document. Apr 16, 2019 at 9:23
  • I have added in the content of MastersDoctoralThesis.cls
    – Mzq
    Apr 16, 2019 at 9:41

1 Answer 1

3

You must load cleveref after hyperref - because your class only loads hyperref at the end of the preamble, you have to do the same trick:

\documentclass[
11pt, % The default document font size, options: 10pt, 11pt, 12pt
english, % ngerman for German
singlespacing, % Single line spacing, alternatives: onehalfspacing or doublespacing
]{MastersDoctoralThesis} % The class file specifying the document structure

\usepackage{amsmath,tensor} % matrix, vector
\AtEndPreamble{\usepackage{cleveref}} 

\begin{document}

\begin{equation}\label{eq:a}
{{\rm{a}}_{r,c,l}} \in \{ 0,1, \ldots ,n\}
\end{equation}

Just ref \ref{eq:a}

Clever \Cref{eq:a} 

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .