1

Edited Version

I am working on the template (MastersDoctoralThesis) downloaded from here

I searched a lot here for a solution to my problem but couldn't find, please be patient with me.

    \usepackage[backend=bibtex,style=authoryear,natbib=true,maxbibnames=2]{biblatex}

    \addbibresource{bibliography.bib} 

\DeclareCiteCommand{\citep}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}} 

When I use \citep to show two authors name and year, I got what I want but in pink color.

I would like to change this color to black with keeping the same format e.g:

(Autor1 and Autho2, 2019)

Any help will be appreciated.

  • 1
    Welcome to TeX.SX! The colour probably is coming from hyperref. Try using \hypersetup{hidelinks} after loading hyperref. – Phelype Oleinik Jun 19 at 15:31
  • 2
    Then please, make a short compilable code (a minimal working example (MWE)) that reproduces this issue so that we can find out where does the colour com from. – Phelype Oleinik Jun 19 at 15:41
  • @PhelypeOleinik +1,Thanks a lot, I used your helpful comment to search and edit my cls file and I change the cite color from magenta to black – Moh Jun 19 at 15:49
  • 1
    The problem is that that template loads hyperref at the \begin{document}, so whatever changes you do before that can be overwritten. If you do \hypersetup{hidelinks} after the \begin{document} it will work (it will hide all links; if you want just citations, then \hypersetup{citecolor=black}). – Phelype Oleinik Jun 19 at 15:54
  • 2
    If it is not too late you may want to consider dropping the template you are using and starting from a more minimal setup instead. That way you know what each bit of code you add to your document does and don't start with a hugely complicated code base. See also github.com/johannesbottcher/templateConfusion/blob/master/… (You can also find many questions about your particular template on this site) – moewe Jun 19 at 16:05
1

Use the following setting

 \hypersetup{citecolor=black}

Working example:

\documentclass{article}

\usepackage[backend=bibtex,style=authoryear,natbib=true,maxbibnames=2]{biblatex}

    \addbibresource{bibliography.bib} 

\DeclareCiteCommand{\citep}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}} 

\usepackage[colorlinks]{hyperref}  
\hypersetup{citecolor=black}  

\begin{document}

\citep{knuth}


\printbibliography
\end{document}

enter image description here

  • @Moh Post a compilable code - works in my example – harryparp Jun 19 at 15:40
  • +1 thanks a lot, I used your answer to search and edit my cls file and I change the cite color from magneta to black. – Moh Jun 19 at 15:48
  • @Moh Do not change the class file. See the license. You can make any changes in the preamble, respectively right after \begin{document}. Or look at the \AtBeginDocument{ in the template, where hyperref changes are set up. Or don't load hyperref at all by uncommenting the nohyperref option. – Johannes_B Jun 20 at 4:48

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.