Page MenuHomePhabricator

\frac 1 {\binom{n}{k}} font size too large
Closed, ResolvedPublicBUG REPORT

Assigned To
Authored By
SalixAlba
Aug 11 2026, 8:34 AM
Project Tags
Referenced Files
F102282846: screenshot.png
Wed, Sep 9, 4:29 PM
F102265041: screenshot.png
Wed, Sep 9, 11:10 AM
F101729222: Screenshot 2026-09-03 at 3.18.52 PM.png
Thu, Sep 3, 10:19 PM
F101494080: Screenshot 2026-09-02 at 15.30.45.png
Wed, Sep 2, 10:32 PM
F101487132: Screenshot 2026-09-02 at 14.59.50.png
Wed, Sep 2, 10:05 PM
F101487129: Screenshot 2026-09-02 at 14.59.48.png
Wed, Sep 2, 10:05 PM
F100605691: image.png
Sat, Aug 29, 7:05 AM
F98107942: image.png
Sat, Aug 29, 7:05 AM

Description

Steps to replicate the issue (include links if applicable):

  • Set math mode to Client side MathJax
  • Enter formula
\textstyle \frac{k-1}{k} \sum_{j=0}^\infty \frac 1 {\binom {j+x} k}= \frac{\binom{x-1}{k-1} }{n}

https://www.mediawiki.org/wiki/Extension:Math/Native_MathML/Reported_Cases#New_cases_since_Aug_2026

What happens?:

Renders as

Screenshot 2026-08-19 at 14.55.25.png (1,450×932 px, 130 KB)

What should have happened instead?:

The binomial coefficients should be rendered with a reduced font size (as the MathJax-server SVG)

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Ecosia browser (chromium)

More test cases at https://www.mediawiki.org/wiki/Extension:Math/T434456

Event Timeline

With \choose the font size is deduced but the surrounding brackets are too big.

\displaystyle \frac n { {n+k} \choose k}

image.png (412×775 px, 39 KB)

Krinkle triaged this task as High priority.Wed, Aug 19, 6:34 PM
Krinkle renamed this task from \frac 1 {\binom{n}{k}} does not decrease font size to \frac 1 {\binom{n}{k}} font size too large.Wed, Aug 19, 9:57 PM
Krinkle updated the task description. (Show Details)

As this is also state-related, let's first try to get consensus on T434456.

PS: As @FrederikHennecke1 has finished implementing the output tree, we could replace the state with pseudo-tree elements.

This might also explain the problem with

\frac{\sum_{k=1}^N k^2}{a}

that renders as in MathML and Client side SVG

image.png (172×191 px, 3 KB)

with limits above and below the sum. Rather than

image.png (336×206 px, 9 KB)

in MathML with limits, like in \textstyle, to the right of the Sigma symbol.

I think I'll remove some special case "fixes" and stick to the official LaTeX manual as a reference.

Change #1332680 had a related patch set uploaded (by Physikerwelt; author: Physikerwelt):

[mediawiki/extensions/Math@master] Respect contextual binomial sizing

https://gerrit.wikimedia.org/r/1332680

Change #1332680 merged by jenkins-bot:

[mediawiki/extensions/Math@master] Respect contextual binomial sizing

https://gerrit.wikimedia.org/r/1332680

Change #1334070 had a related patch set uploaded (by Krinkle; author: Physikerwelt):

[mediawiki/extensions/Math@wmf/1.47.0-wmf.17] Respect contextual binomial sizing

https://gerrit.wikimedia.org/r/1334070

Change #1334070 merged by jenkins-bot:

[mediawiki/extensions/Math@wmf/1.47.0-wmf.17] Respect contextual binomial sizing

https://gerrit.wikimedia.org/r/1334070

Mentioned in SAL (#wikimedia-operations) [2026-09-02T21:50:39Z] <krinkle@deploy1003> Started scap sync-world: Backport for [[gerrit:1334068|Extract MathJax DOM filter into a separate file (T435274)]], [[gerrit:1334070|Respect contextual binomial sizing (T434477 T418144 T401718)]], [[gerrit:1334032|Remove the last vestiges of $wgVirtualRestConfig (T436054)]]

Mentioned in SAL (#wikimedia-operations) [2026-09-02T21:54:57Z] <krinkle@deploy1003> krinkle: Backport for [[gerrit:1334068|Extract MathJax DOM filter into a separate file (T435274)]], [[gerrit:1334070|Respect contextual binomial sizing (T434477 T418144 T401718)]], [[gerrit:1334032|Remove the last vestiges of $wgVirtualRestConfig (T436054)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-09-02T22:04:53Z] <krinkle@deploy1003> Finished scap sync-world: Backport for [[gerrit:1334068|Extract MathJax DOM filter into a separate file (T435274)]], [[gerrit:1334070|Respect contextual binomial sizing (T434477 T418144 T401718)]], [[gerrit:1334032|Remove the last vestiges of $wgVirtualRestConfig (T436054)]] (duration: 14m 14s)

It's definitely a lot smaller now. I wonder if maybe it's too small?

BeforeAfter
Screenshot 2026-09-02 at 14.59.48.png (1,130×732 px, 59 KB)
Screenshot 2026-09-02 at 14.59.50.png (1,130×725 px, 56 KB)

via https://en.wikipedia.org/wiki/Special:ExpandTemplates

<math forcemathmode=mathml>\textstyle \frac n {\binom {n+x} k}</math>
<math forcemathmode=mathjax>\textstyle \frac n {\binom {n+x} k}</math>

Practical example at https://www.mediawiki.org/w/index.php?title=User:Krinkle/MathML_Shortlist&oldid=8576888 looks better:

Screenshot 2026-09-02 at 15.30.45.png (1,454×904 px, 129 KB)

I think it would be a somewhat okay size if we used a dedicated font for the smaller text. in the new default font for "client-side SVG" mode, which is already on the thin side for regular size, anything this small starts getting extremely thin, to the point it's hard to read

Here's what this looks like when rendered with LaTeX, using usual defaults:

Screenshot 2026-09-03 at 3.18.52 PM.png (460×158 px, 14 KB)

Apologies if I am missing something, but it is my understanding that this bug has been fixed and that the fix has been deployed. Yet when I look at https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Mathematics/MathFormattingBugs I still get oversized binomial coefficients with client-side rendering:

screenshot.png (1,673×473 px, 134 KB)

Is this normal?

As @Krinkle explained to me, the reason why I was still experiencing this bug after deployment of the fix was that the rendered SVG was cached.

However, with the fix the binomial coefficient are now too small and hard to read on my setup:

screenshot.png (1,664×461 px, 135 KB)

In fact, I think the problem only partly comes from the size, and that it also comes from the font: the new font is already much lighter than the previous one, and as a result of this many small symbols are hard to read.

Font size issues will hopefully be improved when the proposed CSS changes at https://en.wikipedia.org/wiki/MediaWiki_talk:Common.css#Alignment_of_%3Cmath_display=block%3E

You can see the effect of these changes by using

mjx-container[display] {  
	margin-left: 1.6em !important;
	text-align: left !important;
}
math.mwe-math-element-block {  
	display: flex;
  	justify-content: left;
	margin-left: 1.6em;
    margin-top: 0.6em;
    margin-bottom: 0.6em;
	font-size: 118%;
}
math.mwe-math-element-inline {
	font-size: 118%;
}
span.mwe-math-fallback-source-display {  
	margin-left: 1.6em;
    margin-top: 0.6em;
    margin-bottom: 0.6em;
}

in your https://en.wikipedia.org/wiki/Special:MyPage/common.css file.

The font size for math should be the same as the font size for adjacent text. Bumping the font size for all math is a terrible idea.

Nearly all professional typography of technical documents uses math fonts which are roughly comparable in size to the text font. It would be incredibly distracting to have the font size change repeatedly within the same sentence, and would have the effect of mAKinG oUr ArtICLeS LoOk LiKe a RANsom nOtE.