question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MathML: spacing after \mathrm containing single letter

See original GitHub issue

Describe the bug: Extra spacing appears after \mathrm{...} containing a single letter [a-zA-Z], for MathML output.

(La)TeX code:

\mathrm{d}x

See JSFiddle.

Expected behavior: No spacing between \mathrm{d} and x.

Screenshot: katex-mathml-mathrm

Environment (please complete the following information):

  • KaTeX Version: 0.11.1
  • Device: Desktop
  • OS: Debian GNU/Linux 9.12 (stretch)
  • Browser: Firefox
  • Version: 71.0

Additional context:

  • Weirdly, if one wraps either a digit (\mathrm{1}) or more than one character (\mathrm{dd}), the after-spacing does not appear.
  • Usually I define a total differential macro like this: \mathop{}\!\mathrm{d}.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ronkokcommented, Mar 26, 2020

how KaTeX decides what MathML to output

I’m not one of the original KaTeX developers and cannot speak to the thinking behind those decisions. I believe that early KaTeX wrote each character in its own MathML element. More recent versions have done some consolidation for better semantics. For instance, numbers, \text{…}, and \operatorname{…} each consolidate their contents into a single MathML element. Perhaps other consolidations would be beneficial.

0reactions
kevinbarabashcommented, Aug 1, 2020

Adding a <mi></mi> to work around what appears to be a browser bug isn’t ideal. A Firefox-only CSS tweak to change the spacing might be better.

Using <mo> &DifferentialD; </mo> for differentials would be awesome. The tricky thing is that the LaTeX for the dx is like any other identifiers. In order to recognize it as a differential operator we’d need to introduce a bunch of additional logic.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3 Presentation Markup
Also, when style sheet mechanisms are extended to MathML, even one version of a renderer may use different spacing rules for users with...
Read more >
Rules for space when using \mathrm{} - LaTeX Stack Exchange
Between two atoms of type Ord, TeX inserts no space. To the contrary, 3\ln\left(x\right). contains again three atoms ...
Read more >
Notes on MathML
When the first example is rendered, there is nothing before “Theorem”, one Unicode space character between “Theorem” and “1:”, and nothing after ......
Read more >
LaTeX Error: \mathrm allowed only in math mode - Overleaf
LaTeX Error: \mathrm allowed only in math mode ; \mathit{...} This will give text italic letters. These can be different to math italic...
Read more >
Help:Displaying a formula - Wikipedia
There are three methods for displaying formulas in Wikipedia: raw HTML, HTML with math templates (abbreviated here as {{math}}), and a subset of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found