Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using multiple \eqref's inside an equation #2540

Closed
parhizkari opened this issue Sep 15, 2020 · 5 comments
Closed

using multiple \eqref's inside an equation #2540

parhizkari opened this issue Sep 15, 2020 · 5 comments
Labels
Code Example Contains an illustrative code example, solution, or work-around Duplicate Fixed v3 v3.1
Milestone

Comments

@parhizkari
Copy link

Issue Summary

When multiple \eqref{}'s are used inside an equation, the number of the equations shown are all correct, but sometimes some of them link to wrong equations.
I'm in Firefox, in Lubuntu.

Steps to Reproduce:

A minimal example to show the behavior:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>window.MathJax = {tex:{tags:"ams"}};</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg-full.js"></script>
</head>
<body>
Hello ...
\begin{align}
\cdots\label{eq1}\\
\cdots\label{eq2}\\
\cdots\label{eq3}
\end{align}
now test referring to the equations inside another equation
\begin{equation}
\eqref{eq1},\,\eqref{eq2},\,\eqref{eq3}:\qquad \ldots
\end{equation}
</body>
</html>

You can also try it with only first two equations, then both links will link to the second, the eq2.

Technical details:

  • MathJax Version: 3.1.2
  • Client OS: Lubuntu
  • Browser: Firefox 80 64bit

Supporting information:

  • no error in the console
@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Investigate v3 labels Sep 15, 2020
@dpvc
Copy link
Member

dpvc commented Sep 15, 2020

OK, I can reproduce the issue using your example file. I will have to look into it. So clue what is happening at this point.

@dpvc
Copy link
Member

dpvc commented Sep 15, 2020

I spoke too soon, I do know what it is. It is actually issue #2530. The SVG output uses a transparent <rect> object as a hotbox for the <a> element so that you don't have top be over the ink of the glyph but anywhere it its bounding box. But because the hitboxes are misplaced, the one for the reference to equation 3 lies on top of the one for equation 1, and so clicking on it links to an unexpected equation.

There is already a proposed fix, but I haven't posted a configuration that will do a patch on the fly. I will see about posting one as soon as I can.

@dpvc dpvc added Duplicate and removed Accepted Issue has been reproduced by MathJax team Investigate labels Sep 15, 2020
@parhizkari
Copy link
Author

Thanks a lot

@dpvc
Copy link
Member

dpvc commented Sep 19, 2020

@parhizkari, here is a configuration that patches the link issue:

MathJax = {
  startup: {
    ready() {
      const {SVGWrapper} = MathJax._.output.svg.Wrapper;
      const place = SVGWrapper.prototype.place;
      SVGWrapper.prototype.place = function (x, y, node) {
        place.call(this, x, y, node);
        if ((x || y) && !node && this.node.attributes.get('href')) {
          const translate = 'translate(' + this.fixed(x) + ', ' + this.fixed(y) + ')';
          const rect = this.adaptor.previous(this.element);
          this.adaptor.setAttribute(rect, 'transform', translate);
        }
      };
      MathJax.startup.defaultReady();
    }
  }
}

@parhizkari
Copy link
Author

It worked great, fantastic, thank you 👍

@dpvc dpvc added this to the 3.1.3 milestone Mar 31, 2021
@dpvc dpvc added the Code Example Contains an illustrative code example, solution, or work-around label Apr 1, 2021
@dpvc dpvc closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Example Contains an illustrative code example, solution, or work-around Duplicate Fixed v3 v3.1
Projects
None yet
Development

No branches or pull requests

2 participants