3

I have the following equation:

\begin{equation}\tag{E$_{n}$}\label{E}
 f_n(x)=a
\end{equation}

When I write \eqref{E} I am referred to the equation and it is written E_n

My question is: how to be referred to the same equation and write for example E_{n-1} rather then E_n?

4
  • 3
    As a writer but more importantly as reader of scientific papers I beg you: please, please don't do that ;-)
    – campa
    Jul 26, 2020 at 19:46
  • 1
    Welcome to TeX.SE! Instead of writing See Equation \eqref{E} you can also just write see Equation (E$_{n-1}$), so don't use \eqref at all if you don't want to use the tag. But I guess that would be very confusing for the reader?
    – Marijn
    Jul 26, 2020 at 19:47
  • 2
    The question/intent is ill formed, as the reference is just that, a reference to the equation, which you have given a specific (non-numeric) name to. If you wish to change the formula, then this produces a dangling reference, which does not refer to anything.
    – oliversm
    Jul 26, 2020 at 19:49
  • I want that when the reader click on E_{n-1}, he will be directed to the equation. Indeed, the equation is written as a function of n, and when we write E_{n-1} it will be clear for the reader how he can deduce it.
    – Ghizlane
    Jul 26, 2020 at 19:53

2 Answers 2

4

You can do like this:

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

\DeclareRobustCommand{\tagindex}{\ensuremath{_{\defaulttagindex}}}
\newcommand{\defaulttagindex}{n}
\DeclareRobustCommand{\indexedref}[2][n]{%
  \begingroup\def\defaulttagindex{#1}\ref{#2}\endgroup
}
\DeclareRobustCommand{\indexedeqref}[2][n]{%
  \begingroup\def\defaulttagindex{#1}\eqref{#2}\endgroup
}

\begin{document}

\begin{equation}\tag{E\tagindex}\label{E}
 f_n(x)=a
\end{equation}

We refer to~\indexedeqref{E}, but also to~\indexedeqref[n-1]{E}.

\end{document}

enter image description here

3

For this use case you can use the command \hyperref[label]{text} from the hyperref package. It creates a (clickable) link to the label with the text being shown in the document (and not the default label text).

MWE:

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{amsmath}
\begin{document}
\begin{equation}\tag{E$_{n}$}\label{E}
 f_n(x)=a
\end{equation}
See Equation \eqref{E}, also known as Equation (\hyperref[E]{E$_{n-1}$}).
\end{document}

Result:

enter image description here

You must log in to answer this question.

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