1

I'm new in latex, and maybe this is a simple question for you, but not for me.

I'm using the class that you can find here https://www.latextemplates.com/template/masters-doctoral-thesis.

By default the color of the text of the Contents and List of figure is red, I'd like to turn it into black, but I don't know how to proceed. I tryed to read the template, I understand that I have to put \hypersetup{allcolor=.} but it's not specified where. So I tryed to put it either in the main after the package declaration, but it returns me error, or in the file .cls. In both case it doesn't work.

Can someone help me, please? Thanks

7
  • Welcome to the site. If you are sure the actual offending color is identified as "red" and if you don't care about eliminating the color "red" from the complete document, you could always just do \colorlet{red}{black} in the preamble. Oct 24, 2018 at 14:11
  • 1
    Note that, although this works, it is not really the 'correct' solution - it is a quick fix that has side effects, as @StevenB.Segletes mentions. A cleaner solution would be to use \hypersetup (or equivalent to use options when loading \hyperref) as described for example on en.wikibooks.org/wiki/LaTeX/Hyperlinks#Customization. Short version: use \hypersetup directly after \usepackage{hyperref}. In this case you probably need to customize linkcolor (which is red by default).
    – Marijn
    Oct 24, 2018 at 14:25
  • Do you mean that I should use \hypersetup in the .cls file?
    – XaBla
    Oct 24, 2018 at 14:27
  • No, it should be done in your .tex file. There is most likely a line there containing \usepackage{hyperref}, you can put the \hypersetup command on the next line. If the line is not there then it means that some other package, or maybe the class, loads hyperref. In that case you can put the hypersetup command directly before \begin{document}. In general you should never change anything in the .cls-file, unless you want to do something that the class was not designed to do.
    – Marijn
    Oct 24, 2018 at 14:49
  • 1
    Or use the solution by @esdd below. \AtBeginDocument is normally not really needed for setting options, but in this case it is a reasonable option.
    – Marijn
    Oct 24, 2018 at 14:56

3 Answers 3

2

If you are sure the actual offending color is identified as "red" and if you don't care about eliminating the color "red" from the complete document, you could always just do \colorlet{red}{black} in the preamble.

By saving "red" before you do that, you also have the option of later restoring red, in case you, in fact, need it later.

\documentclass{article}
\usepackage{xcolor}
\colorlet{savered}{red}
\colorlet{red}{black}% ELIMINATE red COLOR
\begin{document}
Text and \textcolor{red}{Red Text}

\colorlet{red}{savered}% RESTORE red COLOR
Text and \textcolor{red}{Red Text}
\end{document}

enter image description here

2
  • 1
    One should maybe note, that this will be not as good, if one has boxes for theorems or examples that carry coloured text.
    – Johannes_B
    Oct 28, 2018 at 13:24
  • @Johannes_B Thanks. That it what I had intended with the proviso, "and if you don't care about eliminating the color "red" from the complete document". Oct 28, 2018 at 20:45
3

From MasterDoctoralThesis.cls Version 1.6 (27/8/17):

\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=magenta,% The color of citations
linkcolor=red,% The color of references to document elements (sections, figures, etc)
urlcolor=mdtRed,% 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
}

To remove the red links you could use in your document preamble (do not change the cls file!)

\AtBeginDocument{\hypersetup{linkcolor=.}}

or you can hide all links with the following code in your document preamble

\AtBeginDocument{\hypersetup{hidelinks}}

The MasterDoctoralThesis class also provides an option nohyperref which can be used as class option. But then you have to remove all \hypersetup and \href commands from the document.

1
  • By the way, i took a closer look at the template. See my new answer.
    – Johannes_B
    Oct 28, 2018 at 13:12
3

I looked at the template and the pdf-file produced. I also took at look at the table of contents and saw Frequently asked questions. Here is a screenshot of what i read next:

mdtScreenshot

A.1 How do I change the colors of links? The color of links can be changed to your liking using:

\hypersetup{urlcolor=red}

or

\hypersetup{citecolor=green}

or

\hypersetup{allcolor=blue}

If you want to completely hide the links, you can use:

\hypersetup{allcolors=.}

or even better:

\hypersetup{hidelinks}

If you want to have obvious links in the PDF but not the printed text, use:

\hypersetup{colorlinks=false}

Edit: To make it more clear, the main file including the preamble already uses hypersetup within an \AtBeginDocument command. Just add the options there.

1

You must log in to answer this question.

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