Generalchanging colour of links

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

changing colour of links

Post by juliette »

I know that I can do this:
--------------------------------------------------------------------
\hypersetup{
colorlinks=false, % false: boxed links; true: colored links
linkcolor=red, % color of internal links
citecolor=green, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=cyan % color of external links
}
--------------------------------------------------------------------
to make sure that my hyperlinks don't change color.


But what if I want some of my links to change color and some not to?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

changing colour of links

Post by localghost »

juliette wrote:[…] But what if I want some of my links to change color and some not to?
What do you exactly mean with that? Be more precise. When posting the same request also in another forum, please mention this [1]. It prevents users from wasting time in case that a solution is given already elsewhere.

[1] CQF.info :: View topic - Changing color of links


Best regards and welcome to the board
Thorsten¹
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

changing colour of links

Post by juliette »

I apologize for not mentioning that I posted the same question elsewhere. I was unaware that the two forums were related.

With regards to being more specific:

I have various links to external URLs on the web from my document which I created in LaTeX using \href{}{}.

When I apply this command, the argument of the second {} is displayed in a navy blue colour in the resulting PDF file.

However, for some hyperlinks, I want the colour to remain black and still link to a URL.

And for others, i DO indeed want the link to become navy blue.

Is this possible?


And I posted this response on CQF as well.
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Re: changing colour of links

Post by juliette »

Here's the answer. It was posted by user gmedina on CQF.

\documentclass[10pt]{article}
\usepackage{hyperref}
\hypersetup{
colorlinks=true, % false: boxed links; true: colored links
linkcolor=red, % color of internal links
citecolor=green, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=cyan % color of external links
}

\newcommand*{\myhref}[2]{%
\hypersetup{urlcolor=black}\href{#1}{#2}\hypersetup{urlcolor=cyan}}

\begin{document}

\href{http://www.cqf.info}{CQF.info}

\myhref{http://www.cqf.info}{CQF.info}

\href{http://www.cqf.info}{CQF.info}

\end{document}
Post Reply