Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am interested in linking to an equation - but being able to change the text.

I had thought I could combine this answer and this answer, but I cannot seem to get it to work.

I have attempted a variety of syntaxes similar to

\hyperref[eq:name]{my text describing the equation here}

but I cannot seem to get it to work.


This is the code I am currently using (well my equation is considerably more complicated but I have the same problem here)

\begin{align*} 
 y = x\label{testp}
\end{align*}
\hyperref[testp]{generalized form}

I get the following warning

LaTeX Warning: Hyper reference `testp' on page 4 undefined on input line 108.
share|improve this question

1 Answer 1

up vote 3 down vote accepted

For this it is easiest to use a \hypertarget and \hyperlink combination since you technically don't have a "counter that you can reference" - this is provided by \refstepcounter, which marks a position that you can hyperlink to:

enter image description here

\documentclass{article}
\usepackage{amsmath,hyperref}% http://ctan.org/pkg/{amsmath,hyperref}
% Taken from http://tex.stackexchange.com/a/17138/5764
\makeatletter
\newcommand{\labeltarget}[1]{\Hy@raisedlink{\hypertarget{#1}{}}}
\makeatother
\begin{document}
\begin{align*}
  y = x \labeltarget{testp}
\end{align*}
\hyperlink{testp}{generalized form}
\end{document}

Since \hypertarget sets its target at the baseline, it has to be raised for any practical application. See \hypertarget seems to aim a line too low.

share|improve this answer
    
This took a weird sequence of compiling but eventually worked (you seemingly need to compile the \newcommand successfully before you can use the \labeltarget). Thanks much - LaTeX is sure neat :) –  enderland Nov 13 '12 at 3:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.