TeX - LaTeX Asked by Ghizlane on September 5, 2021
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
?
You can do like this:
documentclass{article}
usepackage{amsmath}
usepackage{hyperref}
DeclareRobustCommand{tagindex}{ensuremath{_{defaulttagindex}}}
newcommand{defaulttagindex}{n}
DeclareRobustCommand{indexedref}[2][n]{%
begingroupdefdefaulttagindex{#1}ref{#2}endgroup
}
DeclareRobustCommand{indexedeqref}[2][n]{%
begingroupdefdefaulttagindex{#1}eqref{#2}endgroup
}
begin{document}
begin{equation}tag{Etagindex}label{E}
f_n(x)=a
end{equation}
We refer to~indexedeqref{E}, but also to~indexedeqref[n-1]{E}.
end{document}
Correct answer by egreg on September 5, 2021
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:
Answered by Marijn on September 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP