1

I am trying to change a colour of citations in Thesis class. I know that I need to load hyperref package but it didn't work to me. Here is the screenshot of my main docs as well as the Thesis.cls.

% MNRAS Manuscript Template
\documentclass[useams,onecolumn,usenatbib,twoside]{Thesis}
%\pdfminorversion=5
%
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{lettrine}
%
\usepackage{natbib}
\usepackage{amsmath}
\usepackage{setspace}
%\usepackage{pdfpages}
%\usepackage[times,hyper]{Rd}
\usepackage[utf8,latin1]{inputenc}
%\includepdfset{offset=2cm -2cm}
\usepackage{setspace}
\usepackage{lscape}
\usepackage{makeidx}
\graphicspath{{./images/}}
\usepackage[table,xcdraw,svgnames]{xcolor}
%\usepackage[colorlinks=true,
%           citecolor=blue,
%           linkcolor=blue,
%           urlcolor=red,
%           linktocpage=true,
%           hyperfootnotes=false]{hyperref}

%%%%%
% 
%%%%%
\makeindex{}
\begin{document}
\pagestyle{plain}
\pagenumbering{roman}
\DeclareGraphicsExtensions{.pdf,.png,.gif,.jpg}
%----------------------------------------------------------------------------------
%               Title Page
%----------------------------------------------------------------------------------
\begin{titlepage}
    \begin{center}
    \textsc {\LARGE The University of ...}\\[0.5cm]
    \textsc {\LARGE  \& }\\[0.5cm]
    \textsc{School of Physics}\\[0.5cm]
    \LARGE PhD Thesis\\[0.5cm]

    % Bottom of the page
    {\large \today}

    \end{center}
\end{titlepage}

%----------------------------------------------------------------------------------
%               Preamble
%----------------------------------------------------------------------------------

\clearpage
\include{Preamble}
\cleardoublepage
\pagenumbering{arabic}


%----------------------------------------------------------------------------------
%               Content
%----------------------------------------------------------------------------------

\include{ChapterOne}
\include{ChapterTwo}
\include{ChapterThree}
\include{ChapterFour}
\include{ChapterFive}


\cleardoublepage
\addcontentsline{toc}{chapter}{References}
\bibliographystyle{mnras}
\bibliography{library}
\appendix
\include{AppendixOne}
\include{AppendixTwo}
\include{AppendixThree}
\printindex{}
\end{document}

and here is a thesis.cls :

%%
%% This is file `Thesis.cls', based on 'ECSthesis.cls', by Steve R. Gunn
%% generated with the docstrip utility.
%%
%% Created by Steve R. Gunn, modified by Sunil Patel: www.sunilpatel.co.uk

\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesClass{Thesis}
              [2007/22/02 v1.0
   LaTeX document class]
\def\baseclass{book}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\baseclass}}
\def\@checkoptions#1#2{
  \edef\@curroptions{\@ptionlist{\@currname.\@currext}}
  \@tempswafalse
  \@tfor\@this:=#2\do{
    \@expandtwoargs\in@{,\@this,}{,\@curroptions,}
    \ifin@ \@tempswatrue \@break@tfor \fi}
  \let\@this\@empty
  \if@tempswa \else \PassOptionsToClass{#1}{\baseclass}\fi
}
\@checkoptions{12pt}{{10pt}{11pt}{12pt}}
\PassOptionsToClass{a4paper}{\baseclass}
\ProcessOptions\relax
\LoadClass{\baseclass}
\newcommand\bhrule{\typeout{------------------------------------------------------------------------------}}

\usepackage{geometry}
\newcommand\Declaration[1]{
\btypeout{Declaration of Authorship}
\addtotoc{Declaration of Authorship}
\thispagestyle{plain}
\null\vfil
%\vskip 60\p@
\begin{center}{\huge\bf Declaration of Authorship\par}\end{center}
%\vskip 60\p@
{\normalsize #1}
\vfil\vfil\null
%\cleardoublepage
}

\newcommand\btypeout[1]{\bhrule\typeout{\space #1}\bhrule}
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space \number\year}
\usepackage{setspace}
\onehalfspacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{2.0ex plus0.5ex minus0.2ex}
\usepackage{vmargin}
\setmarginsrb           { 4cm}  % left margin
                        { 2cm}  % top margin
                        { 2cm}  % right margin
                        { 2cm}  % bottom margin
                        {  10pt}  % head height
                        {0.25in}  % head sep
                        {   9pt}  % foot height
                        { 0.3in}  % foot sep

\raggedbottom
%\setlength{\topskip}{1\topskip \@plus 5\p@}
\doublehyphendemerits=10000       % No consecutive line hyphens.
\brokenpenalty=10000              % No broken words across columns/pages.
\widowpenalty=9999                % Almost no widows at bottom of page.
\clubpenalty=9999                 % Almost no orphans at top of page.
\interfootnotelinepenalty=9999    % Almost never break footnotes.
\usepackage{fancyhdr}
\lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}}
\rhead[\fancyplain{}{\sl{\leftmark}}]{\rm\thepage}
\chead{}\lfoot{}\rfoot{}\cfoot{}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\btypeout{\thechapter\space #1}\markboth{\@chapapp\ \thechapter\ #1}{\@chapapp\ \thechapter\ #1}}
\renewcommand{\sectionmark}[1]{}
\renewcommand{\subsectionmark}[1]{}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\usepackage{amsmath,amsfonts,amssymb,amscd,amsthm,xspace}
\theoremstyle{plain}
\newtheorem{example}{Example}[chapter]
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{axiom}[theorem]{Axiom}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\usepackage[centerlast,small,sc]{caption}
\setlength{\captionmargin}{20pt}
\newcommand{\fref}[1]{Figure~\ref{#1}}
\newcommand{\tref}[1]{Table~\ref{#1}}
\newcommand{\eref}[1]{Equation~\ref{#1}}
\newcommand{\cref}[1]{Chapter~\ref{#1}}
\newcommand{\sref}[1]{Section~\ref{#1}}
\newcommand{\aref}[1]{Appendix~\ref{#1}}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\dbltopfraction}{.85}
\renewcommand{\floatpagefraction}{0.75}
\renewcommand{\dblfloatpagefraction}{.75}
\setcounter{topnumber}{9}
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20}
\setcounter{dbltopnumber}{9}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage[scriptsize]{subfigure}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{listings}
\usepackage{lstpatch}
\lstset{captionpos=b,
        frame=tb,
        basicstyle=\scriptsize\ttfamily,
        showstringspaces=false,
        keepspaces=true}
\lstdefinestyle{matlab} {
        language=Matlab,
        keywordstyle=\color{blue},
        commentstyle=\color[rgb]{0.13,0.55,0.13}\em,
        stringstyle=\color[rgb]{0.7,0,0} }
\usepackage[pdfpagemode={UseOutlines},bookmarks=true,bookmarksopen=true,
   bookmarksnumbered=true,hypertexnames=true,
   colorlinks,linkcolor={blue},citecolor={green},urlcolor={blue},
   pdfstartview={FitV},unicode,breaklinks=true]{hyperref}
\usepackage[colorlinks]{hyperref}
\pdfstringdefDisableCommands{
   \let\\\space
}
\newcommand*{\supervisor}[1]{\def\supname{#1}}
\newcommand*{\examiner}[1]{\def\examname{#1}}
\newcommand*{\degree}[1]{\def\degreename{#1}}
\newcommand*{\authors}[1]{\def\authornames{#1}}
\newcommand*{\addresses}[1]{\def\addressnames{#1}}
\newcommand*{\university}[1]{\def\univname{#1}}
\newcommand*{\UNIVERSITY}[1]{\def\UNIVNAME{#1}}
\newcommand*{\department}[1]{\def\deptname{#1}}
\newcommand*{\DEPARTMENT}[1]{\def\DEPTNAME{#1}}
\newcommand*{\group}[1]{\def\groupname{#1}}
\newcommand*{\GROUP}[1]{\def\GROUPNAME{#1}}
\newcommand*{\faculty}[1]{\def\facname{#1}}
\newcommand*{\FACULTY}[1]{\def\FACNAME{#1}}
\newcommand*{\subject}[1]{\def\subjectname{#1}}
\newcommand*{\keywords}[1]{\def\keywordnames{#1}}
\supervisor  {}
\examiner    {}
\degree      {}
\authors     {}
\university  {\texorpdfstring{\href{University Web Site URL Here (include http://)}
                {The University of ...}}
                {The University of ...}}
\UNIVERSITY  {\texorpdfstring{\href{University Web Site URL Here (include http://)}
                {THE UNIVERSITY OF WESTERN AUSTRALIA}}
                {THE UNIVERSITY OF WESTERN AUSTRALIA}}
\department  {\texorpdfstring{\href{Department or School Web Site URL Here (include http://)}
                {School of Physics}}
                {School of Physics}}
\DEPARTMENT  {\texorpdfstring{\href{Department or School Web Site URL Here (include http://)}
                {SCHOOL OF PHYSICS}}
                {SCHOOL OF PHYSICS}}
\group       {\texorpdfstring{\href{Research Group Web Site URL Here (include http://)}
                {International Centre for Radio Astronomy Research}}
                {International Centre for Radio Astronomy Research}}
\GROUP       {\texorpdfstring{\href{Research Group Web Site URL Here (include http://)}
                {...}}
                {...}}
\faculty     {\texorpdfstring{\href{Faculty Web Site URL Here (include http://)}
                {Physical Science}}
                {Physical Science}}
\FACULTY     {\texorpdfstring{\href{Faculty Web Site URL Here (include http://)}
                {PHYSICAL SCIENCE}}
                {PHYSICAL SCIENCE}}
\addresses   {}
\subject     {}
\keywords    {}
\renewcommand\maketitle{
  \btypeout{Title Page}
  \hypersetup{pdftitle={\@title}}
  \hypersetup{pdfsubject=\subjectname}
  \hypersetup{pdfauthor=\authornames}
  \hypersetup{pdfkeywords=\keywordnames}
  \thispagestyle{empty}
  \begin{titlepage}
    \let\footnotesize\small
    \let\footnoterule\relax
    \let \footnote \thanks
    \setcounter{footnote}{0}
    \null\vfil
    \vskip 60\p@
    \begin{center}
      \setlength{\parskip}{0pt}
      {\large\textbf{\UNIVNAME}\par}
      \vfill
      {\huge \bf \@title \par}
      \vfill
      {\LARGE by \par}
      \smallskip
      {\LARGE \authornames \par}
      \vfill
      {\large This thesis is presented for the degree of \par}
      {\large Doctor of Philosophy \par}
    {\large at the University of ... \par}
      \bigskip
      \bigskip
      \bigskip
      {\Large \@date \par}
      \bigskip
    \end{center}
    \par
    \@thanks
    \vfil\null
  \end{titlepage}
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
  \cleardoublepage
}
\newenvironment{abstract}
{
  \btypeout{Abstract Page}
  \thispagestyle{empty}
  \null\vfil
  \begin{center}
    \setlength{\parskip}{0pt}
    {\huge{\textit{Abstract}} \par}
  \end{center}
}
{
  \vfil\vfil\vfil\null
  \cleardoublepage
}
\addtocounter{secnumdepth}{1}
\setcounter{tocdepth}{6}
\newcounter{dummy}
\newcommand\addtotoc[1]{
\refstepcounter{dummy}
\addcontentsline{toc}{chapter}{#1}}
\renewcommand\tableofcontents{
\btypeout{Table of Contents}
\begin{spacing}{1}{
    \setlength{\parskip}{1pt}
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{
           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}
    \@starttoc{toc}
    \if@restonecol\twocolumn\fi
   \cleardoublepage
}\end{spacing}
}
\renewcommand\listoffigures{
\btypeout{List of Figures}
\addtotoc{List of Figures}
\begin{spacing}{1}{
    \setlength{\parskip}{1pt}
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename
      \@mkboth{\MakeUppercase\listfigurename}
              {\MakeUppercase\listfigurename}}
    \@starttoc{lof}
    \if@restonecol\twocolumn\fi
    \cleardoublepage
}\end{spacing}
}
\renewcommand\listoftables{
\btypeout{List of Tables}
\addtotoc{List of Tables}
\begin{spacing}{1}{
    \setlength{\parskip}{1pt}
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listtablename
      \@mkboth{
          \MakeUppercase\listtablename}{\MakeUppercase\listtablename}}
    \@starttoc{lot}
    \if@restonecol\twocolumn\fi
    \cleardoublepage
}\end{spacing}
}
\newcommand\listsymbolname{Abbreviations}
\usepackage{longtable}
\newcommand\listofsymbols[2]{
\btypeout{\listsymbolname}
\addtotoc{\listsymbolname}
    \chapter*{\listsymbolname
      \@mkboth{
          \MakeUppercase\listsymbolname}{\MakeUppercase\listsymbolname}}
\begin{longtable}[c]{#1}#2\end{longtable}\par
    \cleardoublepage
}
\newcommand\listconstants{Physical Constants}
\usepackage{longtable}
\newcommand\listofconstants[2]{
\btypeout{\listconstants}
\addtotoc{\listconstants}
    \chapter*{\listconstants
      \@mkboth{
          \MakeUppercase\listconstants}{\MakeUppercase\listconstants}}
\begin{longtable}[c]{#1}#2\end{longtable}\par
    \cleardoublepage
}
\newcommand\listnomenclature{Symbols}
\usepackage{longtable}
\newcommand\listofnomenclature[2]{
\btypeout{\listnomenclature}
\addtotoc{\listnomenclature}
    \chapter*{\listnomenclature
      \@mkboth{
          \MakeUppercase\listnomenclature}{\MakeUppercase\listnomenclature}}
\begin{longtable}[c]{#1}#2\end{longtable}\par
    \cleardoublepage
}
\newcommand\acknowledgements[1]{
\btypeout{Acknowledgements}
\addtotoc{Acknowledgements}
\thispagestyle{plain}
\begin{center}{\huge{\textit{Acknowledgements}} \par}\end{center}
{\normalsize #1}
\vfil\vfil\null

}
\newcommand\dedicatory[1]{
\btypeout{Dedicatory}
\thispagestyle{plain}
\null\vfil
\vskip 60\p@
\begin{center}{\Large \sl #1}\end{center}
\vfil\null
\cleardoublepage
}
\renewcommand\backmatter{
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \addtotoc{\bibname}
  \btypeout{\bibname}
  \@mainmatterfalse}
\endinput
%%
%% End of file `Thesis.cls'.

Please advise!

5
  • I also tried to load hyperref only in main doc or thesis.cls but it didn't work!
    – Soheil
    Nov 5, 2019 at 9:20
  • 3
    Welcome to TeX.SX! Don't post screenshots of code! Make minimal working example (MWE) instead. The option citecolor of hyperref can be adapted. hyperref should be imported as last package.
    – dexteritas
    Nov 5, 2019 at 9:29
  • Welcome to TeX.SE...Instead of posting image, please post a MWE of your code....
    – MadyYuvi
    Nov 5, 2019 at 9:29
  • Thanks for letting me know guys.
    – Soheil
    Nov 5, 2019 at 9:49
  • Your MWE should have a citation example.
    – sztruks
    Nov 5, 2019 at 10:36

1 Answer 1

2

It appears that hyperref package is already loaded in (lines 128-131 of) your Thesis.cls class file.

Use \hypersetup (in your manuscript, not the class file) to change the behaviour of hyperref. For instance if you want blue citations, use:

\hypersetup{citecolor=blue}

See this answer for a full list of the possibles :)

EDIT full details provided. I only commented line 117 of Thesis.cls to remove package lstpatch which was raising errors in my case (due to the absence of that package):

%\usepackage{lstpatch}

The main body is as follows:

% MNRAS Manuscript Template
\documentclass[useams,onecolumn,usenatbib,twoside]{Thesis}
%\pdfminorversion=5
%
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{lettrine}
%
%\usepackage{natbib}
\usepackage{amsmath}
\usepackage{setspace}
%\usepackage{pdfpages}
%\usepackage[times,hyper]{Rd}
\usepackage[utf8,latin1]{inputenc}
%\includepdfset{offset=2cm -2cm}
\usepackage{setspace}
\usepackage{lscape}
\usepackage{makeidx}
\graphicspath{{./images/}}
\usepackage[table,xcdraw,svgnames]{xcolor}
%\usepackage[colorlinks=true,
%           citecolor=blue,
%           linkcolor=blue,
%           urlcolor=red,
%           linktocpage=true,
%           hyperfootnotes=false]{hyperref}

%%%%%
% 
%%%%%

\hypersetup{citecolor=blue}

\makeindex{}
\begin{document}
\pagestyle{plain}
\pagenumbering{roman}
\DeclareGraphicsExtensions{.pdf,.png,.gif,.jpg}
%----------------------------------------------------------------------------------
%               Title Page
%----------------------------------------------------------------------------------
\begin{titlepage}
    \begin{center}
    \textsc {\LARGE The University of ...}\\[0.5cm]
    \textsc {\LARGE  \& }\\[0.5cm]
    \textsc{School of Physics}\\[0.5cm]
    \LARGE PhD Thesis\\[0.5cm]

    % Bottom of the page
    {\large \today}

    \end{center}
\end{titlepage}

%----------------------------------------------------------------------------------
%               Preamble
%----------------------------------------------------------------------------------

\clearpage
\include{Preamble}
\cleardoublepage
\pagenumbering{arabic}


%----------------------------------------------------------------------------------
%               Content
%----------------------------------------------------------------------------------

\section{Citation example}

First citation~\cite{latexcompanion}. 

Second where I change the citation color locally using braces:~{\hypersetup{citecolor=red}\cite{latexcompanion}}. 

The colour is set back to its previous value automatically~\cite{latexcompanion}.

\include{ChapterOne}
\include{ChapterTwo}
\include{ChapterThree}
\include{ChapterFour}
\include{ChapterFive}


\cleardoublepage
\addcontentsline{toc}{chapter}{References}
\bibliographystyle{mnras}
%\bibliography{library}
\begin{thebibliography}{9}
\bibitem{latexcompanion} 
Michel Goossens, Frank Mittelbach, and Alexander Samarin. 
\textit{The \LaTeX\ Companion}. 
Addison-Wesley, Reading, Massachusetts, 1993.
 \end{thebibliography}


\appendix
\include{AppendixOne}
\include{AppendixTwo}
\include{AppendixThree}
\printindex{}
\end{document}

Notice the \hypersetup{citecolor=blue} on line 34.

This produces the following result: enter image description here

6
  • I tried but didn't work! Its compiled properly but no change in colour!
    – Soheil
    Nov 5, 2019 at 10:20
  • I edited my answer. Based on my edit, could you please be more explicit on what is not working?
    – jchd
    Nov 5, 2019 at 10:38
  • Well, I commented out the lstpatch package and added hypersetup line as you advised, and recompiled the mainuscript. In the beginning didn't change the colour and gave me hyperref warning that draft mode on. Then I added \hypersetup{final} and It fixed the issue and colorized all the citations.
    – Soheil
    Nov 5, 2019 at 11:14
  • Anyhow, thank you very much for your help.
    – Soheil
    Nov 5, 2019 at 11:24
  • In that configuration, I had no warning (compiling with pdflatex) regarding hyperref. The only warning is about options useams and natbib not being used. Glad if it helped, you can mark this answer as accepted if it solved your issue.
    – jchd
    Nov 5, 2019 at 11:41

You must log in to answer this question.

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