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

Double brackets with negative space appear misplaced #3341

Open
agrigoriadis1977 opened this issue Mar 11, 2025 · 1 comment
Open

Double brackets with negative space appear misplaced #3341

agrigoriadis1977 opened this issue Mar 11, 2025 · 1 comment
Labels
Cannot Reproduce Code Example Contains an illustrative code example, solution, or work-around v4

Comments

@agrigoriadis1977
Copy link

agrigoriadis1977 commented Mar 11, 2025

Issue Summary

In version 4 of MathJax we use double brackets with negative space, but one of the brackets appears misplaced on top and right from where it should be.

Steps to Reproduce:

  1. Use version 4 and enter: \([\![r,s]\!]=\{r,r{+}1\}\)
  2. See how the brackets appear
  3. If you use version 3.2.2 it appears correctly
  4. If you strip the second part of the equation like that: \([\![r,s]\!]\) it appears correctly
  5. Adding only one more character (like "=") causes the problem

Technical details:

  • MathJax Version: 4: all the versions up to 4.0.0-beta.7

I am using the following MathJax configuration:

no configuration at all

and loading MathJax via

<script src="node_modules/mathjax/tex-mml-chtml.js" id="MathJax-script" async></script>

where 4.0.0 version has been installed via npm

Supporting information:

See the image below (version 4)

Image

and version 3:

Image

@dpvc
Copy link
Member

dpvc commented Mar 11, 2025

I am not able to reproduce the issue of the misplaced bracket, but I do see the reduced spacing in the second bracket (that you didn't mention). This turns out to be due to the fact that the negative space is being treated as a potential line break, and the tags used to do that seem to be interfering with the spacing. It may also be that the displaced brace is due to the same cause. (The current develop branch doesn't exhibit the spacing problem, so that may have been resolved somewhere along the way.)

One potential solution is to put braces around the whole expressions, which will prevent in-line linebreaking within the expression. That should clear it up.

Another option is to use the fact that the fonts in v4 have more extensive character coverage, and that includes U+27E6 (MATHEMATICAL LEFT WHITE SQUARE BRACKET) and U+27E7 (MATHEMATICAL RIGHT WHITE SQUARE BRACKET). So you could use

\(\U{27E6}r,s\U{27E7}=\{r,r{+}1\}\)

to get single-character versions of the brackets. You can, of course, create macros for this, such as

\newcommand{\llbrack}{\U{27E6}}
\newcommand{\rrbrack}{\U{27E7}}

\(\llbrack r,s\rrbrack=\{r,r{+}1\}\)

or something similar. You can use

MathJax = {
  tex: {
    macros: {
      llbrack: '\u27E6',  // an explicit U+27E6 character
      rrbrack: '\u27E7'
    }
  }
};

as part of your configuration in order to pre-define those macros.

@dpvc dpvc added Cannot Reproduce Code Example Contains an illustrative code example, solution, or work-around v4 labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cannot Reproduce Code Example Contains an illustrative code example, solution, or work-around v4
Projects
None yet
Development

No branches or pull requests

2 participants