3

My question relates to here. I am trying to define new commands for hyperref. For example, I want to have some equations to be called: Function, Constraint, or Constraint Set. To do it, I tried to follow the instructions provided in the hyperlink.

\def\HyLang@english{%
      \def\functionautorefname{Function}%
      \def\conssetautorefname{Constraint set}%
      \def\consautorefname{Constraint}%
    }

And, I failed using it as follows:

\begin{equation}\label{consset:sum_all=1}
    y_j^A+y_j^I+y_j^P=1 \qquad \forall j\in J
\end{equation}

\autoref{consset:sum_all=1} ensures that everything is alright!

which still prints as:

Equation (<eq number>) ensures that everything is alright!

while I want:

Constraint set (<eq number>) ensures that everything is alright!

Is there any quick solution?

tcokyasar
  • 233

1 Answers1

2

\autoref cannot know what type of object you're referring to.

You can use cleveref that's more customizable and more powerful.

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{cleveref}

\crefformat{equation}{#2Equation~\textup{(#1)}#3} % by default eq. (<eq>) is used
\crefformat{constraint}{#2Constraint~\textup{(#1)}#3}

\begin{document}

\begin{equation}\label{eq}
equation
\end{equation}

\begin{equation}\label[constraint]{co}
constraint
\end{equation}

We can refer to \cref{eq} and to \cref{co}.

\end{document}

enter image description here

egreg
  • 1,121,712