# Box around reference and citation

I want to add a border around my internal references and citation. I have tried what is suggested in this post.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{backref=true,
pagebackref=true,
hyperindex=true,
urlcolor= black,
bookmarks=true,
bookmarksopen=false,
citecolor=black,
filecolor=black,
citecolor=blue,
}

\title{test}

\usepackage{natbib}
\usepackage{graphicx}

\begin{document}

\maketitle

\section{Introduction}

\begin{align}\label{eq:1}
\ln(ab)=\ln(a) + \ln(b)
\end{align}

my equation is \ref{eq:1}

\end{document}


While the citation colour did change to blue, there is no blue border around equation and figure references.

Do I have to set a parameter to TRUE like colorlinks to enable the link border to be visible.

• hyperref explicitly checks at \begin{document} whether colorlinks is set to true, and if so, set pdfborder to {0 0 0}. Maybe one way to go around this is to pass \AtBeginDocument{\hypersetup{pdfborder={0 0 1}}} again. – Troy Jul 28 '17 at 8:02

The hyperref package explicitly checks at \begin{document} whether colorlinks is set to true, and if so, set pdfborder to {0 0 0} (which means no border).

One way to go around this is to pass \AtBeginDocument{\hypersetup{pdfborder={0 0 1}}} so that this behaviour is negated, like so:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{backref=true,
pagebackref=true,
hyperindex=true,
urlcolor= black,
bookmarks=true,
bookmarksopen=false,
filecolor=black,
citecolor=blue,
}

\AtBeginDocument{\hypersetup{pdfborder={0 0 1}}}% <-----------

\begin{document}
\section{Introduction}

$$\label{eq:1} \ln(ab)=\ln(a) + \ln(b)$$

my equation is \ref{eq:1}

\end{document}


You are defined linkcolor two times, first one is blue and the second time redefined as black, so as LaTeX, most recent defined term will execute, so it the link color turned to black, please remove it and check...

            \hypersetup{backref=true,
pagebackref=true,
hyperindex=true,