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

Strange bug with using \tag after \color #2643

Closed
kwankyu opened this issue Mar 8, 2021 · 3 comments
Closed

Strange bug with using \tag after \color #2643

kwankyu opened this issue Mar 8, 2021 · 3 comments
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Fixed Test Needed v3 v3.1
Milestone

Comments

@kwankyu
Copy link

kwankyu commented Mar 8, 2021

This is with MathJax version 3.

In the source webpage, after this math display

\[
	\begin{aligned}
	\color{red}{1}
	\end{aligned}
\]

I have this math display

\[\tag{S}
\]

On the rendered webpage, the second display shows a strange error

     \tag is not allowed in aligned environment

This seems a bug in MathJax.

@dpvc
Copy link
Member

dpvc commented Mar 16, 2021

I can reproduce the result, and yes, it does seem to be a bug. Thanks for the report. I will investigate further.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Investigate v3 labels Mar 16, 2021
@dpvc dpvc added this to the 3.1.3 milestone Mar 16, 2021
@dpvc dpvc self-assigned this Mar 16, 2021
@dpvc
Copy link
Member

dpvc commented Mar 16, 2021

OK, I figured it out. The tagging module keeps a stack of tagging information (as different environments are started and stopped), and it turns out that during the autoload of the color extension, the tag information was not being reset when the equation was being re-rendered. That left an extra tagging information object on the stack, and that ended up being the initial state for the next equation (instead of a blank one).

Here is a configuration that I think will fix the issue for you.

MathJax = {
  startup: {
    ready() {
      const {AbstractTags, TagInfo} = MathJax._.input.tex.Tags;
      const clearTag = AbstractTags.prototype.clearTag;
      const startEquation = AbstractTags.prototype.startEquation;
      AbstractTags.prototype.clearTag = function () {
        clearTag.call(this);
        this.currentTag.tagId = '';
      }
      AbstractTags.prototype.startEquation = function (math) {
        this.history = [];
        this.stack = [];
        this.clearTag();
        this.currentTag = new TagInfo('', undefined, undefined);
        startEquation.call(this, math);
      }
      MathJax.startup.defaultReady();
    }
  }
}

I will make a pull request that makes these changes for the next release.

@kwankyu
Copy link
Author

kwankyu commented Mar 17, 2021

Thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Code Example Contains an illustrative code example, solution, or work-around Fixed Test Needed v3 v3.1
Projects
None yet
Development

No branches or pull requests

2 participants