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

Broken links with Mathjax \eqref #2222

Open
DavidPowell opened this issue Aug 23, 2018 · 2 comments
Open

Broken links with Mathjax \eqref #2222

DavidPowell opened this issue Aug 23, 2018 · 2 comments

Comments

@DavidPowell
Copy link

I have Mathjax equations within my slides, and I have enabled automatic equation with Mathjax autonumbering. I then create an equation label with \label and refer to it later with \eqref

For example, I create the following slide:

<section>
	\begin{equation} \label{straightline}
	y = mx+c
	\end{equation}
	
	Equation \eqref{straightline} is a straight line
</section>

The equation is numbered correctly, and the link to it has the correct number as well.

However, mathjax turns the \eqref into a link, which does not seem to work within reveal.js - it just jumps to the first slide.

Is there easy any way that such links could be corrected to point to the slide on which the equation appears?

Failing that, does anyone know how to stop mathjax from creating these hyperlinks? Cleary it is better to have no hyperlink rather than a broken one.

Note, in order to get auto-numbering working, I have the following mathjax config lines to my html file, in addition to including the math plugin

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
		TeX: { equationNumbers: { autoNumber: "AMS" } },
    });
</script>
@ndaman
Copy link

ndaman commented Jan 16, 2019

I am having the same issue (although with manual numbering and using \ref instead of \eqref), and would appreciate any advice.

For reference, although I write my equations in an external markdown file, I can see by inspecting elements that there is an <mtd id="mjx-eqn-eqref">..</mtd> generated, which the reference tries to link to using <a href="#mjx-eqn-eqref">...</a>

There are two issues I can see. One is that the href format is missing a /, it should read <a href="#/mjx-eqn-eqref">...</a> to link properly, but even when I force that change in the browser, it links to the first slide, but when I give the id "mjx-eqn-eqref" to the slide (and manually change the link) it does link as expected.

I'm not sure how to proceed from here, as it seems both a fix to how MathJax links are created and how internal links are handled with reveal.js are needed to solve this issue.

@chnchg
Copy link

chnchg commented Sep 27, 2022

I am using MathJax 3.1 and work around this problem by using the tagformat extension. The following will slide to the page of the referred equation upon click.

tagformat:{
    url:(id,base)=>{
        var i = Reveal.getIndices(document.getElementById(id).closest('section'));
        return 'javascript:Reveal.slide('+i.h+','+i.v+')';
    }
}

You can turn off the link by returning an empty string ''.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants