Page MenuHomePhabricator

Provide an "indented display" styling for formulæ in lieu of the ":<math>" hack
Open, Needs TriagePublic

Description

Visual Editor exploits the new <math display="block"> ...</math> display mode.

Currently this appears center aligned. This conflicts with the convention on the English wikipedia [citation needed] which formats maths equations left aligned and indented one space, by using
:<math>...</math>
this gets translated to a <dd> tag.

Ideally we use the same appearance for existing display maths equations and those produced by VE. We can make the display="block" maths appear like the : format using CSS

.mwe-math-fallback-image-display,
.mwe-math-mathml-display {
   margin-left: 1.6em !important;
}
.mwe-math-mathml-display math {
   display: inline;
}

which I thinks works in PNG/SVG and MathML.

I've discussed that at https://en.wikipedia.org/wiki/Wikipedia:VisualEditor/Feedback#Indentation_for_mathematical_equations

Details

Related Gerrit Patches:
mediawiki/extensions/Math : masterVE: Add a '$$' sequence

Event Timeline

SalixAlba created this task.Sep 7 2015, 5:48 PM
SalixAlba raised the priority of this task from to Needs Triage.
SalixAlba updated the task description. (Show Details)
SalixAlba added projects: Math, VisualEditor.
SalixAlba added a subscriber: SalixAlba.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 7 2015, 5:48 PM
Esanders closed this task as Declined.Sep 8 2015, 3:06 PM
Esanders claimed this task.
Esanders added a subscriber: Esanders.

This hack is for a specific wiki, so you should add it to that wiki's common.css.

(Also, this is nothing to do with VisualEditor; block mode of the Math extension is that extension's decision.)

Jdforrester-WMF set Security to None.

As well as a specific wiki this task addresses the default for all wiki's. These seem to be specified at https://phabricator.wikimedia.org/diffusion/EMAT/browse/master/modules/ext.math.css

If we look at various wiki's, the German, French, Spanish, Italian, Netherlands, Polish, Russian, Swedish, and Vietnamese wikis (all those wikis with >1,000,000 articles) all use the follow the one space indent convention. Checked by looking at the corresponding wiki's articles for Cone. https://de.wikipedia.org/wiki/Kegel_(Geometrie) etc

There is a good case that appropriate CSS should be used as the default, and it should be discussed.

What you're showing is that people either (a) don't know about or (b) don't want to use the styling of display="block" for this use case. That's different from "There is no valid use case of the current styling so we should change it to be what I suggest".

This comment was removed by DavidEppstein.

I admit that VE is a bit off topic, but I as explained on WP:VE/F it does impact on VE. As far as I can see there is currently no way for VE to produce display maths equations which match the dominant style conventions. I can't see an option to produce the definition list <dd> tag through VE. For VE to be usable in maths articles either <dd> needs to be supported or the CSS suggestion needs to be rolled out to all wikis. A slightly more flexible option might be to have display="indent" option, but that might be overkill.

I admit that VE is a bit off topic, but I as explained on WP:VE/F it does impact on VE.

Almost everything in MediaWiki and its extensions impacts on VE. :-)

As far as I can see there is currently no way for VE to produce display maths equations which match the dominant style conventions. I can't see an option to produce the definition list <dd> tag through VE.

That's T39938: Support for creating and editing definition-lists in VisualEditor.

For VE to be usable in maths articles either <dd> needs to be supported or the CSS suggestion needs to be rolled out to all wikis.

I do not think it's appropriate to change how the Maths extension works for all wikis for all time just to work around a missing VE feature.

A slightly more flexible option might be to have display="indent" option, but that might be overkill.

I actually quite like that idea. @Physikerwelt, what do you think?

Ozob added a subscriber: Ozob.Sep 9 2015, 2:55 AM

This problem is more about the interface between VE and the Math extension rather than a problem with either one of them. English Wikipedia has been using :<math> as the standard displayed equation format since I began editing as an IP over a decade ago. As Salix Alba noted, similar formatting is standard on all the other large Wikipedias. Because this formatting is everywhere, we're either in the uncomfortable situation of changing hundreds of thousands if not millions of articles, or we're in the unpleasant situation of VE users being unable to edit articles with displayed formulas (including not just mathematics, but also physics, chemistry, theoretical computer science, all branches of engineering, some biology articles,...).

In the long run, I don't mind if <math display="block"> or <math display="indent"> becomes standard. I think I'd even prefer it. But in order for there to be a clear transition path from the present to the future, the styling ought to be similar to the styling everyone uses now. Because of that, the change ought to be in ext.math.css.

Just to slightly update the CSS. You need
.mwe-math-fallback-image-display,
.mwe-math-mathml-display {

margin-left: 1.6em !important;
margin-top: 0.6em;
margin-bottom: 0.6em;

}
.mwe-math-mathml-display math {

display: inline;

}
To get the top and bottom margins to match the DL style. The values seem accurate to 1px.

Jdforrester-WMF renamed this task from CSS for <math display="block"> to Provide an "indented display" styling for formulæ in lieu of the ":<math>" hack.Sep 10 2015, 3:38 PM
Jdforrester-WMF reopened this task as Open.
Jdforrester-WMF added a project: Design.

I think display="block|indent" meaning center/left is a bit confusing. Alignment should probably be another attribute:

<math display="block" align="center/indent"> (or just 'left' instead of indent)

As a breaking change we could change the default alignment to "indent" or make it a per-wiki setting.

Ozob added a comment.Sep 10 2015, 7:41 PM

Having a separate alignment attribute sounds overly complicated to me. Ordinary mathematics publishing has just two types of equations, inline and displayed. All inline equations are formatted the same way and all displayed equations are formatted the same way, and that consistency makes everything more legible.

Right now I can't think of a use case for having a separate alignment attribute. The only situations that come to mind where you want something aligned are (1) If the equation is in a table (but then the alignment should be controlled by the table); (2) Equation numbers are flush left or flush right (at least on the English Wikipedia we discourage equation numbers in displayed math); (3) Internal alignment between several rows of the equation or equations (not relevant here). Though there may be others that I'm not thinking of.

Jdforrester-WMF removed Esanders as the assignee of this task.Sep 17 2015, 12:02 AM

@Jdforrester-WMF: Sorry for the delayed response... I was on vacation.
My semantically driven view on the things is that there should only be two options "inline" or "block". Writing a bot that converts :<math to <math display="block" and using css rules that the layout does not change is my personal preference.
While I personally like the centered layout like it is used in scientific papers better than the indented version I got the impression that the mayority of math editors prefers the indented version.
If there is consensus, I'm happy to change the default rendering of block to indent ... leaving the centering option availible via css so that wiki admins can change this based on their preferences.
However, I'm a little bit afraid that if we change the block behaviour someone will complain.

Physikerwelt updated the task description. (Show Details)Sep 17 2015, 7:30 AM

I agree with the sentiment of having only the inline or block options, with some wiki-local rendering settings to determine the block formatting. Experience has shown that if you give Wikipedia editors two incompatible formatting options they will use both of them and create inconsistencies, and that seems unnecessary here. I have no strong feeling about whether centered or indented is better for block math in the abstract, but keeping the current indented formatting on Wikipedia for now seems likely to cause the least disruption.

As for globally replacing :<math> by <math display="block"> to achieve better semantics: this seems harmless enough but the new syntax would be a bit more annoying to type by hand. I suppose it's too much to ask that we get \[ ... \] as a wiki-shortcut for block math? The Wikipedia template system could be used to produce a shortcut instead I suppose but matching TeX syntax if possible would be conceptually easier.

I suppose it's too much to ask that we get \[ ... \] as a wiki-shortcut for block math?

Yes.

The Wikipedia template system could be used to produce a shortcut instead I suppose but matching TeX syntax if possible would be conceptually easier.

If we made display=block the default, we'd need to go change the (relatively few) inline examples, but it'd be a lot easier in future (in fact, there'd be one fewer characters to write for the default case).

If we made display=block the default, we'd need to go change the (relatively few) inline examples, but it'd be a lot easier in future (in fact, there'd be one fewer characters to write for the default case).

I've just done a quick test on one of the dump and it seems like 2/3rd of occurrences of <math> tags are inline, so display=block should not be the default. Overall there is in the region of 500,000 equations in 35,000 articles in the English wikipedia, so its no small task to change all the existing occurrences.

I've just done a quick test on one of the dump and it seems like 2/3rd of occurrences of <math> tags are inline, so display=block should not be the default.

Oh, interesting. Then let's not, yeah.

Overall there is in the region of 500,000 equations in 35,000 articles in the English wikipedia, so its no small task to change all the existing occurrences.

Trivial bot work is trivial. :-)

I suppose it's too much to ask that we get \[ ... \] as a wiki-shortcut for block math?

Yes.

Oh well, I can understand why not but no harm in asking. Thanks for the response.

I suppose it's too much to ask that we get \[ ... \] as a wiki-shortcut for block math?

Yes.

Oh well, I can understand why not but no harm in asking. Thanks for the response.

We could try to make a <dmath> element that converts itself into <math display="block"> for non visual editor users.

He7d3r added a subscriber: He7d3r.Oct 24 2015, 11:50 AM

Change 248066 had a related patch set uploaded (by Physikerwelt):
VE: Add a '$$' sequence

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

Change 248066 abandoned by Jforrester:
VE: Add a '$$' sequence

Reason:
Abandon for now.

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

Restricted Application added a subscriber: StudiesWorld. · View Herald TranscriptNov 18 2015, 1:58 AM

Overall there is in the region of 500,000 equations in 35,000 articles in the English wikipedia, so its no small task to change all the existing occurrences.

Trivial bot work is trivial. :-)

Also the old syntax of :<math (not block)> will still work, so there'll be no hurry to convert them.

the problem is
(1) the old :<math> is only identical to <math display="block"> in the English wikipedia due to custom css and
(2) it is awkward to write compared to :<math>

(1) the old :<math> is only identical to <math display="block"> in the English wikipedia due to custom css and

The proposal is upstream this CSS into the extension.

(2) it is awkward to write compared to :<math>

It is a bit longer, but :<math> is semantically just plain wrong. We need to keep the wikitext sensible, but abusing other features (definition lists) to achieve the desired styling is untenable.

Ozob added a comment.Dec 6 2015, 3:47 PM

It is a bit longer, but :<math> is semantically just plain wrong. We need to keep the wikitext sensible, but abusing other features (definition lists) to achieve the desired styling is untenable.

I would add that using :<math> makes it nigh impossible to make global changes to the styling of displayed equations. Sure, you could restyle by updating every article using a bot; but if the consensus on styling changes, then you have to update the whole encyclopedia again. Whereas using <math display="block"> makes such changes easy.

(2) it is awkward to write compared to :<math>

It is a bit longer, but :<math> is semantically just plain wrong. We need to keep the wikitext sensible, but abusing other features (definition lists) to achieve the desired styling is untenable.

I've a feeling changing this syntax is likely to enrage much of the maths community. The current syntax has served the community well for 10 years and some are going to take a lot of convincing that there is any advantage in this.

I would consider discussing this on wikiproject mathematics. If it is too be made compulsory then adding a button to the wikitext editor might help.

I think we can proceed with this proposal now. Community adoption is a separate issue that doesn't block this technical task.

It is I think inaccurate to state that the semantics of ":", as used by Wikipedia editors, is "just plain wrong". The intended meaning of this markup is almost always "indent this block of text", a reasonable thing to do and a reasonably clean way to mark it up. The part that is semantically wrong is the conflation of this markup with ;: description-list semantics, and the use of description lists by the Wikimedia engine to indent blocks of text that semantically should be indented some other way. Regardless of that quibble, this change seems like an improvement: display equation math should be rendered in different ways than inline math and it's important to have a way to code that rather than letting the engine guess which style to use with no way to control it when it guesses wrong.

I wonder, though: in some instances Wikipedia already has indented blocks of text that mix display-style mathematics with non-mathematical text. (As a simple example of why you might want this: suppose that a displayed equation is the end of a sentence or paragraph that needs to be referenced. Where does the reference go?) Would there be any way to handle this with the new proposal, or would that still have to be rendered the old way, with :<math>? This probably makes no difference to the proposal — if we can clean up the semantics of most displayed mathematics, that's still an improvement even if we can't get all of them — but it may mean that care is needed if anyone wants to bulk-replace the old form with the new one within Wikipedia.

Where does the reference go?

References are designed to go with inline text content, not block content. You wouldn't try and stick a [1] in the top right corner of a large image - it would go with text above/below it or in a caption, e.g.:

The following equation is commonly used:<ref>source</ref>
<math indented>...<math>

Your answer reflects a fundamental misunderstanding of how mathematics is written. Equations are part of the text, not separate sidebar things, regardless of whether they are displayed inline or as separate display equations. For instance, your sample sentence should probably end with a period, in the displayed equation. That period can be inside the math tags, but a reference can't.

Ozob added a comment.EditedDec 15 2015, 8:25 PM

For examples of what David Eppstein is talking about, see for instance:

https://books.google.com/books?id=spiaBAAAQBAJ&lpg=PP1&dq=Calculus&pg=PA3#v=onepage&q&f=false
https://books.google.com/books?id=e7FJM6aqZD8C&lpg=PP1&dq=lax%20linear%20algebra&pg=PA1#v=onepage&q&f=false
https://books.google.com/books?id=Xnu0o_EJrCQC&lpg=PP1&dq=differential%20equations&pg=PA1#v=onepage&q&f=false

These are math books from a variety of publishers at a variety of difficulty levels. All of them use displayed equations with an equation number at the left or right side of the equation.

Consider also the recommendation of Swanson et al., Mathematics Into Type, updated edition, 3.3.1, available [[ ftp://ftp.ams.org/pub/author-info/documentation/howto/mit-2.pdf | here ]] courtesy of the American Mathematical Society:

When displays are numbered, the most common practice is to place this number in parentheses at the margin. Some publishers place them at the left margin, others at the right. As long as a consistent style is used, the placement is not important. The predominant practice among American publishers of mathematics is to place the equation number at the left margin...

Equations are part of the text, not separate sidebar things, regardless of whether they are displayed inline or as separate display equations.

I can not agree more. However, I'd very much like to eliminate the default rendering style, which is neither display nor inline style. I think there is a general consensus how to write mathematics with TeX and the simple inline $ should be treated in the same way it's done in TeX. Currently we replace $ by ${ \displaystyle if the display attribute is not set. This is counter intutive for me. In addition there should be a second mode similar to \begin{align} where align can as well be another math environment. This is rendered as \begin{align*}
I would very much apprechiate an option to add numbering but I can't implement that alone.
Today display="block" corresponds to \begin{align*} and display="inline" corresponds to the simple $
We can generally discuss to simplyfy the input for display and inline style, but I think those two options should be sufficient.

I totally agree with Physikerwelt. However:

  • If the long term goal is to replace the :<math> syntax, then the new semantics has to be shorter than <math display="block">, otherwise it will never get accepted
  • The same is true for <math display="inline">, which means we need the $$ sequence
  • Using the VE it is impossible to replace :<math> with <math display="block">. Upstreaming the CSS into the extension does not change this.

I totally agree with Physikerwelt. However:

  • If the long term goal is to replace the :<math> syntax, then the new semantics has to be shorter than <math display="block">, otherwise it will never get accepted

we could also analyse the content of the math tag and spot for (\begin{(align|...)|\displaystyle|...). Do you think that would be a good approach?

  • The same is true for <math display="inline">, which means we need the $$ sequence

display inline would be $, or did I miss something?

  • Using the VE it is impossible to replace :<math> with <math display="block">. Upstreaming the CSS into the extension does not change this.

Maybe, I miss something again, but I was assuming that that's soething very easy https://en.wikipedia.org/wiki/Help:Displaying_a_formula#/media/File:Editing_a_formula_using_VisualEditor.png

I totally agree with Physikerwelt. However:

  • If the long term goal is to replace the :<math> syntax, then the new semantics has to be shorter than <math display="block">, otherwise it will never get accepted

we could also analyse the content of the math tag and spot for (\begin{(align|...)|\displaystyle|...). Do you think that would be a good approach?

I don't think that would be a good approach.

  • It is not obvious to the editors how their formula will render
  • It would make it impossible to use the inline style symbols in a block equation or the other way around (this could be desired in tables or align environments to adjust the size of certain symbols)
  • The automatic numbering of equations is probably easier to implement when there is a clear distinction between the two options
  • The same is true for <math display="inline">, which means we need the $$ sequence

display inline would be $, or did I miss something?

Sorry, i meant $

  • Using the VE it is impossible to replace :<math> with <math display="block">. Upstreaming the CSS into the extension does not change this.

Maybe, I miss something again, but I was assuming that that's soething very easy https://en.wikipedia.org/wiki/Help:Displaying_a_formula#/media/File:Editing_a_formula_using_VisualEditor.png

Generating <math display="block"> is easy. I just wanted to emphasize that replacing the :<math> needs the normal editor, because VE would only replace it with :<math display="block"> which gets indented twice

Pkra moved this task from Incoming to MW Math Extension on the Math board.Dec 8 2018, 12:11 AM