Page MenuHomePhabricator

Determine block mode vs. inline mode properly for MathJax
Closed, ResolvedPublic


In all these formulas

\sum_{0\le i\le m\atop 0<j<n}P(i,j)

the PNG shows the subscript below the symbol, while MathJax puts them in the lower left corner. Consistency would be nice, but not necessary.

Version: unspecified
Severity: minor



Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:16 AM
bzimport added a project: Math.
bzimport set Reference to bz35188.
bzimport added a subscriber: Unknown Object (MLST).

Created attachment 10325
the png version


d516e253331adc958db85ac9bd720017.png (48×145 px, 1 KB)

Created attachment 10326
the mathjax version

They look similar to me. What browser and version do you have, might be browser specific issue ?


Screen_Shot_2012-03-25_at_22.13.48.png (57×136 px, 8 KB)

I found out where the problem is:

While texvc renders every formula in block mode ($$), MathJax is able to render both for block mode and inline mode ($). But the configuration for this in MathJax/extensions/wiki2jax.js is not ideal. Have a look at the ConvertMath function. Block mode is only chosen for formulas directly inside a <DD> with only one child, i. e. when a formula is indented using colons. This will fail when formulas are wrapped inside a span (see bug 35191). Furthermore formulas which form there own paragraph should be treated as block, too. Currently there is some code to insert \displaystyle etc. to do this.

I created a test page on This shows that it actually looks as expected, but a cleaner code would be nice.

Perhaps some code like

if ( $formula.closest( 'p, div, dd' ).text() === $formula.text() ) {
} else {

works, but I didn't test this.

Nageh said something about this that is relevant when he detailed his changes:

Heuristic detection of inline vs. display maths. Heuristic used: parent HTML element is "DD" and maths element is the only child, then interpret as "display maths", otherwise as "inline maths". Also, if the maths element is classified as "inline maths" but the element is the first child in the parent "DD", precede the maths with "\displaystyle": this effectively treats the maths as a display-style formula but without the newline of ordinary display maths formulas. See ConvertMath() function in User:Nageh/mathJax/config/TeX-AMS-texvc_HTML.js.

  • Bug 36062 has been marked as a duplicate of this bug. ***

From bug 36062:
The added \displaystyle also appears on [right click]-Show Math As-TeX Commands, which might be confusing for users.

I've not done the oiint part yet, we will have to add that later. (Gerrit Change Ie0c308c31d38581e556dc73109879c7a3d365121) | change APPROVED and MERGED [by jenkins-bot]

Gerrit patch got merged, can this bug report get closed as RESOLVED FIXED or is there anything else to do?

Tested with

Formula <math>\bigwedge_x</math> in text.

Here comes a formula:


Here comes an indented formula:


Everything looks as it should.