2

I am using \href{} from the hyperref package. Here's a MWE:

\documentclass{article}
\usepackage[colorlinks]{hyperref}
    \hypersetup{}
\begin{document}
\href{http://google.com}{Click me!}
\end{document}

This results in a PDF where the entire Click me! line is hyperlinked. The trouble is, when I add a color option then the clickable area in the resulting PDF is extremely short.

\href{http://google.com}{\color{black}}{Click me!}

Why is this? How do I avoid this?

I don't want to change the color option in the preamble (e.g. \hypersetup{urlcolor = black}) because there are many other hyperlinks that I want a different color. I just want to change this one URL.

Thanks!

0
4

You need to make sure that both \color{black} and the string "Click me!" are in the second argument of \href -- in the same "group", to use TeX jargon. You should thus write

\documentclass{article}
\usepackage[colorlinks]{hyperref}
    \hypersetup{}
\begin{document}
\href{http://google.com}{\color{black}Click me!}
\end{document}

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.