I want to create a command alternative to \ref
to distinguish links between 2 different colours (say, black and red).
In my code below I have simply use the answer here and replaced \href
with \ref
. It does not work but I don't know how to fix it.
\documentclass[10 pt,a4paper,oneside,openany, notitlepage]{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{amsmath, amssymb, graphics}
\usepackage[colorlinks = true,
linkcolor = black,
urlcolor = black,
citecolor = black,
anchorcolor = black]{hyperref}
\newcommand\MYref[3][red]{\ref{#2}{\color{#1}{#3}}}% %NEW COMMAND ALTERNATIVE TO REF
\begin{document}
\section{Title}
\label{blah}
\begin{equation}
\label{eq1}
A=B
\end{equation}
See Section \MYref{blah2}
See Equation \ref{eq1} or \MYref{eq1}
\newpage
\section{Title2}
\label{blah2}
\end{document}
What I want is the link (to an equation, section, subsection, figure, etc) displaying in red when I use \Myref
and displaying in black when I use \ref
.
\MYref
as taking 3 arguments (one being optional) in the preamble, yet to invoke the macro with just 1 argument in the body of the document. Please clarify what you're trying to achieve.article
does not know theopenany
option