Jump to content

Template talk:Math

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Template talk:Math/doc)

Proper spacing

[edit]

This template fails to provide proper spacing in expressions like 4 ≥ 3. I therefore expunged the template from an article I just edited. I will do likewise with other articles in which I find it if this flaw persists. Michael Hardy (talk) 06:22, 25 September 2008 (UTC)[reply]

How is the spacing in 4 ≥ 3 improper? --Yecril (talk) 13:00, 30 September 2008 (UTC)[reply]
Besides, the template being currently not completely perfect (which in the case you mentioned it actually works when you put spaces between operators yourself: WYSIWYM) is not an excuse to not use it, particularly when no other serif template exists for proper rendering of inline variables and relations. A template itself should be a standard such that improvements are global (as such, it would be great if editing the template were open). SamuelRiv (talk) 21:45, 16 January 2011 (UTC)[reply]
I am unwilling to fix that because I consider the code 1+2 inferior to 1 + 2. --Yecril (talk) 14:00, 4 April 2011 (UTC)[reply]

The user Yecryl's statement is "original research". Paul —Preceding unsigned comment added by 188.25.52.21 (talk) 03:14, 25 February 2011 (UTC)[reply]

Nowrap on white space

[edit]

I modified the style to not wrap on whitespace. This is the same as what Template:nowrap does. Justin W Smith talk/stalk 19:21, 18 May 2010 (UTC)[reply]

The documentation appears to claim that it would "prevent line-wrapping". I'm not sure why it made the claim. The css describing the span.texhtml class does not appear to affect line breaks. Justin W Smith talk/stalk 19:26, 18 May 2010 (UTC)[reply]
I probably meant that if it does not wrap, it is a bug in the math coprocessor. --Yecril (talk) 13:41, 4 April 2011 (UTC)[reply]

Using vertical lines

[edit]

How do you incorporate vertical lines, as for example in absolute value or the parallel symbol? --RockMagnetist (talk) 21:12, 25 October 2010 (UTC)[reply]

You can use {{!}} as in {{math|{{!}}''x''{{!}}}} |x|. But your probably better using the <math> tag <math>\left|x\right|</math> gives see WP:MATH.--Salix (talk): 22:13, 25 October 2010 (UTC)[reply]
Thank you, Salix. I'd love to use inline latex, but the appearance and size is so inconsistent. --RockMagnetist (talk) 22:45, 25 October 2010 (UTC)[reply]
I would use |x| and ab. --Yecril (talk) 13:51, 4 April 2011 (UTC)[reply]
I like the mabs template, but not ab. For a moment, I wondered what it was supposed to represent. --RockMagnetist (talk) 15:04, 4 April 2011 (UTC)[reply]
One more: you can also use " &#124; " as in x = {a | c|a}. SamuelRiv (talk) 21:58, 9 March 2011 (UTC)[reply]
This is viable, but hard to remember. --RockMagnetist (talk) 15:04, 4 April 2011 (UTC)[reply]

Difference between mrad and radical? List of keywords?

[edit]

Is there any difference between mrad and radical?

In the article, I also spotted several other keywords like mapply, minteg, mexp and frac. Is there a complete list of keywords that we can use? Is there any list of predefined parameters (like big) as well?

The article also implicitly teaches us that we can use <sup> to make superscript. Is there anything else similar we should know?

The article is very incomplete. 石庭豐 (talk) 08:06, 10 August 2011 (UTC)[reply]

You can find other maths templates like {[t1|mapply}} in Category:Mathematical formatting templates. For anything complicated LaTeX is preferred. --Salix (talk): 10:37, 10 August 2011 (UTC)[reply]
See Help:Displaying a formula for information about how to use LaTeX. —Kri (talk) 16:43, 10 August 2011 (UTC)[reply]

What is the the purpose with the argument #2?

[edit]

In the definition of this template, it can be seen that it utilizes both argument #1 and argument #2. However, both of them appear at only one place, and there they are just placed after each other. The code

"{{math|a|b|c|d}}"

is substituted with

"<span class="texhtml " >a</span>"

which produces the text "ab". So I'm wondering, what is really the purpose with the argument #2? How is this an improvement over having just #1 (meaning that #2 would be removed)? It must have been placed there by mistake, right? In that case, it should probably be removed. —Kri (talk) 15:41, 2 June 2012 (UTC)[reply]

In the documentation, there is this example:
{{math|big=1|1 + 2 {{=}} 3}}
which produces: 1 + 2 = 3. So apparently the purpose of the second argument is to add optional parameters. RockMagnetist (talk) 15:58, 2 June 2012 (UTC)[reply]
Yes, although this is not what I meant with the second argument – I actually meant argument #2 (even though I didn't write it; that was a bit sloppy of me). Now I have corrected that I my previous comment.
The code {{math|big=1|a|b|c|d}} still produces a, which is kind of a strange behaviour. In the example in the documentation there is no argument #2. The first argument is labeled "big". Since the code for the argument contains an equals sign the label of the argument is what comes before the equals sign and the value of the argument is what comes after it. Unlike the code for the first argument, the code for the second argument doesn't contain an equals sign; hence the second argument is auto-labeled to "#1", not to "#2", even though it is the second argument. —Kri (talk) 16:46, 2 June 2012 (UTC)[reply]
I have created a test case for a single argument in sandbox5 and added test cases. One worry about changing the template is that some people might have used multiple arguments (although there is nothing in the documentation to encourage them). RockMagnetist (talk) 18:55, 2 June 2012 (UTC)[reply]
Strictly, it is not needed. It's probably there for backward compatibility with an older version of this template. Edokter (talk) — 20:48, 2 June 2012 (UTC)[reply]
He, I just realized they are not labeled #1 and #2 – that is LaTeX ' way of labeling arguments; on Wikimedia software they are just labeled 1 and 2. —Kri (talk) 22:41, 7 June 2012 (UTC)[reply]

Problems with the esthetic appearance of some fonts

[edit]

In Internet Explorer on laptops and workstations, several of the fonts used for math symbols show up with very thin strokes and in a different style. I try to make in-line math look as much as possible like the text in which it is embedded – much as a math textbook – by using mostly standard text and italics. I only use other fonts for math when absolutely necessary (e.g., when the symbols do not exist in standard text) and then usually on a separate line. I often go to another terminal to see if something looks different on another system. I often compare what I am editing with other articles to see if other editors have frequently used a particular type font. I recently spent a lot of time on several articles, e.g., stiff equation cleaning up some of the mixture of type fonts. I would like to suggest that editors take a look at how a font appears on several terminals before using it heavily. I would also like to suggest that someone with the authority to improve the math templates take a close look at how these templates (e.g., the many examples in this article) work on various terminal types. — Anita5192 (talk) 19:05, 26 June 2012 (UTC)[reply]

Change the associated style

[edit]

Now that MathJax is working on this wiki it might be worth considering making the output of this template compatible with MathJax, so that pages which mix <math> and {{math}} where posible use the same font. This could be achieved by modifying the CSS rule to be span.texhtml { font-family: MathJax_Math, serif; }. There is some discussion on this at Wikipedia_talk:WikiProject_Mathematics/Archive/2012/Jul#MathJax working.--Salix (talk): 17:22, 27 July 2012 (UTC)[reply]

Summary of that discussion is
span.texhtml {       font-family: MathJax_Main, serif; font-size: 123%;}
span.texhtml var {       font-family: MathJax_Math, serif;}
span.texhtml sup {       font-size: 70.7%; }
span.texhtml sub {       font-size: 70.7%; }
is the closest css rules I can find to math {{math}} look like MathJax.--Salix (talk): 18:31, 4 September 2012 (UTC)[reply]
There seems to be a misunderstanding propagating through these discussions, namely that the MathJax fonts are the same as the STIX fonts. They are not. The MathJax fonts are webfonts which are only loaded through the @font-face directive, and only when MathJax in invoked. Otherwise, declaring these fonts does nothing. MathJax will use locally installed STIX font (which look vastly different then MathJax' native webfont), however, this is a relatively new MathJax feature which only works with Nageh's MathJax script, but not yet with MediaWiki's default MathJax installation. Edokter (talk) — 18:56, 4 September 2012 (UTC)[reply]
The usercase I'm thinking of is that a reader will have MathJax switched on, if the reader encounter a page which uses some occurrence of {{math}} and some <math> then the @font-face will be invoked. Having font-family: MathJax_Main, serif; will use the same font as used by MathJax if availiable but fallback to serif if its not. There would be a problem if there is no <math> on the page then it will use the fallback.
Is it worth rasiing a bug to get the MediaWiki version to use local installed stix fonts if available.--Salix (talk): 21:17, 4 September 2012 (UTC)[reply]
As to Stix there is a bug 35498 about using them.--Salix (talk): 01:05, 6 September 2012 (UTC)[reply]
[edit]

What I could now present are the formula from a fresh section Square (algebra) #In complex analysis, and samples made just to this cause like fg = λx.f(g(x)), Pnf, or ψ | A | ψ. These samples are not useful in this literal form, but demonstrate various ideas how so complicated expressions may be clarified. Very likely, there are several cases in articles with links inside a formula, but I have no idea how to search for these. And I am not sure that underlines should be turned off for all {{math}}s, or even by default, because there are different formulas. For example, ASL(2,R) looks fine with underlines. Incnis Mrsi (talk) 21:24, 4 September 2012 (UTC)[reply]

Wikipedia's default is not to underline links until hovered over. That said, I have never encountered the use of links in formulae before, and I wonder if this would be considered good practice. You should bring this up at WT:MATH. Edokter (talk) — 21:36, 4 September 2012 (UTC)[reply]
Really, I forgot that "standard" skin is out of fashion for several years. Thank you for this suggestion. Incnis Mrsi (talk) 07:10, 5 September 2012 (UTC)[reply]

Math template for numbers

[edit]

Should a math template be used for numbers? Which one is better, 1234567890 or 1234567890, in an article? I've noticed that both are often used in the same article. 069952497a (talk) 20:25, 2 February 2013 (UTC)[reply]

Only when the numbers are part of a formula, even as simple as x = 123. It should not be used for stand alone numbers. Edokter (talk) — 20:54, 2 February 2013 (UTC)[reply]
Ok. Thanks. 069952497a (talk) 19:38, 3 February 2013 (UTC)[reply]

Consequences of a lack of consensus concerning inline text style mathematical formulae

[edit]

I copied the discussion thread on (to have it on one location only): Wikipedia talk:WikiProject Mathematics/Typography#Consequences of a lack of consensus concerning inline text style mathematical formulae. — TentaclesTalk or mailto:Tentacles 22:06, 24 March 2016 (UTC)[reply]

Remove this template

[edit]

I think it would be good, if we could remove this template and simply use the math tag instead. A research group from the rochester institute of technology has started to develop software which is capable to convert the templates back to regular math. --Physikerwelt (talk) 18:02, 16 May 2016 (UTC)[reply]

No. The math tag is unacceptable until it generates formula that can be used inline, on all major browsers. The current version (even in MathML/SVG mode) instead makes formulas that do not match the body text in font (e.g. wthin \text markup), font size, baseline alignment, font weight, antialiasing, and coloring of wikilinked text. It is too ugly to use by default. It has gotten better recently, enough so that it can be used for display math formulas, but is still far worse than the MathJax in most major mathematics web sites. —David Eppstein (talk) 18:11, 16 May 2016 (UTC)[reply]
I concur with David. This template is the only bearable display options for inline math at this time. Also, not every editor is familiar with TeX markup, which makes HTML their only recourse. -- [[User:Edokter]] {{talk}} 18:48, 16 May 2016 (UTC)[reply]
@David Eppstein: it would be great to add some evidence to your claim. Otherwise, it's hard to comment and/or improve the situation.--Physikerwelt (talk) 22:07, 9 January 2017 (UTC)[reply]
Evidence: Look with your eyes. See e.g. Talk:Clique problem/GA1 for a very recent comparison I did of the formatting of some very simple formulas. In that example, what I see (with Chrome / SVG fallback) is still formulas that use too large a font, that come as atomic images rather than something you can copy text out of, and that (in other cases, not that one) don't get colored to match wikilinks on surrounding text. The antialiasing is now much better than it was using bitmaps, but I think it may still be a little rougher than the wikitext — the text is antialiased at the subpixel level on my Mac screen, using the color channels, and I'm not convinced that the SVG antialiasing knows how to do that. It is still simply false that the <math> markup matches the quality that can be attained with {{math}}, in formulas simple enough to use {{math}}. —David Eppstein (talk) 23:27, 9 January 2017 (UTC)[reply]
What looks nicer of course depends on your personal preferences. There was a community request to make formulae larger. For Firefox rendering with MathML there was a request to make the font of mathematical characters 118%, which was implemented in MediaWiki:Common.css. Thus I would call rather a feature than a bug. To my 'eyes' the identifiers such as looks nicer compared to n. However, that might be only the case since I'm more used to the LaTeX fonts. I have to admit that copy and pasting formulae from Wikipedia to other application such as word could be simpler https://www.youtube.com/watch?v=FDMfT27zE54, but at least it's a general method that to copy and paste formulae. For Chrome I would like to mention the option of the Math Anywhere addon, which uses the MathJax path to get slow but more interactive math rendering https://www.mediawiki.org/wiki/Extension:Math#Viewing_math. However, the mixture of and the competition of the math tag and the math template is somehow unfortunate. Especially, it adds complexity and differentiates English Wikipedia, with formualae inconsistency marked up from other wiki language versions. However, I currently do not have a road map at hand how to improve upon this situation. --Physikerwelt (talk) 22:11, 10 January 2017 (UTC)[reply]
So the mismatch in font size is deliberate? How unfortunate. As for patches that individual users can apply: that does not good when my purpose is to write mathematics that random readers of Wikipedia can read without being distracted by the ugly formatting. Yes, I agree that the mixture of formats is unfortunate. Also unfortunate was the fact that the developers ripped out the formerly-working MathJax code, discouraging content-contributors such as myself from continuing to use <math> and making it more likely that this mixture would continue —David Eppstein (talk) 22:46, 10 January 2017 (UTC)[reply]
I do not understand the argument that MathJax was ripped out. When MathJax was removed it was used by about 7300 users, which is only a tiny fraction of all Wikimedia users. And it's still possible to use MathJax as described on the link above. The only change made to the way MathJax is enabled is in the procedure how to enable MathJax. Before, MathJax had to be enabled in the user setting, now it has to be enabled on the browser level. I think that makes sense, since it fixes the problem with missing HTML5/MathML support at its root, in the browsers that do not fully support the standard.--Physikerwelt (talk) 00:45, 11 January 2017 (UTC)[reply]
On the copying and pasting of LaTeX formula, I've a bit of javascript which copies the latex to the clipboard after a double click. --Salix alba (talk): 12:25, 11 January 2017 (UTC)[reply]
// Makes double clicking on a mathematical equation copy the source latex 
	$(".mwe-math-mathml-a11y").each(function(ind,ele) {
		root = ele.parentElement;
		$(root).dblclick(function(ev) {
			console.log(ev.delegateTarget);
			var root = ev.delegateTarget;
			var anno = $(root).find("annotation");
			var latex = $(root).find("annotation").text();
			var $temp = $("<input>")
			$("body").append($temp);
			$temp.val(latex).select();
			document.execCommand("copy");
			$temp.remove();
		});
	});

Towards a future solution

[edit]

I was watching the conversation here, but since there is no real solution, maybe these remarks help to solve the problem in the future.

  • "Also, not every editor is familiar with TeX markup, which makes HTML their only recourse." - Maybe I don't have enough experience and insight into these templates, but is there someone who thinks that those templates are easier to use than LaTeX? For simple equations:
  • LaTeX: <math>a+b=c</math> - works
  • {{math}}: {{math|a+b=c}} - you have to escape the equal sign - {{math|a+b{{=}}c}} - you have to know where to put spaces and add them manually - {{math|a + b {{=}} c}} - works
For things like integrals there are templates, but they are not easier to use:
  • LaTeX: (1) guess "\int..." (2) google "latex integral" (3) use a visual formula-editor (4) ask any mathematician, physicist... (5) search any LaTeX help page or a related WP-article
  • {{math}}: (1) guess "{{intmath|int|..." - probably not (2) google "HTML integral" - you can't add boudaries, google "wikipedia integral" - no suitable result (3) as far as I know there is no editor (4) ask someone familiar with english wikipedia math templates (5) search through the template documentations or a related WP-article
  • "What looks nicer of course depends on your personal preferences" - I would say the main issues are not different personal preferences, but diffenent appearance and different problems depending on browser, operating system and hardware that is used. If I look at the comparison Talk:Clique_problem/GA1 on my laptop with firefox and MathML there is no problem and I also don't see "the big-O butt right up":
However I think for the average reader <math> looks much worse.
  • Replacing {{math}} with <math> would probably be limited to the English Wikipedia anyway. For a lot of other languages, the main issue with the svg output of <math> compared to {{math}} is the broken display of non-ascii characters
  • это хорошо выглядит?

What I am currently hoping for is MathJax 3.0. While the current alpha version rightly carries the notice "do not use in production" it might be working properly next year. Since it supports node.js out of the box I would guess that it is not more difficult to integrate into mediawiki than the current setup and the average readers can get a client side rendering that is as good as the former MathJax user setting.--Debenben (talk) 00:16, 25 January 2018 (UTC)[reply]

How should greek letter variables be handled

[edit]

I've been told in the past (in the context of normal text, not in the context of this template) that it is undesirable to put italic wikimarkup around greek letters. However, the template is providing an upright font for greek characters (α,β,γ,δ,ε,ζ) that does not match the output of math markup. How should this be handled? SpinningSpark 17:37, 23 December 2016 (UTC)[reply]

I've been treating these just like the roman minuscules: they need to be italicized (''α'' etc) inside {{math}}, or they can go unadorned into {{mvar}} which does the italicization itself. —David Eppstein (talk) 18:14, 23 December 2016 (UTC)[reply]
Ta. SpinningSpark 20:25, 23 December 2016 (UTC)[reply]

T153938

[edit]

On phab:T153938 it was proposed to add some hidden math for the math template E=mc^2 (not to be confused with the math tag ). One option I see is to add a hidden math tag to this math template

{{math|1=E=mc^2}}<span stype="display:none">{{#tag:math|E=mc^2}}</span>

at least from the math extension there is no way to access the math template (availible for english wikipedia). Any comments, suggestions on this idea? --Physikerwelt (talk) 22:03, 9 January 2017 (UTC)[reply]

I don't think it is necessary to modify the input at all. I talked my son and a friend of his into writing some JS for converting the output of the math (and nowrap) templates into MathML and then inserting the MathML back into the page in the same manner as is done for the math tag. The generated span tag is unchanged except for the addition of @aria-hidden so that screen readers don't try to read the nonsensical-HTML. Hence, neither the input is changed nor is the look of the output changed; the only difference is that the math is now accessible; the page is slightly bigger. The JS code is in github. This is working on the output of the template. It's probably a little easier working with the input.
The current status of the code is that we are awaiting approval for it to be a Mozilla add-on. Once approved, we'll see what bugs other people find and then move on to submitting it as a Chrome extension and Safari extension in their respective stores. This is all hopefully temporary. It would be much, much better if the page would be originally generated this way so that special things don't have to be done to make it accessible.
We found one bug in JAWS: it is not respecting @aria-hidden on a span tag. Hopefully that gets fixed. Both NVDA and VoiceOver do the right thing.
- Neil Soiffer (talk) 01:28, 10 January 2017 (UTC)NSoiffer[reply]

Presumably the example should have been

{{math|1=''E'' = ''mc''<sup>2</sup>}}
E = mc2

rather than the ugly atrocity actually given, which assumes incorrectly that {{math}} syntax is the same as LaTeX syntax. I really hope this isn't a developer attempt to make {{math}} work as badly as <math> in an attempt to drive editors away from it. —David Eppstein (talk) 03:56, 10 January 2017 (UTC)[reply]

I think this needs a much broader venue. There would a lot of users that this impacts and very few of those will have this template on their watchlist. WT:WPM is a more natural venue for a change of this magnitude.
I'm not quite sure of the consequences of the script, I think there are some quite non-standard uses of this and the {{mathvar}} tag. If there is going to be an auto conversion script then it pretty much leaves {{math}} pointless. A better option might be just to mark this as deprecated. --Salix alba (talk): 23:38, 10 January 2017 (UTC)[reply]
I also very strongly disagree with the claimed justification for making this change, the first sentence on Phabricator, "Math that is authored with TeX inside of <math> tags is accessible because part of the output is MathML.". Content MathML is accessible, because it describes the actual structure of a mathematical formula. Presentation MathML is no more accessible than html-formatted math or math-template-formatted math, because they all just describe patterns of marks on a page. However, it is not possible to generate accurate content MathML even from <math> markup, let alone from {{math}} templates, because these markups do not carry any semantic information. So by claiming accessibility as an argument for this change you are playing sleight of hand with the meaning of "MathML" and hoping nobody notices your falsehood. —David Eppstein (talk)
Presentation MathML is accessible; the existence of assistive technology that uses it is proof that that it is accessible. JAWS, NVDA, and VoiceOver are leading screen readers that work with the presentation MathML by speaking it, converting it to Nemeth (braille) code, and allowing users to navigate it. TextHELP's products (learning disability software) go further by injecting script to modify Wikipedia pages so the image is deleted and the MathML is drawn by MathJax. That allows it to highlight the parts of the equation as they are spoken; this is a big boon to those with dyslexia. There are definitely ambiguities with TeX and Presentation MathML, but humans have to deal with reading the notation and its ambiguities also. Presentation MathML provides a standardized, easily recognizable and parsable notation for computer programs to interpret, and hence is vastly preferable to trying to figure out whether some random HTML+CSS represents math, and what that math is. Neil Soiffer (talk) 21:12, 11 January 2017 (UTC)NSoiffer[reply]

Looking at some of the dificulties Algorithms for calculating variance we have some exotic unicode symbols. {{math|''n'' ← 0, Sum ← 0, SumSq ← 0}} some include templates {{math|Var {{=}} (SumSq − (Sum × Sum) / n) / (n − 1)}} From Bra–ket notation we have {{math|{{bra-ket|·|⋅}}}} which leads to several levels of nested templates including unicode {{rangle}} and html entities &#124; the pipe character |.

At the least such a conversion algorithm would need to cope with the various math notation template. --Salix alba (talk): 10:07, 11 January 2017 (UTC)[reply]

For another example of markup within the template argument that would need to be coped with, see
O(n) — marked up as {{math|{{italics correction|''O''}}(''n'')}}
which I recently added to an article at the request of a GA reviewer who felt that, without the correction, the O was too close to the paren. The italics correction just wraps its argument in a span, so maybe that would be easy to ignore but it probably depends on evaluation order (which templates get expanded before or after the hidden math gets added). —David Eppstein (talk) 21:44, 11 January 2017 (UTC)[reply]

Template-protected edit request on 4 May 2017

[edit]

Request that inline math text be made non-breaking by adding the class nowrap to <span class="...">. Inline math formulas should not be broken across lines. Hgrosser (talk) 09:05, 4 May 2017 (UTC)[reply]

Not done: The template already adds the class texhtml which specifies white-space: nowrap. Ahecht (TALK
PAGE
) 22:51, 4 May 2017 (UTC)[reply]

Template-protected edit request on 5 May 2017

[edit]

Hi! I'm editing an article in the wiki of a game called "Stardew Valley" and I noticed the Template:Math doesn't exist there. Is there a way I can get the source of this template so I can copy and use it there? Thanks! Santisanti32 (talk) 05:38, 5 May 2017 (UTC)[reply]

This is not an edit request. You can view the source by clicking 'view source' on the template page. — JJMC89(T·C) 06:09, 5 May 2017 (UTC)[reply]

Template-protected edit request on 5 May 2017

[edit]

Hi! I was editing an article in the wiki of a game called "Stardew Valley" and I noticed that the Template:Math doesn't exist. Is there a way I can get the source of this template so I can create it in the other wiki? Thanks! Santisanti32 (talk) 06:13, 5 May 2017 (UTC)[reply]

Here it is. It's short, and relies on Wikipedia's css to do most of the work.
<span class="texhtml {{#if:{{{big|}}}{{{size|}}}|texhtml-big}}" {{#if:{{{big|}}}{{{size|}}}|style="font-size:{{{size|165%}}};"}}>{{{1}}}</span><noinclude> {{Documentation}} </noinclude>
David Eppstein (talk) 06:24, 5 May 2017 (UTC)[reply]

Template-protected edit request on 11 January 2021

[edit]

Please replace code with all code from {{Math/sandbox}} (diff).

Change: added Module:Check for unknown parameters.

Background: Math formulae are prone to use math symbols = and | incorrectly in template parameter entering (math meaning versus parameter parsing effect). See parameter usage (now outdated).

The addition provides a Warning in preview, and categorises mainpage error articles (new Category:Pages using Math with unknown parameters).

Tested: Template:Math/testcases (also to Preview), and live articles Priview only. DePiep (talk) 19:02, 11 January 2021 (UTC)[reply]

 Done — Martin (MSGJ · talk) 10:51, 13 January 2021 (UTC)[reply]
  • trout Self-trout Sorry, I had not undone my testsettings in the sandbox ( Fixed now [1] use of {{Main other}}). So same request again:
  • Please replace code with all code from {{Math/sandbox}} (diff).
-DePiep (talk) 14:59, 13 January 2021 (UTC)[reply]
 Done Special:Diff/1000135454. —⁠andrybak (talk) 19:24, 13 January 2021 (UTC)[reply]

RFC: Use Computer Modern in texhtml class

[edit]

The current CSS rule for the texhtml class in MediaWiki:Common.css uses Times New Roman and its clones for displaying math, with no mention of the Computer Modern font that <math> uses. This difference is a major source of visual inconsistency between the two math layout options on Wikipedia, and I propose that a different font fallback sequence to be used so that a CM-based font is used first when available.

Comparison of math layout options
Current {{math}}<math>Proposed {{math}}
(view source for CSS rules)
123456789123456789
|f(x) − a| < ε|f(x) − a| < ε
x.M)x.M)

(There's something really odd going on with the CM OpenType fonts not having the greek stuff.)

Now this change does not make it indistinguishable from <math>. There's still a stark difference in font weight (likely due to antialiasing and other rendering shenanigans), and the Greek letters somehow have to be filled in by the Times fallback. But it's one step closer for readers that have the fonts installed.

--Artoria2e5 🌉 02:59, 27 April 2021 (UTC)[reply]

Current and proposed look identical to me on multiple browsers. I suspect the same may be true for many readers. —David Eppstein (talk) 04:47, 27 April 2021 (UTC)[reply]
Oh right, you will need to install either Latin Modern Roman or CMU Serif to see the more similar version. This is about allowing the possibility of having a more similar presentation by putting them into the fallback list, not about shipping such a font to everyone. You can get it from the GUST people at http://www.gust.org.pl/projects/e-foundry/latin-modern. (And if you are using Safari, the browser will block ALL user-installed fonts.) --Artoria2e5 🌉 23:34, 27 April 2021 (UTC)[reply]
@Artoria2e5: Please move the table out of the statement, it's breaking Wikipedia:Requests for comment/Wikipedia technical issues and templates - see WP:RFCBRIEF. --Redrose64 🌹 (talk) 13:12, 27 April 2021 (UTC)[reply]
You're right re the spacing. Maybe this (see also MediaWiki:Common.css, selector texhtml): Could it be that the proposal demo here (3rd column, with in-page css) is missing other, non-font settings that causes this spacing difference? Possibly font-kerning: none;? -DePiep (talk) 09:38, 2 May 2021 (UTC)[reply]

Problem with letters "a" and "α" in the italic case

[edit]

Hi, the output of this templates for the letters "a" and "α" when they are italic are very similar, as in: a(x) and α(x), so I propose that in the first line use a font-family style like this:

style="font-family: Arial;" or style="font-family: Courier;"

to remove confusion of shape of these letters in the italic case. Thanks, Hooman Mallahzadeh (talk) 10:56, 2 December 2021 (UTC)[reply]

"Display=Block" does not work with Dark Mode

[edit]

When I run the Wikipedia app on my phone or iPad, and I view in Dark Mode (black background; white text) ... many math formulas are invisible. I tracked it down to formulas that use <math display="block">. Changing to <math> fixes the problem (but, of course, loses the block characteristic).

Can someone relay that issue to whoever is in charge of the math template display software: they should fix it so display="block" works better in Dark Mode.

I'm not sure where to post this, but this template Talk page seems like it may get to the right people. Noleander (talk) 16:57, 8 August 2022 (UTC)[reply]

It's https://phabricator.wikimedia.org/T268279 but "the right people" (the Wikimedia developers) have historically shown little to no interest in making mathematics work well on Wikipedia, hence our piecemeal efforts (like the math templates) to patch around their problems. It has been listed as a bug since 2020 with no progress since then. Pinging User:Izno (already listed as interested in this at phab); I'm not sure who else needs to have this called to their attention. —David Eppstein (talk) 18:12, 8 August 2022 (UTC)[reply]
@David Eppstein - Alright, thanks. I'm a software engineer, maybe I'll head over there and see if I can contribute. Sounds pretty bureaucratic, though. Noleander (talk) 21:40, 12 August 2022 (UTC)[reply]
I saw the comment on Phabricator for that task and was concerned that you were actually going to "fix" it like that. The better solution would be to fix the CSS. Since you say you're a software engineer, you should get yourself a Gerrit account (I think mediawikiwiki:How to become a MediaWiki hacker is the correct place for that) and then submit an appropriate patch upstream.
As a guess to what the patch would look like, I'd gather they're targeting the inline-only classes for the color flip or possibly adding the HTML element in the CSS, so the display versions also need to be added or the relevant HTML element removed in the CSS the app is applying. Izno (talk) 23:56, 14 August 2022 (UTC)[reply]
@Izno - thanks for the info. You wrote "... they're targeting the .." - can you help me understand the process here? Any interested party can comment in the phabricator, and can post results of experiements? But any proposed changes only make it into the official MathXL/Tex Wikimedia software after Wikimedia developers approve it? In that phabricator issue at https://phabricator.wikimedia.org/T268279 ... who are the Wikimedia developers? The phabricator conversation seems a bit chaotic, e.g: the issue was closed on 17 Aug 2021, but then immediately re-opened. Is there an individual responsible for resolving that issue? It is hard (for me) to get excited to work on this unless the people with authority are participating. Noleander (talk) 14:25, 15 August 2022 (UTC)[reply]
My understanding of the apps (without having looked into it) esp. regarding dark mode sorts of things is that they have CSS to flip colors, in whole or in part. There will accordingly be some stylesheet in the iOS app codebase to do so. That CSS will have either 1) something like .mwe-math-inline { background: #000 } but be missing .mwe-math-display { background: #000 }, or something like .mwe-math-inline { filter: I don't know what goes here } but again not a similar version with .mwe-math-display.
  • Any interested party can comment in the phabricator, and can post results of experiements Of course.
  • But any proposed changes only make it into the official MathXL/Tex Wikimedia software after Wikimedia developers approve it? Anyone with +2 rights in gerrit. This is predominantly WMF engineers but includes some community engineers as well. (NB, this change needs to be made to the app code as a skinning issue, not the separate math extension which drives the LaTeX transformation on Wikipedia.)
  • who are the Wikimedia [employees]? They usually have something in the hover-over/user page to indicate which they are, though many have a name which includes WMF. Some have only an LDAP account rather than a connected wiki account. Just eyeballing which, Dbrant, now-departed Cleinman, ABorbaWMF, scblr, MSantos, LGoto (PM/PO), possibly Vadim (unclear) are WMF employees. I couldn't tell you which of these have +2, but that's not particularly important to the subject of at least getting a patch in. Getting a review for the patch is then a question usually of jumping on IRC and asking who has +2 for the repo and/or can review the patch.
  • Is there an individual responsible for resolving that issue? Officially, this is the person in the assignee field in the infobox. That person is supposed to be the one who ultimately makes the change to code/docs/whatever that corrects the issue. That's currently Vadim. However, as you noted, the task is a little chaotic, and I think that's partially because it has no discrete completion criteria, meaning that any issue with dark mode and math is ending up in that task rather than having their own discrete tasks, and partially because the task is being cookie-licked (i.e. he is the assignee but is not in fact working on the task right now).
Izno (talk) 16:22, 15 August 2022 (UTC)[reply]
@Izno - Thanks for the prompt and detailed response. Maybe I'll look into it. I've never had good luck modifying WP processes ... the answer is often some variation of "You idiot, that was suggested 30 years ago and rejected for a dozen good reasons. RTFM."
In this case, it seems like WikiMedia may have two teams involved: One team responsible for getting dark mode working (for the Wikipedia app only?) And a second team that owns the software that xlates MathXL into SVG/PNG images.
When dark mode became a thing several years ago, the inline <math> worked okay ... so someone in the MathXL team made sure that the MathXL software responded to the current in-line CSS color directions and changed the formula text color accordingly (use white text when CSS specifies dark mode colors). I'm sure they considered <math display="block"> at the same time ... and they chose to leave it alone: forcing the formula text to always be black for block-display. Why?
I know block mode is supposed to be self-contained (ignore the "current" formatting of the prior text) but if they are going to force the formula text to be black when display=block, then why not also force the formula's background to be white? They are leaving the SVG/PNG background color as transparent (I think) and that is causing dark mode to fail.
Noleander (talk) 16:49, 15 August 2022 (UTC)[reply]
I'm sure they considered <math display="block"> at the same time Doubtful, the team implementing it probably didn't even know there was another display mode. My observation is that domain knowledge of extensions is/has been minimal for engineers who aren't really working on the core product. Izno (talk) 19:15, 15 August 2022 (UTC)[reply]

Summary for people that may read this in the future:

  • There is a bug in the <math display="block"> MathXL formatter where it fails to work in the Wikipedia mobile app when the app has Dark Mode preference enabled. Bug has apparently been there since 2000.
  • The bug shows up on all mobile devices, including iPhone, Android, and iPad.
  • The bug is: when viewing formulas in the Wikipedia mobile app (with Dark Mode preference enabled) math formulas are invisible if formatted with <math display="block">. They are invisible because the MathXL is using black text on a black background. The fix is to have the MathXL formatter respect the inline color and use white color for text (in the Dark Mode scenario).
  • This bug was reported to WMF at https://phabricator.wikimedia.org/T268279 ... it looks like the primary investigator is Vadim Kovalenko. The bug report was appended to an older, similar bug report. The WMF has not commented on the new bug report yet.
  • Until the bug is fixed, an available workaround is to edit selected Wikipedia pages to change the formulas from <math display="block"> to the inline format :<math> (note the indent colon).
  • Changing a math formula from block-display to :<math> is generally okay, but has a couple of potential downsides: (a) According to this 2017 VP discussion using the block-display may be better for visually-impaired users of Wikipedia, because screen-reading apps have problems with the indent - I'm not sure if this is still a concern now, five years later; and (b) if the formula is wider than a full page width the block-display may help the user view the formula if the user narrows the page.
  • For that reason, the only formulas that should be changed from <math display="block"> to :<math> are those that are shorter than a full page width.
  • The long term solution is to have the WMF (or a volunteer) fix <math display="block"> so the mathXL produces HTML that works better in Wikipedia app in Dark Mode (i.e. the HTML should adopt to the text color of the current CSS, rather than force text to black).
Noleander (talk) 13:25, 20 August 2022 (UTC)[reply]
Indenting with a colon violates MOS:ACCESSIBILITY and should not be used as a workaround. A better workaround is to use {{bi|left=1.6|<math> ... </math>}}. —David Eppstein (talk) 18:50, 20 August 2022 (UTC)[reply]
@David Eppstein - Is your point simply that indenting is okay, but use bi-left rather than colon? The impression I have from reading the discussions on this, including Wikipedia:Village_pump_(policy)/Archive_138#RfC:_Accessibility_versus_convenience_in_indentation (which did not come to the conclusion to avoid indents), is that it is not a matter of "violating" a styleguide or not, but rather balancing competing interests. I got the impression that visual indents with colon may be used, or may be avoided, depending on the article & editor. There are probably thousands of articles that indent formulas with indents. Is there some WP RfC that came to the conclusion that indenting formulas with colon is prohibited? I don't care one way or another, I'm just curious. Noleander (talk) 13:58, 21 August 2022 (UTC)[reply]
Also, MOS:ACCESSIBILITY says <math display="block"> should be used instead of :<math>. I don't see mention of bi-left. Is there an effort underway to update that MOS so it recommends bi-left? Noleander (talk) 14:08, 21 August 2022 (UTC)[reply]
MOS:MATH § Using LaTeX markupDavid Eppstein (talk) 16:29, 21 August 2022 (UTC)[reply]
Alright, if colon is not ideal, and if bi-left resolves the Dark Mode issue described in https://phabricator.wikimedia.org/T268279, the "summary" above should be updated to suggest bi-left. But before that: are you aware of any discussions in the past where editors objected to the use of bi-left as a way to indent math formulae? Noleander (talk) 21:09, 21 August 2022 (UTC)[reply]

.... more discussion (subsection for Edit purposes)

[edit]
Methods of indenting math formulas
Technique Pros Cons
<math display="block"> * Handles wide (lengthy) formulas well by providing local side-scrolling.
* Supports mixing formulas with non-math text.
* Consistent with Manual of Style.
* Commonly used already.
* Formula is NOT visible, at all, in Wikipedia mobile app in Dark Mode (this is not a bug in the app, but an issue with the MathXL display="block" software).
:<math> * Simple.
* Commonly used already.
* Contrary to Manual of Style.
* Causes problems for accessibility (web reader) tools.
* Formulas wider than one page-width use awkward full-window side-scrolling.
{{bi|left=1.6|<math> ... </math>}} * Consistent with Manual of Style. * Not familiar to many editors.
* Not described in MOS:MATH or other pages about formatting math formulas.
* Formulas wider than one page-width use awkward full-window side-scrolling.

Does the above table accurately reflect the three options (that have been discussed in this section) for indenting math formulas? Noleander (talk) 21:29, 21 August 2022 (UTC)[reply]

I don't know about the cropping part. When I try it I get a window that side-scrolls. Maybe there is a separate bug that side-scrolling windows cannot be side-scrolled for some devices? Also, the block-indent-template variation is necessary when mixing math formulas with non-math text, and may provide better control of vertical spacing above and below the formula. And the <math display="block"> version sometimes adds a spurious scroll-bar next to the formula. —David Eppstein (talk) 22:14, 21 August 2022 (UTC)[reply]
Regarding side-scrolling for wide formulas: My tests show that <math> (without "block") does NOT display a side-scroll under the formula (desktop: Chrome, Safari, Firefox). But <math display="block"> DOES shows a side-scroll bar. I assumed that was a big benefit of the "block" option. You say you've seen a side-scroll without the "block" option? On what platforms? Noleander (talk) 22:21, 21 August 2022 (UTC)[reply]
It's the side-scroll for the entire window, not a separate gadget within the window. Chrome, OS X. —David Eppstein (talk) 22:30, 21 August 2022 (UTC)[reply]
Ah, okay. I thought you were talking about the mini scrollbar immediately under the formula. I also get the "whole window" scroll bar at the bottom of my browser window (when there is a wide formula and "block" option is not in use) I did not see it until you mentioned it. So: the "block" option _does_ improve formula readability for lengthy formula because the small, local scroll bar is handy & more visible. But the non-"block" choices are not too horrible, because a more obscure scrollbar is available. Noleander (talk) 22:34, 21 August 2022 (UTC)[reply]

Based on the above disucssion, I'm considering going to MOS:MATH talk page and proposing a minor change in that MOS from

A frequent method for displaying formulas on their own line has been to indent the line with one or more colons (:). Although this produces the intended visual appearance, it produces invalid html (see Wikipedia:Manual of Style/Accessibility § Indentation). Instead, formulas may be placed on their own line using &lt;math display=block>.

to

A frequent method for displaying formulas on their own line has been to indent the line with one or more colons (:). Although this produces the intended visual appearance, it produces invalid html (see Wikipedia:Manual of Style/Accessibility § Indentation). Instead, formulas may be placed on their own line using &lt;math display=block> or bi|left=1.6|math..../math

Thoughts? (Ignore the incorrect formatting above for the bi-left example ... not sure yet how to get that formatted for the Talk page). Noleander (talk) 22:49, 21 August 2022 (UTC)[reply]

Can you PLEASE stop using actual angle-brackets for your formatting of "<math>", and format it like "&lt;math&gt;" instead? Every time you do this it makes it impossible to preview any actual mathematics lower down on the same discussion page, because then the Wikimedia parser takes your angle-bracketed math tag as the start of a math formula until the first end of a math formula it finds, and produces a long error message about how that doesn't parse as mathematics. —David Eppstein (talk) 00:25, 22 August 2022 (UTC)[reply]

Error with space after template Plusminus

[edit]

These two cases should work identically.

{{math|± X}}: ± X
{{math|{{plusmn}} X}}: ± X

What is going on, why, and what needs to be fixed?

Note: This adds one to Misnested tag with different rendering in HTML5 and HTML4 in Template talk namespace, and I hate to do that, but we need answers. —Anomalocaris (talk) 22:07, 2 January 2023 (UTC)[reply]

@Anomalocaris I've fixed the issue. The noinclude tag should start on the same line else it creates a new line. Gonnym (talk) 15:22, 2 March 2023 (UTC)[reply]
Gonnym: Thank you for fixing Template:Plusminus! —Anomalocaris (talk) 20:12, 2 March 2023 (UTC)[reply]

Error with comma following "math" template

[edit]

In Abel–Ruffini theorem it just so happens in my browser that in History, 2nd paragraph, (search for "real and therefore") the list of "roots r1, r2, and r3" ends up with a line break after "r2" and a comma at the beginning of the next line. This is obviously not very good, and equally obviously I expect there is no simple solution, but perhaps someone can think about it. I tried moving the comma inside the template, but this gives the (noticeably) wrong font. Imaginatorium (talk) 15:19, 8 October 2023 (UTC)[reply]

Equations render twice in Chrome

[edit]

Formulas entered using <math display="block"> are rendered twice in Chrome browser both on a Windows PC and in Android Chrome app. The first formula appears centered on the page, the second is left-alligned on the next line. A simple example of this can be seen at Help:Displaying a formula#Block. The bug makes many math and physics articles (e.g. Taylor series) very difficult to read. The mobile app renders even the inline math twice (e.g. in electronvolt). Has it already been reported to some developers? What can be done about it? --egg 14:03, 19 March 2024 (UTC)[reply]

I should have mentioned that my Math Preferences are set to "SVG". When I switch to "MathML", the problem is gone but the formulas are ugly. --egg 12:00, 20 March 2024 (UTC)[reply]

Does this make sense?

[edit]

Re [2] – does it make sense to use this template "for legible Greek text"? Aza24 (talk) 06:41, 24 March 2024 (UTC)[reply]