[Tex/LaTex] How to add “link boxes” to \href that disappear when printing

hyperref

I want to:

  • make \href more visible by adding boxes (in red or green) like the other hyperref links have.

  • Ideally, I want this boxes to show up in the PDF but disappear when the PDF is printed (otherwise I can just generate two documents, one for viewing and one for printing).

EDIT:

the boxes disappear if in the following I uncomment the colorlinks line

\definecolor{darkblue}{rgb}{0.0,0.0,0.3}
\hypersetup{
 %          colorlinks,
            breaklinks,
            linkcolor=darkblue,
            urlcolor=darkblue,
            anchorcolor=darkblue,
            citecolor=darkblue
           }

Is there a way to be able to color \href links while preserving the box?

Best Answer

By default there is a cyan box around the \href link text:

\documentclass{article}

\usepackage{hyperref}

\begin{document}
\href[page=2]{http://mirrors.ctan.org/macros/latex/contrib/mwe/mwe.pdf}{MWE-Manual
  Page 2}
\end{document}

is shown as:

cyan \href link

The cyan border is not printed. It is only visible in the PDF viewer.

hyperref itself does not provide colored links with borders. Option colorlinks always switches off the link borders. But you can try to set pdfborder to 0 0 1 after hyperref has activated colored links in \begin{document}:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\AtBeginDocument{\hypersetup{pdfborder={0 0 1}}}

\begin{document}
\href{http://mirrors.ctan.org/macros/latex/contrib/hyperref/hyperref.pdf}{hyperrref manual}
\end{document}

This will result in

enter image description here

I do not like this. It's just too much.

Related Question