0

How can I individually set the color of the hyperlinks ? It currently has a red box around it.

\href{www.google.com}{Test}

How can I select its color ? Like

\href{www.google.com}{Test}{boxcolor=blue}

I have many other boxes to put with different colors so Id rather repeatedly type a short idiot-friendly method then redefine the function definitions.

  • 1
    Reading the manual of hyperref helps: \hypersetup{linkcolor=blue}, for example – user31729 Feb 13 '18 at 15:47
  • @ChristianHupfer - But it doesn't help that much. urlcolor is the one you want, but it only works with colorlinks=true. I think the box colors are chosen by the PDF viewer. – John Kormylo Feb 13 '18 at 17:32
  • @JohnKormylo: True, I missed that it is about urls – user31729 Feb 13 '18 at 17:35
  • 1
    \usepackage[colorlinks,urlcolor=orange]{hyperref} to avoid the ugly boxes and fix a default organge color for URL links, and then \href{http://www.example.com}{\color{blue}www.example.com} to make a individual link in blue. – Fran Feb 13 '18 at 22:08
2

You can use {\color{<color>}\url{<url>}} or \href{<url>}{\color{<color>}<text>}. A macro could simplify only a little this:

\documentclass{article}
\usepackage{xcolor}
\usepackage[hidelinks]{hyperref}
\newcommand\colorlink[3]{\href{#2}{\color{#1}#3}}
\newcommand\colorurl[2]{{\color{#1}\url{#2}}}
\linespread{1.3}

\begin{document}

\obeylines

\href{http://www.example.com}{www.example.com} 
\colorlink{purple}{http://www.example.com}{www.example.com}  
\colorlink{violet}{http://www.example.com}{www.example.com}{blue}   
\colorlink{blue}{http://www.example.com}{www.example.com}{cyan}  

\bigskip

\url{http://www.example.com}
\colorurl{purple}{http://www.example.com}
\colorurl{violet}{http://www.example.com}
\colorurl{blue}{http://www.example.com}

\end{document}

In the odd case that you want link boxes instead of colored text, remove any package option incompatible with that boxes (e.g. colorlinks or hidelinks) and then use some like:

\hypersetup{urlbordercolor=orange} 
\url{http://www.example.com}
\hypersetup{urlbordercolor=cyan}   % return to default color

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.