3

I want to change the border color of my hyperref links depending on an input variable for the \myLabel command.

In this MWE all links are colored blue. How can I use a third input variable in my command to tell him to change this color just for a particular label and not overall in the hyperref settings?

MWE

\documentclass{article}
\usepackage{color}
\usepackage[linkbordercolor={0 0 1}]{hyperref}

\makeatletter
\newcommand\myLabel[2]{\def\@currentlabel{#2}\phantomsection\label{mylabel:#1}{#2}}
\newcommand\myRef[1]{\ref{mylabel:#1}}
\makeatother

\begin{document}
  \section*{Test Section}
  \myLabel{TEST_LABEL}{TEST-LABEL-TEXT}\\
  MORE TEXT\\
  \myRef{TEST_LABEL}
\end{document}

Output Output

1 Answer 1

3
  1. With

     \usepackage{xcolor}
    

    color names can be used instead of raw numbers in linkbordercolor.

  2. The color can be changed locally in a group with \hypersetup, e.g.:

     \newcommand\myRef[1]{%
       \begingroup
         \hypersetup{linkbordercolor=red}%
         \ref{mylabel:#1}%
       \endgroup
     }
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .