6

I've got a system of equation splitted on multiple lines with the environment split and a reference to them, which I would like to point to the top of the system of equations. Here's my MWE:

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

\begin{document}
    \begin{equation}\label{mylabel}
    \begin{split}
    \tau y + \nabla \phi(x)=0 \\
    D^{-1} y - x=0 \\
    y^T x \leq 1
    \end{split}
    \end{equation}

    The conditions \eqref{mylabel}...
\end{document}

However, when I click on the hyperlink in the PDF output file, it directs me to the middle of the equation, rather than pointig to the top of it.

I already know the package hypcap, but it only works within floating environments...

2
  • 2
    eqref links to the equation number. Do you also want to shift it to the first line or do you want to keep it vertically centered?
    – Benjamin
    Commented Feb 16, 2016 at 12:24
  • I would like it to point to the first line of the equation: keeping it vertically centered means that the reader, after clicking on the link, sees only the second and the third line, and has to scroll the page up to read the first one too.
    – Rackbox
    Commented Feb 17, 2016 at 13:16

1 Answer 1

5

An alternative is to put the \refstepcounter inside the equation, as long as the \lable comes BEFORE the \tag.

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

\begin{document}
  \raisebox{\dimexpr-\abovedisplayskip-\baselineskip}[0pt][0pt]%
  {\hbox{\refstepcounter{equation}\label{mylabel}}}%
    \begin{equation*}
    \begin{split}
    \tau y + \nabla \phi(x)=0 \\
    D^{-1} y - x=0 \\
    y^T x \leq 1
    \end{split}\tag{\theequation}
    \end{equation*}

    The conditions \eqref{mylabel}...
\end{document}

The hyperref version of \refstepcounter places a \hypertarget at that location. The hyperref version of \label saves the value of the last counter incremented by \refstepcounter along with \thepage, \@currentlabel and \@currentHref. \tag uses a user supplied equation number, and the equation counter is not incremented (or both incremented and decremented).

4
  • Nice solution, thank you! Can you explain better how did you do it and what do the commands you added do?
    – Rackbox
    Commented Feb 17, 2016 at 13:20
  • @JohnKormylo I think you missed the *. It should be \begin{equation*} ... \end{equation*}.
    – Benjamin
    Commented Feb 17, 2016 at 13:29
  • @Benjamin - You are right. Even with the \tag a \hypertarget {equation.0.2} would be created by the first equation. Commented Feb 17, 2016 at 18:49
  • @JohnKormylo: your answer is almost perfect now, but doing this way the pointer brings the PDF viewer to the line before the equation, and not exactly on the first line of the equation, like here.
    – Rackbox
    Commented Feb 19, 2016 at 14:26

You must log in to answer this question.

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