Search code examples
mathjax

How to refer to an equation in a different page with Mathjax


I have several html pages with a lot of equations rendered by Mathjax. I would like to refer to several equations not especially in the same page.

The problem is that "\eqref" is only working if the equation is in the same page.

One solution would be to use "\tag{}" for all equations and use simple html links.

For example,

\label{myequation} \tag{4.1}  

and the link would be

"<a href="http://www.mysite.com/mypage#myequation"> 4.1 </a>"

The problem with that solution is that I need to have personal tag for all equations.

Does anyone has a solution for referring to equations in different pages by producing tags automatically ?


Solution

  • See the documentation for automatic equation numbering. This allows you to have your equations numbered automatically rather than requiring \tag. Note that any numbered or tagged equation automatically gets an ID that can be used in a link, so there is no requirement to use \label (though it helps if you are adding and removing equations during editing). If an equation is numbered 5, then the id is mjx-eqn-5. There are functions that you can override in order to change the format of the equation numbers. See the equationNumbers section of the TeX configuration parameters documentation.

    Edit: Now that I understand your request, I can tell you that to do what you ask for would require MathJax to know the label-to-tag mapping for the other pages in your site (not just the page currently being viewed). MathJax doesn't have that data available to it. The only way to do it would be to create data files for the other pages that includes that data so that MathJax could load it and have it available. While technically possible, it would be a bit cumbersome to do that, especially since JavaScript (normally) can't write files for you.

    On the other hand, the only place the label-to-tag mapping is needed is for the text that acts as the link itself (that is, if eq:sum refers to equation 4.1, then you would want "4.1" to be the text that links to that equation. Note that the link itself will be to myotherpage#eq:sum, so the only thing that needs the number is the link text itself. If you were willing to use something like "[sum]" as the link text for eq:sum (e.g., "In equation [sum] we see..."), then you would not need the label-to-tag mapping, and \eqref could be modified to handle that. But if you really want the equation number as the link, you would need a lot more infrastructure to make that happen.