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

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
Aklapper moved this task from MW Math Extension to Incoming on the Math board.Jun 24 2020, 5:28 AM
Ozob added a comment.Nov 26 2020, 6:08 PM

It has been years since <math display="block"> was introduced, but as the previous link from @Esanders hints, :<math> is still more popular—despite its disadvantages. People have often complained about the relative difficulty of typing <math display="block>, so I wonder if the situation would be improved by introducing new tags that are easier to type. One could imagine new <mathblock> and <mathinline> tags. They would be synonyms for <math display="block"> and <math display="inline">. The existing <math> tag would not change.

I feel like this would be a low-risk change; but it's no help if it doesn't catch on. What does everyone else think?

@Ozob I think math power users would like to have a shortcut that expands \[ to <math display=block></math> and \( to <math display=inline></math> moreover, a bot might convert the old syntax.

Physikalerwelt's suggestion of backslashed parens and backslashed brackets would be greatly preferable to new longer and nonstandard tags, both because they're much easier to type and because (unlike the math tags) they're familiar and standard TeX syntax that works in other contexts (LaTeX documents and many other web sites). I think this would be much likelier to catch on and actually change the culture of using colons for displayed math.

Izno added a subscriber: Izno.Nov 27 2020, 1:49 PM

@Ozob I think math power users would like to have a shortcut that expands \[ to <math display=block></math> and \( to <math display=inline></math> moreover, a bot might convert the old syntax.

I don't think that will fly for non-math users. Maybe a compromise solution like <math>\[</math> for a block and <math> as normal for inline.

@Izno. I agree. I was not very clear about what I mean by expansion. I was referring to the expansion during input. I was looking at the codebase today. Currently, you can type <math which brings up a popup to enter LaTeX. This does not attach any display information; thus, the - to my mind broken - default inline-displaystyle is used. Adding here \(and \[ seems something that can be implemented in a few hours. Rewriting the parser to interpret \( rather than <math in the wiki-text source is something which I would not dare to try, even though I would like to have it (and how it is currently done in the Encyclopedia of Mathematics).

Looking at
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Math/+/248066
which was deleted 5 years ago reduces my hope, that \( will go through. :-(

Ozob added a comment.EditedNov 27 2020, 8:49 PM

I think @Izno's suggestion above is extremely promising. Syntax like <math display="block">, <mathblock>, or <dmath> will only ever be specific to MediaWiki. But math-inclined editors almost surely already know the meaning of \[ and $$, making constructions like <math>\[x=y\]</math> intuitive. That makes it likely that people will actually use this syntax. Backwards compatibility should be good: Right now, \[ and \] cause syntax errors, and I would be surprised if there were many intentional uses of $$. So this seems like a productive path forward.

Like Physikerwelt I'm sceptical on the chances of getting quite a fundamental syntax change through code review.

We would need to specify precisely where this new syntax would occurs

  1. In the wikitext code which is stored in the main database
  2. As a key sequence which you could type into an editor, which would ten replace it with <math display="block">

I see 1. as almost impossible to get through. This has down stream effects Parsoid and VE would have to be adjusted to recognise this syntax, or produce the correct syntax.

  1. is possible. Perhaps the easiest would be a user script, which would detect the key sequence and insert the correct markup. We could do this without any review process, but it would require power users to install the script.

A key sequence in the editor is totally useless for me. Like many Wikipedia editors, I avoid the Visual Editor to the extent possible. So for me at least, more effort into keyboard shortcuts there is wasted effort. If it's not in in wikitext I won't use it.

Ozob added a comment.Nov 28 2020, 5:49 AM

Maybe I should be more specific about what I had in mind. I did imagine that \[ and \] would remain in the wikitext. However I was not imagining that they would have special behavior outside of a <math> tag. That is, I was hoping to replace

:<math>a^2 + b^2 = c^2</math>

with

<math>\[a^2 + b^2 = c^2\]</math>

I was not hoping to replace it with

\[a^2 + b^2 = c^2\]

like in an actual LaTeX document. I don't think that's a reasonable request here.

In full detail, what I was thinking is as follows: Say we are beginning to parse the contents of a <math> tag. We will have a simple finite state machine. We start in the "first token" state. If the first token inside the tag (excepting whitespace) is not \[, we move to the "no display math delimiter" state. If we enter this state, we never leave it; it acts like <math> currently acts, and \[ and \] cause a syntax error, "Illegal display math delimiter." If first token is \[ and the <math> tag had an explicit display="inline", return a syntax error. If the first token is \[ and there was no explicit display="inline", then we act as if the tag contained display="block" and pass to the "looking for matching \] token" state. If we run out of tokens while in the "looking for matching \] token" state, return a syntax error. On the other hand, if we observe the token \], then we move to the "found matching display math tokens" state. From this state, if there are no more tokens, then we return successfully; whereas any further tokens cause a syntax error.

This feels like a thing that would behave reasonably and could maybe be implemented without too much difficulty. But I don't know how Mathoid actually works, so I don't know if my feeling is correct. I welcome more informed responses.

I rather feal discussion on having a \[ syntax really needs its own task. I've created one at T268912

What this task is about is whether there should be a global default style rule for math equations which use <math display="block"> (or possibly the equivalent <math>\[ ...). In either case there are sufficient css classes already created by the math extensions to allow style rules to be set for the different cases.

On the most active wiki's (en, de) people have edited local style rules so that a <math display="block"> will display indented. But if you find a less well used wiki, like the Esperanto one this displays <math display="block"> center aligned.

Compare
https://en.wikipedia.org/wiki/User:Salix_alba/sandbox
with
https://eo.wikipedia.org/wiki/Uzanto:Salix_alba/provejo
both have exactly the same wikitext. But display differently.

I do not think it is a good idea to take well known syntax like \[ for the same reason as the other suggestion (searching for \begin{align} \begin{equation} etc.) to influence the rendering outside of the math tags. It will never have the same functionality like in LaTeX (switching between text and math mode), therefore it would make the current behavior even more confusing to the editors.

Below some notes of what people are used to and need and expect to have also here. Some of it is just writing up well known conventions, some of it is what I keep repeating everywhere when the topic comes up, please just ignore if that is the case.

Purpose of a block formula

In a mathematical text it is often easier to express things with formulas rather than text, sometimes necessary because the text would become too lengthy to understand. Therefore you need to write equations for the things you want to express. There are some symbols to express frequently needed quantities "real numbers, complex numbers..." and frequently needed parts of phrases like "implies, for all, in, exists..." but by far not everything. This means formulas are meaningless without the text that surrounds them, you cannot take them out of their context. They are part of a normal sentence, they do not change the punctuation rules and everything that makes them stand out and break the flow of the text is undesirably. In a mathematical text with good layout you should not notice that it contains formulas, it should look and read the same as an equivalent text without formulas.

However there is one difference with formulas: They can become lengthy and wrapping them into the next line can be confusing and generally not as easy. This is why editors will try to avoid a linebreaks within a formula. Furthermore some expressions can become taller than a normal line, so that you can no longer fit them into the normal height. Often you can rewrite things i.e. split a large expression into several smaller expressions and for tall formulas rewrite them using brackets. This has the disadvantage that people can get confused about the additional symbols you need to introduce for parts of the expression or what bracket ends where, so those two solutions are usually bad for readability.

Often the best solution is to start a new line in the text when you want to write a larger formula. However this creates a problem: The formula which should be part of the sentence looks from a layout point of view like a new paragraph in the text. This impression you would like to avoid. There are two approaches:

(1) The first one is the default setting in LaTeX, if you just write a mathematical text with a lot of formulas this is probably the preferred layout style: You have block formatting of the text and you have linespacing of 1.5 to have a bit more space for larger formulas. Within a paragraph there is as much black letters to the left and to the right of your page. If you start a new paragraph, the last sentence terminates before it reaches the end of the line. To increase the effect, you additionally start a new paragraph by indentation of the first line of the paragraph. So the visual appearance of a new paragraph is that left-right shift of the black letters. If you do not want to start a new paragraph but just write a larger formula that is hard to break and fit into the text, you use centering of block formulas. That way they do not create this left-right shift you use for a new paragraph.

(2) The second approach is the one in Wikipedia. Here you have normal linespacing, not necessarily block layout and you put images on the side rather than in the standard LaTeX layout (1) into their own line. The text will have some uneven distribution of black to the left and right anyway. Instead you will start a new paragraph by leaving some white space, so the visual appearance is not a left-right shift but a gap that is larger than then normal spacing of a new new line in the distribution of black letters from top to bottom. In this layout there is no need for indenting the new paragraph, so it will start without indentation. If you would write a block formula left aligned here, it will look like a new paragraph. To indicate to the reader that you do not want to start a new paragraph you use indentation for block formulas here.

Behavior in LaTeX

Basically, there are only two choices for the editor: block formula or inline. Only those two choices. If the editor thinks that the expression is larger, he can select delimiters that create a block formula and it will be put the formula into its own line. Either you put the equation into its own line or you don't, there is no third possibility. The delimiter itself will, apart from selecting math mode, do this for you, i.e. a linebreak and the appropriate centering or indentation or no linebreak. In the source code you do not need to put it into its own line. If you do, then it does not create a new paragraph in the text, in Wikipedia you would expect not to get a new paragraph. In other words, the :<math> hack in Wikipedia currently creates a new paragraph and the spacing before and after a block formula is too large.

Centering or indentation is selected globally for the document, it does not make sense to mix the two. You do not want to hard-code this on an equation basis. New editors will just be confused if you give them a choice with more than these two options. Currently with "default", "inline" and "block" in visual editor people will assume that "default" means automatic selection or inline since it does not create a new line.

All the other layout will be taken care of automatically. For example if you write an exponent then the size of the exponent is smaller. This is done automatically, it chooses this "style" for you. There is \displaystyle, \textstyle, \scriptstyle, \scriptscriptstyle in standard LaTeX. Most people writing equations in LaTeX probably do not know about this style. The reason is that it is always chosen automatically and it practically never happens that you need or want a style that is different from the one that is selected automatically. \displaystyle is the style that is selected by default in the main scope of a block equations, \textstyle the one that is selected by default in an inline equation. For example if the integral is \displaystyle, the boundaries are \textstyle and placed above and below the large symbol, if the integral is \textstyle, the boundaries are \scriptstyle and are to the right of the integral. You have the possibility to modify all those things if you do not like it, but people expect not having to do any modification here.

In other words they expect to get \textstyle when they select an inline equation, which they assume is selected if they chose "default". To get the equivalent of what is "default" in Wikipedia you need to employ those rather unknown hacks in LaTeX.

Limitations in Mediawiki

There are some things you need to be able to do within a block equation. For example you would like to write a point at the end of the equation and you would like it to look the same as the points in the text for them to be not confused. Also you would like to use text in your block equation that looks like your main text, put references etc. in other words, you need everything that you need in normal text also in a block equation. In Wikipedia you cannot jump back to text mode within a block equation like you can do in LaTeX.

Until there is a solution for this, we will never be able to convert everything that is done with the :<math> hack into to use <math display=block> or some other syntax. I am afraid this is a limitation of our current software, so we will have to live with some hack, where you can compose the block equation yourself.

A solution could be

  • make <math> tags without argument to be inline math. Anything that needs more letters to type or is more complicated will never be accepted.
  • have some syntax outside of the math tags that creates a block equation which you can compose out of several math tags and text elements. An option would be to stay with the current syntax, i.e. :<math> to do this modification. If not, we would have to replace all of the current usages to use this new syntax, currently I think this is - even with our bot- not feasible.
Izno added a comment.EditedDec 2 2020, 9:11 PM

I've also previously suggested T182673: Math on a newline should always have block display which I think would be the best solution. No cluttering wikitext or the LaTeX; it just works.

The bot being discussed in the other task would just run to remove the : and sort out/tag text remaining on the line.