Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have tried to find a way to customize how internal links are colored, but I don't yet have the expertise in finding and redefining commands. In the LaTeX example below, I describe how I would like to change the colors of various links. Any ideas or examples are much appreciated.

\documentclass{article}

\usepackage[backref=true]{biblatex}
\begin{filecontents}{refs.bib}
@book{cit1,
title = {The backreferences should be yellow},
author = {Last, First}
}
\end{filecontents}
\bibliography{refs.bib}

\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[colorlinks=true,
            linkcolor=red,
            urlcolor=blue,
            citecolor=gray]{hyperref}

\begin{document}

\title{Title}
\maketitle
\tableofcontents
\listoffigures

\section{Table of content's links should be green}
\label{s1}
All text, captions, and section headers after the list of figures
should be black. The citation links should be gray.\autocite{cit1}
\subsection{Table of content's subsections links should be orange}
Internal links like this section link \ref{s1} 
or this figure link \ref{f1} should be blue.

\begin{figure}[h]
\caption{List of figures links red}
\label{f1}
\end{figure}

\printbibliography

\end{document}
share|improve this question
    
Welcome to TeX.SE! This sounds like an interesting question, but are you sure that you want such an output? Have you ever seen a document that uses so many different colours? It sounds like it might be a little overwhelming... –  cmhughes Feb 17 '13 at 2:11
    
@golbasche, you may accept my post if you think it answers your question. –  Umar Kalim Feb 18 '13 at 6:21
    
I know this output sounds ridiculous ;) However, I do not intend to make my document a rainbow of colors. I only chose these colors for an easy to see testing environment. I will choose more subtle colors and formats once I figure out how to change everything. Thanks! –  Kevin Feb 19 '13 at 0:36
add comment

1 Answer

up vote 11 down vote accepted

The hyperref options can be configured using the \hypersetup command and colors are enabled by colorlinks=true.

A MWE is below. citecolor is set to gray. For the table of contents link colors, linkcolor is set to green before the \tableofcontents command. Similarly for the list of figures, linkcolor is set to red before the \listoffigures command. Later linkcolor is set to blue for the internal links.

I was unable to make the table of contents's sub-section links appear in orange color.

\documentclass{article}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[backref=true,backend=biber,natbib=true,hyperref=true]{biblatex}
\bibliography{refs}

\usepackage{hyperref}
\hypersetup{
     colorlinks   = true,
     citecolor    = gray
}
\begin{document}

\title{Title}
\maketitle
\hypersetup{linkcolor=green}
\tableofcontents
\hypersetup{linkcolor=red}
\listoffigures
\hypersetup{linkcolor=blue}

\section{Table of content's links should be green} \label{s1}
All text, captions, and section headers after the list of figures 
should be black. The citation links should be gray~\cite{cit2}. 
\subsection{Table of content's subsections links should be orange} 
Internal links like this section link \ref{s1} or this figure link 
\ref{f1} should be blue.

\begin{figure}[h]
\caption{List of figures links red}
\label{f1}
\end{figure}
\nocite{*}

\printbibliography
\end{document}

Here is a screenshot of the output: enter image description here

share|improve this answer
    
Thank you Umar. You got me one step closer. I would concede the request with the color orange. However, I'd still like to change the colors of the backref links. –  Kevin Feb 19 '13 at 0:38
1  
Ah. It wasn't hard to figure out the last thing after looking at the code in more detail. I added \hypersetup{linkcolor=yellow} before \printbibliography and I got what I wanted. Thanks! –  Kevin Feb 19 '13 at 0:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.