5

It seems that if I change from boxed links to coloured links using the \hypersetup{colorlinks=false,true} command from the hyperref package, this has a global effects on all types of links, be it link, cite or URL.

I like my links and cites default red/green boxed, but I don't like how the blue boxes in my bibliography are, and would like to change the, and only them, to blue text. Can this be done? I use \href in my bibliography like this

\documentclass{article}

\usepackage{hyperref}
 %\hypersetup{colorlinks=true,urlcolor=blue} Don't want this because will change 
 %links and cites too
\begin{document}

 \begin{thebibliography}
  \bibitem{some}
  \href{http://some.url}{Some Ref}
 \end{thebibliography}

\end{document}

Whereas links and cites are just using the \ref{} and \cite{} commands and the global hyperref effect.

1
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Feb 4, 2014 at 15:32

2 Answers 2

4

This is just a workaround.

You can declare the following hyper setup locally in the bibliography

\hypersetup{pdfborder={0 0 0}}

Also define a new command \hrefblue

\newcommand{\hrefblue}[2]{%
  \href{#1}{\textcolor{blue}{#2}}%
}

and use it instead of \href inside the bibliography.

MWE:

\documentclass{article}

\usepackage{xcolor}
\usepackage{hyperref}

\newcommand{\hrefblue}[2]{%
  \href{#1}{\textcolor{blue}{#2}}%
}

\begin{document}

\section{Citing}\label{sec:first}

In section \ref{sec:first} we cite \cite{some}.

{\hypersetup{pdfborder={0 0 0}}
 \begin{thebibliography}{9}
  \bibitem{some}
  \hrefblue{http://some.url}{Some Ref}
 \end{thebibliography}}

\end{document} 

Output:

enter image description here

1

You can't change colorlinks from false to true; but you can change the colors if colorlinks is set to true.

\documentclass{article}

\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  %allcolors=black,% all colors are black
  urlcolor=black,% only links are black
}

\begin{document}

\href{http://u.v}{AB}

\hypersetup{urlcolor=blue}
\begin{thebibliography}{1}
 \bibitem{some}
 \href{http://some.url}{Some Ref}
\end{thebibliography}

\end{document}

enter image description here

2
  • Yes, that is the desired result for the \href{}s in the bibliography but with your code I lose the green and red in text boxes, around \ref{}s and \cite{}s, that I would like to keep.
    – user23112
    Feb 4, 2014 at 17:00
  • @user23112 Then, use urlcolor=black instead of allcolors=black.
    – egreg
    Feb 4, 2014 at 17:09

You must log in to answer this question.

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