[Tex/LaTex] Switch between box and color links with hyperref

hyperreflinks

How can I have both boxed and color links in the same document? I know I can use \usepackage[colorlinks]{hyperref} and have colored links instead of boxes, but how do I have both in the same document. The MWE below yields:

enter image description here

Notes:

  • This is intended for use only in the review version of the document where I want to be able to distinguish different types of links. In the final version there will be a single style.

Code:

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\href{www.google.com}{The Google} 

\hypersetup{colorlinks=true, urlcolor=blue}
\href{www.google.com}{The Google} 

\hypersetup{colorlinks=false}
\href{www.google.com}{The Google} 
\end{document}

Best Answer

If colorlinks is activated, then the color can be disabled by using the current color . that is provided by package xcolor. The setting for pdfborder enables or disables the annotation frame:

\documentclass{article}
\usepackage{xcolor}
\usepackage[colorlinks]{hyperref}

\AtBeginDocument{%
  \hypersetup{pdfborder={0 0 1}, urlcolor=.}%
}

\begin{document}
\href{www.google.com}{The Google}

\hypersetup{pdfborder={0 0 0}, urlcolor=blue}
\href{www.google.com}{The Google}

\hypersetup{pdfborder={0 0 1}, urlcolor=.}
\href{www.google.com}{The Google}

\textcolor{red}{\href{www.google.com}{The Google}}
\end{document}

Result

Related Question