Help talk:Displaying a formula/Archive 3

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

LaTeX Incorrect Rendering

(In reference to edit Special:Diff/811387351 on the triangular numbers page) Under what conditions could/would the LaTeX markup (eg "<math></math>") be displayed instead of the intended formula? Specifically, what could cause all the LaTeX markup in a single section of a page to render that way? (It's possible the issue was caused by my browser not fully loading the page) If possible, please point me to any "best practices" documentation for Wikipedia's LaTeX implemention. —Leopardpaw (talk) 09:02, 21 November 2017 (UTC)

@Leopardpaw: Your Math settings in the appearance section of the preferences would cause that if it were set to "LaTeX source", instead of MathML with SVG and PNG. —TheDJ (talkcontribs) 09:26, 21 November 2017 (UTC)
@TheDJ: Thank you for the quick response. In this case, I am primarily using a mobile browser (which may be part of the issue). It might have been due to a combination of interacting with Wikipedia's mobile site and my browser's setting, since as soon as I pushed my edit, the LaTeX rendered properly.

As a note, I did check the settings you referrenced, and it is set to render MathML. Thanks again. —Leopardpaw 09:48, 21 November 2017 (UTC)

@Leopardpaw what likely happened, is that when you added it, the page was rendered before the math fragment was finished. In theory this should not happen, but sometimes it does. Reloading the page, or making a WP:NULLEDIT usually fixes the problem. —TheDJ (talkcontribs) 09:47, 5 December 2017 (UTC)

Work around for LaTeX \phantom?

I intend to re-use given structures for displaying formulas by (slightly) modifying the existing content, without spending much effort on redesigning an elaborate alignment. This quick-and-dirty method seems reasonable to me, especially when considering the rate of acceptance for changes in WP. Cleaning up LaTeX-source may be scheduled for times after establishing content, possibly carried out by expert gnomes.

Since I am no expert in LaTeX, I humbly ask for cheap tricks, possibly saving me to, e.g., dig into arrays with elaborate aligning. Best regards, Purgy (talk) 09:08, 5 December 2017 (UTC)

Do you have an example of the expression you would like to display. --Salix alba (talk): 09:36, 5 December 2017 (UTC)
@Purgy Purgatorio Note that we don't support full LaTeX, only the math subset of LaTeX (specifically amsmath). —TheDJ (talkcontribs) 09:50, 5 December 2017 (UTC)
We don't even fully support amsmath: \genfrac, \substack, and \operatorname* all don't work, for example. –Deacon Vorbis (carbon • videos) 13:46, 5 December 2017 (UTC)
... yes, I got to learn this already (\dddots -> \overset), nevertheless I ask the experts for some work around. Purgy (talk) 19:50, 5 December 2017 (UTC)

I would enjoy most a generic answer to Howto mimic \phantom in WP?, but I do understand that this is maybe too much or meaningless to ask for. The last encounter with this problem was the following:

Having this:

and wanting something, approximated by this:

but not by using the ridiculous and unsatisfactory "\;\;\" but rather "\phantom {-}", or possibly "\phantom {{}-}". Aligning with the rude "&" did not work for me because of the minimally introduced whitespace, and \mspace does not work either. I mused about this already in other environments, but started to ask around on this occasion. As said, I am no expert, but really, I do like experts' answers. Purgy (talk) 19:50, 5 December 2017 (UTC)

Well, \phantom would certainly be nice to have for other things too, but here, you can achieve the same effect using the array environment, which is essentially what cases does. (Note, use \text{} here, not \mbox{}).
Deacon Vorbis (carbon • videos) 20:22, 5 December 2017 (UTC)
Thank you for having done the work, which I so eagerly strive to avoid. As mentioned in the thread starter I search for a quick-and-dirty method to re-use, as extensively as possibly, existing structures and definitely want to avoid re-casting the whole environment.
Mournfully, by your suggestion, I see my chances, for some artifice of \LaTex (you cannot have even this in its full glory) to trick WP-rendering to my desires, dramatically degrading. Any more sages around, please? Purgy (talk) 08:42, 6 December 2017 (UTC)

Difference between \bold and \mathbf?

This text is in \bold

And this is the same string in \mathbf

There doesn't seem to be any difference between the two, so which one should be used? And why is there no reference to \bold anywhere except for section 3.7.1.1.1? — Preceding unsigned comment added by Megafish40 (talkcontribs) 19:44, 10 December 2017 (UTC)

The \bold command does not appear in The Not So Short Introduction to LATEX 2ε. It might be a hang over from the old texvc package which had some odd non standard syntax.--Salix alba (talk): 23:47, 10 December 2017 (UTC)
@Megafish40: Correct, there are many texvc commands that weren't actual standard mathmode commands or that were common LaTeX commands or shortcuts, which were added in the early days for convenience. \bold is defined as an alias for the proper \mathbf. So while the result is the same, \mathbf, is what you really should be using, because it makes the formula interoperable with most latex renderers. —TheDJ (talkcontribs) 10:48, 11 December 2017 (UTC)

Spacing in arrays

I perceived that

{r@{}l}

generates an error, and

{r@{4em}l}

is ignored. Did I do something wrong, or is there a workaround? Specifically, I would like to be able to set the arrays-inherent spacing to zero. Purgy (talk) 12:06, 14 January 2018 (UTC)

It sure doesn't look like there's much control over the spacing commands here. You can try using 6 \!s before every entry in the second column. That seems to give about the right negative space, but that's almost certainly a bad idea. What are you trying to do? Maybe there's another way. –Deacon Vorbis (carbon • videos) 14:05, 14 January 2018 (UTC)
It is similar to what I wanted to do recently with \phantom. I want to have approximately this:
but I dislike doing it with \;\;\ , and would like to avoid the surplus white space before and after the "=", which should remain aligned, of course.
Thank you for your efforts. Purgy (talk) 15:38, 15 January 2018 (UTC)
Unfortunately, I don't think that's going to be reasonable given the limited spacing commands available, especially missing \phantom{}. I think using a plain align block would be just fine here. I suspect that even in a full TeX install, getting such fine control over vertical alignment (in a robust way) within an alignment block would require some significant wizardry (to the point where I'd just look for separate packages that do it for you already). –Deacon Vorbis (carbon • videos) 15:51, 15 January 2018 (UTC)

Writing chem ionic equation

How do I write:

Fe2+ + Cu2+

using <chem>? I cannot figure out how to get the "+" between the pair of ions to render correctly. Here are my attempts at the left-hand side:

<chem>Fe2+ + Cu2+</chem>
<chem>Fe+2 + Cu+2</chem>
<chem>Fe^{2+} + Cu^{2+}</chem>
<chem>Fe^{+2} + Cu^{+2}</chem>

DMacks (talk) 20:09, 20 January 2018 (UTC)

<chem>Fe^2+ + Cu^2+</chem> seems to work . --Salix alba (talk): 20:17, 20 January 2018 (UTC)

Thanks! DMacks (talk) 02:28, 24 January 2018 (UTC)

Migration away from old texvc <math> engine

There is now a project to migrate away from the texvc renderer for <math> expressions. This was the default a few years ago which produces PNG images, now we have a hybrid solution with uses MathJax in the backend to produce svg images and sometimes xml. There is still some legacy from texvc as it is used in the frist parsing step of the current engine. This means there are some idiosyncrasies in the syntax which differ from standard LaTex:

Current syntax Suggested replacement Comment
$ \$ redefinition would involve changing the character code
% \% redefinition would involve changing the character code
\and \land causes normal align environment to fail
\or \lor see [1]; causes teubner to fail
\part \partial acceptable if the document doesn't use sectioning with \part.
\ang \angle this only conflicts with siunitx package.
\C \Complex conflicts with puenc.def e.g. from hyperref package
\H \mathbb{H} conflicts with text command \H{0} which is ő.
\bold \mathbf
\Bbb \mathbb
\pagecolor remove not needed and not working anymore, done on en-wiki mainspace
<ce>...</ce> <chem>...</chem> Chemistry environment, done on en-wiki mainspace

The first step in the project will involve deprecating the old syntax and running a bot or semi-automated edits to change the syntax. These should not result in any visible change to the pages. The bot doing the work is User:Texvc2LaTeXBot which is currently seeking approval. Changes will also be made to the Visual Editor to produce the new syntax.

Subsequent stages in the project are discussed at mw:Extension:Math/Roadmap, these involve some more complex problems with the <chem> syntax. Eventually the texvc part will be removed completely and there may be some slight change to the rendered output. The main discussion of the project happens at T195861 and your input is welcome. Discussion on the English wikipedia should be on WT:WPM--Salix alba (talk): 15:55, 22 June 2018 (UTC)

dash instead of minus sign produced by math tag

See minus sign and 5 − 3 = 2 versus . It also produces text that is too small. --Espoo (talk) 16:24, 9 November 2018 (UTC)

@Espoo: (I fixed the weird horrible error; it was from a badly placed tag in the previous section header). I don't understand what you're referring to though. What's too small? What are we supposed to be seeing at minus sign? –Deacon Vorbis (carbon • videos) 16:33, 9 November 2018 (UTC)
Thanks! The text "5 - 3 = 2" is too small in the second example, and its minus sign is much too long. --Espoo (talk) 16:38, 9 November 2018 (UTC)
It looks fine to me. It could be related to your math display settings. Look under Preferences → Appearance → Math, and see if changing to "PNG images" helps. Does any other rendered math look weird? If that doesn't help, can you post a screenshot of how it appears to you? –Deacon Vorbis (carbon • videos) 16:43, 9 November 2018 (UTC)
That's very weird because the minus sign looks like a dash (even with png now), which is easily misread as "from a to b", on both my android smartphone and windows PC. I'll attach screenshots soon and would be grateful for your screenshot too. --Espoo (talk) 16:55, 9 November 2018 (UTC)

Some issues

\mathbf, \mathit and \mathsf do not work on Greek letters that are defined as a Latin letter in roman type, e.g., \mathit\Alpha () is displayed as an upright letter. While \mbox{a} and \text{a} do work, \mbox a and \text a do not. Support for upright Greek small letters seems to be missing in general, though at least \text{µ} (using U+00B5 rather than U+03BC) works: . \omicron ( – should be italic!) and \varcoppa () are displayed wrongly.

Also note that \oiint (), \oiiint ( – another try: ) and are displayed with an upright integral symbol while, e.g., \int () and \oint () are not. It would be great to have both variants (upright, slanted); the upright version fits to the practice of writing (→ ISO 80000-2:2009) instead of . -- IvanP (talk) 15:18, 4 April 2019 (UTC)

RfC on <chem>

What is <chem>: a recommended device or an obscure hack?
  • Should opinions of the “chemical” community in en.Wikipedia on <chem>...</chem> be mentioned here? I’m sure it is an important guidance for a help page in the English Wikipedia. The user Deacon Vorbis wages an edit war over it. Incnis Mrsi (talk) 16:24, 7 August 2019 (UTC)
Funny how it's always only the other person waging the edit war and never oneself. In any case, if something needs to be updated here in order to reflect common practice, that's fine. Your first two additions were completely inappropriate talking about edit warring and aspersions. Since you used an undo, I missed that the third had changed wording. But there's still a problem that you're basing a fairly substantial change off of something that one person said in response to an incomprehensible post on the chemistry wikiproject talk page. Without wider input, it's hard to know what to even make of it. So again, if something needs to be updated here, then you should coordinate with people who maintain chem articles and make sure what current practice really is. –Deacon Vorbis (carbon • videos) 16:54, 7 August 2019 (UTC)
Even so, there is also a concern I have about WP:CONLEVEL. --Izno (talk) 14:22, 10 August 2019 (UTC)
Can Izno please speak more specifically and less elitistic? Proponents of <chem> may come here and there and argue against me and Graeme. But the use of <chem> is controversial – this is currently a reality of en.Wikipedia which has to be documented. Incnis Mrsi (talk) 14:36, 10 August 2019 (UTC)
By the way, we see the RfC sabotaged by Deacon_Vorbis while the same Deacon_Vorbis vocally calls for “coordination with people who maintain chem articles”. Incnis Mrsi (talk) 14:50, 10 August 2019 (UTC)
Anyway the edit by Deacon_Vorbis indicates that there should be a discussion before, so that at least the scope and options for the RFC can be determined. I have a few issues with <chem>. Firstly issues for our readers, that it cannot be copied and pasted cleanly from a screen. There is a heap of extra text attached to the copy. Similarly searching on a page or on the Wikipedia search box may not find the formula due to extraneous inclusions. The third issue is for our editors who need to learn a lot before being able to use the <chem> tag properly. There are also the chem and chem2 templates which may have similar problems or reduced problems. I normally use sub and sup tags, and I sometimes use a template that merges them together. One feature that I dont know how to get is a line over the top that joins to a symbol at each end in order to illustrate a ring closure in a linear formula. Graeme Bartlett (talk) 12:58, 11 August 2019 (UTC)
@Graeme Bartlett: I defer to any solution by the “chemical community” which will deter wrecking and censorship. Specific formulation for preferences for <chem> and the templates are not of great importance. Incnis Mrsi (talk) 13:11, 11 August 2019 (UTC)
This statement is indicating drama and interpersonal problems. I will note that Deacon Vorbis removed your statement about yourself. If people are misbehaving and cannot be resolved by a civil discussion then there is a special drama board: WP:AN/I. So lets have a discussion of the use of the chem tag, and how it should be described on this help page first. In this discussion just discuss the topic and not the users. That will avoid stepping into the next level. It seems that this section has already upset two people. Graeme Bartlett (talk) 22:27, 11 August 2019 (UTC)
Again, there may be discussions on <chem> and arguments in defence of it at least for certain special applications. But its shortages indicate that—in conditions where {{chem2}} performs well—the current implementation of <chem> is controversial at best and detrimental at worst. Not all help-page readers are expected to understand what exactly means controversial, hence it would be better to suggest: to avoid trouble, don’t push <chem> boldly. Incnis Mrsi (talk) 22:36, 11 August 2019 (UTC)
@Incnis Mrsi: For crying out loud; since I caught it fairly quickly, I've again removed the RfC tag as hopelessly prejudicially worded. In case you didn't read WP:RFCBRIEF, which I had initially pointed out when I objected to the RfC wording, "Statements should be neutral and brief"; accusing another editor (me, in this case) of edit warring in the statement is not neutral (specific editors and/or their positions shouldn't even be mentioned). Referring to something as "an obscure hack" is not neutral (unless that's the specific text you're trying to add or change). Ideally, write it without any extraneous markup, and put it in a new section as well; you can refer to this thread for previous background discussion if you want. It should also be specific enough for other editors to have a basic idea of what you're asking. I've been semi-involved in this, and even I don't know what you're asking from the RfC statement. Please seek assistance on the RfC wording before placing a new one; I'd be happy to review it, although I wouldn't blame you if you didn't trust me to. –Deacon Vorbis (carbon • videos) 12:38, 14 August 2019 (UTC)
The statement proper occupies one <div align=center> – it is brief. Is this the guideline against calling the present situation “edit warring”? Incnis Mrsi (talk) 13:47, 14 August 2019 (UTC)

Alternative text does not work as described

Hello! The section Help:Displaying_a_formula#Rendering gives instructions on how to create an alternative text that can be used to make a formula accessible by using screen readers. However, it does not work. The example given is the code <math alt="Square root of pi">\sqrt{\pi}</math> which generates an image which should display the alt text Square root of pi, but actually displays the TeX code to create the image, i.e.: {\sqrt {\pi }}. --Lpd-Lbr (talk) 09:21, 17 September 2019 (UTC)

Since this seems quite unresolved, I have issued a bug report at https://phabricator.wikimedia.org/T233121
I think this might be by design. A mathematically inclined blind reader may well be able to interpret latex, there might even be screen readers which can cope with it. For a simple formula like sqrt(pi) an alt text might be fine, but a more complex integral might be hard to give an accurate representation of the formula. Still, I do think an explicitly specified should override the default one. --Salix alba (talk): 18:23, 17 September 2019 (UTC)
I think that the Help page should convey accurate and true technical information. I feel that I lack the necessary scope and expertise to correct it, as the information exists across multiple projects (including mediawiki) and seems to be centrally coordinated. I believe that discussions on accessibility are best done at Wikipedia:WikiProject_Accessibility. --Lpd-Lbr (talk) 18:52, 17 September 2019 (UTC)

Template

[Unrelated to my above query]

This page shows markup like:

<math qid=Q35875>E=mc^2</math>

Do we have a template, that would let the markup be entered in the form of:

{{Foobar |formula=E=mc^2 |qid=Q35875 }}

or even:

{{Foobar|E=mc^2|Q35875}}

If not, I plan to make one. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 13:00, 13 January 2020 (UTC)

Be aware that adding templates for basic wikitext like math means VisualEditor cannot edit them inline. --Izno (talk) 14:45, 13 January 2020 (UTC)
Then that's a bug in VE (such templates predate VE by many years). Is there an existing ticket? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 15:01, 13 January 2020 (UTC)
It's not a bug, but I'm not going to argue with you about it. I'm just letting you know that that is the case. As for templates, did you try {{math}} or look around related categories? --Izno (talk) 15:26, 13 January 2020 (UTC)
There's {{tmath}}, but it's hardly ever used, so I'm not sure if it would be worth the trouble. –Deacon Vorbis (carbon • videos) 19:58, 13 January 2020 (UTC)

Transfer from .tex document

A colleague has sent me some LaTeX, in a .tex document. What's the best way to get this onto a wiki page, preserving the markup? Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 16:42, 10 January 2020 (UTC)

@Pigsonthewing: Can you be a bit more specific about what you're trying to do? Is it purely text? Is it just a few equations you're trying to transfer? In any case, it will likely take some manual conversion. Someone writing a tex document is likely going to have at least a little bit of custom commands that they're using, which can't be used here. Mediawiki also doesn't use "real" TeX; it uses TexVC, which only implements a limited subset of math typesetting commands. If they're using anything that's not supported, then some decisions will have to be made about what you want to do. –Deacon Vorbis (carbon • videos) 01:32, 11 January 2020 (UTC)
I've been asked to recarte a series of PDF worksheets - including those on http://sigma.coventry.ac.uk/calculus - on a MediaWiki install. I've been sent the source document from which one of the PDFs, "C9 - Integration by Parts", was generated, to convert as a trial. I'm hoping we can make them available under an open licence. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 12:55, 13 January 2020 (UTC)
The way the worksheets are formatted into boxes like that is going to require some manual work to get started. I'd think you could set a template or two up for that and just mostly copy the text over. The equations could hopefully be mostly copied wholesale, but there's still some formatting to do, like changing $$...$$ to <math>...</math>. You might want to see if mw:Extension:MathJax would be suitable and helpful, though, as well. But again, any custom macros/environments in the .tex source will probably have to be dealt with manually as well. There might be some back-end magic for adding that in, but that's beyond what I know. –Deacon Vorbis (carbon • videos) 20:09, 13 January 2020 (UTC)

FormulaEditor

This screenshot shows the formula E = mc2 being edited using VisualEditor. The visual editor shows a button that allows to choose one of three offered modes to display a formula.

I suggest a Math Editor, a full visual editor for VisualEditor. This would work in a similar way to a calculator. If you put / in the visual box in your keyboard, it would put the wikitext: \frac . It also can link to a visual list with commons functions (as square root), mathematical input graphical environment or math handwriting recognition [2]. Just an idea ;-)

On the other hand, if you put the formula within {{align}} (i.e. to center it), Visual Editor does not work properly. So, better use wiki tags <center></center>


Example 1: Visual editor does not work to edit the formula, using {{align}}:


Example 2: Visual Editor works for editing, using <center></center>:

.--BoldLuis (talk) 16:13, 28 April 2020 (UTC)

Don't use <center>...</center>. If you want to center it, use <math display=block> and then use personal CSS. --Izno (talk) 16:35, 28 April 2020 (UTC)

"Math tag" listed at Redirects for discussion

An editor has asked for a discussion to address the redirect Math tag. Please participate in the redirect discussion if you wish to do so. –Deacon Vorbis (carbon • videos) 20:21, 17 April 2020 (UTC)

Green tickY Finished. --BoldLuis (talk) 16:37, 28 April 2020 (UTC)

InvisibleTimes, ApplyFunction

What is your stance on the novel character entity references in HTML 5 &InvisibleTimes; U+2062 and &ApplyFunction; U+2061? — Preceding unsigned comment added by 2A01:11CF:316:FD00:88A5:6B8F:93FB:4181 (talk) 08:29, 13 May 2020 (UTC)

What about them? And whose stance? People's opinions might differ. –Deacon Vorbis (carbon • videos) 14:14, 13 May 2020 (UTC)
They should be avoided inside <math>...</math> tags, as this is generally not compatible with unicode and these character cause parse errors.
Theoretically they covey some semantic meaning in HTML markup, using the {{math}} template etc. As they are invisable most readers will not be able the see any difference. For example in a⁢b⁡cd, there is U2062 between a and b, U2061 between b and c and nothing between c and d. The only people who might benefit might be someone with a screen reader, but as they are virtually unused across wikipedia its likely to cause more confusion. Their presence make it harder for other editors. Either its appears as a entity reference which most users will not have heard of, or the actual unicode character has been entered, as I've done in the abcd example, this make it a real pain to edit as you can't see anything but the cursor behave weirdly. I've cursed several times editing formula editor have cut and pasted from external sources containing similar invisible character.
To sum up I can see no benefits and plently of downsides to their use in wikipedia. --Salix alba (talk): 20:00, 13 May 2020 (UTC)

Fractions that include a multiplication symbol

When there are display formulæ that contain fractions involving algebra, multiplication is implied without any sign, as in

or
<math>\frac{a b}{a-b c}</math> or <math>{a b \over a-b c}</math>

But suppose I want to provide a numerical example of some interesting case, such as a=12, b=3 and c=4? Neither

or
<math>\frac{12 3}{12-3 4}</math> or <math>{12 3 \over 12-3 4}</math>

nor

Failed to parse (syntax error): {\displaystyle \frac{12×3}{12-3×4}} or Failed to parse (syntax error): {\displaystyle {12×3 \over 12-3×4}}
<math>\frac{12×3}{12-3×4}</math> or <math>{12×3 \over 12-3×4}</math>

nor

or
<math>\frac{12*3}{12-3*4}</math> or <math>{12*3 \over 12-3*4}</math>

are really acceptable.

On the other hand, whilst

or
<math>\frac{(12)(3)}{12-(3)(4)}</math> or <math>{(12)(3) \over 12-(3)(4)}</math>

and

or
<math>\frac{12 \cdot 3}{12-3 \cdot 4}</math> or <math>{12 \cdot 3 \over 12-3 \cdot 4}</math>

might be acceptable to some audiences, they are not ideal for a general audience. Remember that such formulæ may be appearing on all sorts of pages, not just those targeting an audience of mathematicians.

How is this supposed to be done, and could an example please be provided in the Help article?

—DIV (1.129.106.159 (talk) 07:07, 27 February 2021 (UTC))


Try using \times

or
<math>\frac{12\times 3}{12-3\times 4}</math> or <math>{12\times 3 \over 12-3\times 4}</math>

--Salix alba (talk): 07:14, 27 February 2021 (UTC)


Thanks, I just discovered that this might be the answer too, with an example under Tall parentheses and fractions. But I think it is worth its own dedicated simple example at Fractions, matrices, multilines. Or am I supposed to figure it out from Operators?
Anyway, is there any good reason why I cannot simply put a literal "×"? Why is that forbidden, but "+" is OK?
—DIV (1.129.106.159 (talk) 07:21, 27 February 2021 (UTC))

Latex predates the introduction of unicode and unicode characters, like U+00D7 × MULTIPLICATION SIGN, are not allowed in latex. Instead the backslash is used to encode special character. --Salix alba (talk): 11:18, 27 February 2021 (UTC)

Enter TeX quick edit quickly

I use the visual editor almost exclusively, and when I wish to write formulae in LaTeX the fastest way I know is to type "<math", which opens an editor that hides most of the page. On the other hand, clicking on existing TeX formula within an article brings up a "Quick Edit" box that doesn't hide the page and shows how the formula will appear when rendered inline. Is there a shortcut to bring up the quick edit box rapidly? Failing that, is there another way to enter TeX quickly short of editing source? I've tried asking this question on the general help desk, but it seems it was too niche. Krb19 (talk) 21:23, 17 June 2021 (UTC)

Displaying Greek LaTeX characters in Roman (upright) type

Is there any way of rendering e.g. as an upright symbol? This has come to my attention specifically in the context of typesetting the unit symbol for the micrometre. Without upright mu, this introduces a potential ambiguity (esp. in a formula containing mu as an algebraic symbol) and it is not correct. Vanilla LaTeX does not support upright Greek; such symbols are provided by the upgreek package, and correct SI symbols are provided by siunitx, but I do not know how to do a \usepackage{} in Wikipedia LaTeX fields, if this is even possible? Archon 2488 (talk) 09:54, 7 July 2021 (UTC)

A workaround is to use the Unicode character U+00B5 µ MICRO SIGN but it gets rendered in a wrong font: <math>3 \text{ µm}</math> renders as . It might be worth creating a request to add siunitx. —Dexxor (talk) 15:00, 7 July 2021 (UTC)
I've added this to the task for adding more characters to math mode: T286295
Dexxor's workaround is interesting, doing <math>\text{µ}</math> seems to work for various other unicode characters. So <math>\text{БЂЯғشفæ̃∮שא}</math> renders as (note slight change in order with right to left Hebrew Arabic characters). I'm not sure if this should be supported or not. There is a separate task for this issue T286294. --Salix alba (talk): 16:54, 7 July 2021 (UTC)

<math>\LaTeX</math> doesn't seem to work. Arlo James Barnes 10:27, 18 December 2021 (UTC)

Note: headings should not use templates or <math>...</math> tags. I edited this section's heading to remove the template transclusion.  — sbb (talk) 05:52, 30 December 2021 (UTC)

Factorials?

How do we do factorials, such as j1!, in LaTex? — kwami (talk) 22:34, 15 January 2022 (UTC)

It's . Or do I misunderstand your question? Mgnbar (talk) 03:02, 16 January 2022 (UTC)

Auto-spacing workaround unnecessary?

Is it just me, or are the two example renderings in § Formatting > Spacing (the long formula with and without enclosing curly braces) actually rendered identically, and both without any visible issues? Is the overfull hbox problem that's being worked around there no longer a concern? Should we remove that (non-)example? FeRDNYC (talk) 13:50, 14 May 2022 (UTC)

How to insert straight quotation marks in math formulas?

I'm working on replacing some low-quality images of formulas in applicative universal grammar (example) with wiki markup. However, the MathML renderer doesn't seem to want to straight double quotes. Help:Displaying a formula doesn't say anything about quotation marks. I've tried the following methods, but they all give me a syntax error:

  • \"
  • putting " inside \normaltext{} instead of \text{}
  • \char13
  • \textquotedbl
  • \textquotesingle \textquotesingle

Using two single quotes sort of works, but they appear as closing quotes and makes the output kind of ugly:

{{math}} displays double quotes just fine, but the output isn't as good as the MathML renderer because some of the text touches the vinculum:

"my" :: OTT   "friend" :: T/p q :: y

Anyone know what I'm doing wrong? Ixfd64 (talk) 18:21, 11 March 2022 (UTC)

@Ixfd64: I know it's been a while, but... Forgive the stupid question, but why do those formulas need to use straight double quotes? Would rendering them with curly quotes really alter their meaning?
I'm looking at the formulas currently on that page, for example:
(which looks very wrong to me, TBH) and I'm not really seeing what the problem would be with this:
Is it just some convention of the domain, that quotes must be straight-up-and-down? FeRDNYC (talk) 14:19, 14 May 2022 (UTC)
I was trying to math the original image as much as possible. I guess there are no real issues with using curly quotes. Ixfd64 (talk) 16:41, 14 May 2022 (UTC)

Reaction arrows in mhchem

I am attempting to insert the long version of the right-left arrows () into a chemical equation. According to mhchem documentation this is done with \ce{A <--> B}, but <chem>A <--> B</chem> results in

Why does it not work? Petr Matas 10:45, 1 July 2022 (UTC)

please don't use \ce or <chem>. Sometimes I use ←→ but it is not as good. Graeme Bartlett (talk) 12:41, 1 July 2022 (UTC)
According to IUPAC it is even incorrect. How would you write the following equation with the right-left arrows?
Petr Matas 13:04, 1 July 2022 (UTC)

Some hacky workarounds

<chem>A\ {}_{\longleftarrow}^{\longrightarrow}\ B\ \stackrel{\longrightarrow}{\longleftarrow}\ C\ \rightleftarrows\ D </chem>
--Salix alba (talk): 16:22, 1 July 2022 (UTC)
Not ideal, but as I actually only need to put the lone symbol into a table, I will go for <chem>\underset{<-}{->}</chem>. See it in action at Special:Diff/1096072833#Reaction types. Thanks for the inspiration. Petr Matas 04:13, 2 July 2022 (UTC)

In the end I rendered it with a standalone LaTeX and uploaded the SVG: Petr Matas 15:46, 15 July 2022 (UTC)

can we apply html formatting?

Sometimes I need to bold a simple math formulation. E.g. is used as a symbol (e.g. in alchemy), or a simple fraction but in a form faithful to the typesetting of the original (e.g. in Wikisource), and in a header I need it to display as bold. I could use the Unicode mathematical bold figures, but those have a distinct meaning in mathematics. Can I apply html bolding to match the rest of the text? — kwami (talk) 22:19, 5 August 2022 (UTC)

Also, I wanted to do something similar with Kannada: i.e. ^೧_೨, but it produces an error. I tried Unicode numbers, but that didn't work either. Is there a way around the character restriction? — kwami (talk) 23:49, 5 August 2022 (UTC)

Here you may want to use the various maths template so {{su|p=1|b=2}} renders as 1
2
, to get bold use {{su|p='''1'''|b='''2'''}} which renders as 1
2
. and {{su|p=೧|b=೨}} renders as  
. Any legal wikitext could be put in the arguments.

For the <math> the bold \mathbf could be used <math>^\mathbf{1}_\mathbf{2}</math> gives . Unicode character can appear inside a \text environment, <math>^\text{}_\text{}</math> gives . The latter case is undocumented.--Salix alba (talk): 03:32, 6 August 2022 (UTC)

"Display=Block" does not work with Dark Mode

When I run the Wikipedia app on my iPad, and I view in Dark Mode (black background; white text) ... many math formulas are invisible. I tracked it down to forumulas 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. Noleander (talk) 16:55, 8 August 2022 (UTC)

@Noleander: If <math display="block"> causes the math to be rendered in black instead of white, even in the dark skin, there's likely a CSS rule somewhere that's responsible for that. That rule can surely be corrected. It would be helpful if you could provide a link (or just the title) of at least one specific article that exhibits the problem, so that it can be investigated. FeRDNYC (talk) 22:44, 9 August 2022 (UTC)
@FeRDNYC Here is an article that had the problem: Reissner–Nordström metric. The edit I did that fixed the problem is: https://en.wikipedia.org/w/index.php?title=Reissner%E2%80%93Nordstr%C3%B6m_metric&type=revision&diff=1103053458&oldid=1102839763
I was on iPad, using Wikipedia app, with preference set to "Dark Mode" (or whatever it is called). Most formulas in Reissner–Nordström metric were NOT VISIBLE because of black text on black background. After I made the edit (above) the formula text became white, and looked great.
I have seen at least 100 pages in Wikipedia (english) that have this problem. The pattern seems to be all formulas that begin with <math display="block">. Noleander (talk) 17:23, 12 August 2022 (UTC)


I also reported this on WP HELP page at Wikipedia:Help_desk#Math_template:_Formulas_are_not_visible_on_iPad_in_Wikipedia_app,_in_Dark_Mode. Who is in charge of tempaltes at Wikipedia? Noleander (talk) 17:48, 12 August 2022 (UTC)

Why LaTeX and not just TeX?

The equation handling originates in the native TeX typesetting language. LaTeX is a common macro package for use with TeX to make things like page layout, paragraph formatting, font selection, etc. easier, but it has little if anything to do with the equation typesetting, which is part of plain (without the LaTeX package) TeX. — Preceding unsigned comment added by 198.91.146.105 (talk) 15:10, 11 September 2022 (UTC)

You're right about formula support originating with Plain TeX, way back when. (1983, to be exact.) But it's still definitely more accurate to say "LaTeX", when discussing the sort of equation support provided by <math>...</math> on MediaWiki.
Equation support for TeX typesetting systems was born with the AMSTeX macro package from the American Mathematical Society, written by Michael Spivak in the mid-1990s. Spivak also wrote a book, The Joy of TeX, in which he extensively documented AMSTeX.
But software evolves over time, and by the 1990s most users of TeX had adopted Leslie Lamport's advanced document layout and formatting macros: LaTeX. LaTeX advanced the state of the art in TeX typesetting immensely, particularly with its introduction of environments, localized customization domains which automated much of the layout tedium commonly associated with TeX.
LaTeX proved so popular with document and presentation authors, in fact, that AMSTeX was soon rewritten to both support and take advantage of LaTeX's layout automation. The rewritten amsmath package was combined with AMS' LaTeX document classes (until they were split again in 2016) and the AMS LaTeX package was born. It eventually superseded AMSTeX, and now LaTeX-amsmath is the only supported math package for TeX and its derivatives.[1]

The AMS no longer recommends the use of AMSTeX, and urges its authors to use the LaTeX classes and packages instead.

The AMS has actually made Spivak's Joy of TeX available for free on the web, alongside the final, deprecated release of the amstex distribution. So, anyone who's curious can check out what TeX-based equation formatting looked like, and how it differs from LaTeX's amsmath.
They're pretty different beasts. Like I said, one of LaTeX's major innovations was the introduction of envrionments, and amsmath makes heavy use of them. Every time you use a \begin{...} or \end{}, technically you're writing LaTeX, not TeX. TeX has no support for environments, and requires the author to do a lot more of the tedious formatting stuff themselves. LaTeX environments take care of a lot of that, letting the author focus on content rather than presentation.
Granted, most of what amsmath brings to the table over AMSTeX doesn't affect us, since we're only formatting equations and LaTeX was primarily oriented towards improving document layout. The major layout enhancements that led to AMSTeX's deprecation, things like automated equation numbering and figure captioning, are irrelevant here.
But the simple fact is, if you plug any of the examples from Spivak's book into a MediaWiki <math>...</math> tag, all you'll get is an error message. Extension:Math doesn't speak TeX, it speaks LaTeX. FeRDNYC (talk) 03:45, 20 September 2022 (UTC)
Here's a pretty good example of when the differences do affect us, though. Spivak presents a particular typeset equation layout in his book, on page 110 (p. 132 of the PDF): Exercise 17.4. On page 248 (pdf 270), in Appendix B, he provides the solution.
$$
\pmatrix \format\r&\quad\r\\
\cos\theta&\sin\theta\\
{-\sin\theta}&\cos\theta
\endpmatrix
\pmatrix \format\r&\quad\r\\
\cos\phi&\sin\phi\\
{-\sin\phi}&\cos\phi
\endpmatrix
=\pmatrix \format\r&\quad\r\\
\cos\rho&\sin\rho\\
{-\sin\rho}&\cos\rho
\endpmatrix,
\qquad \rho=\theta+\phi.
$$
That's pretty tedious, with a manual \format row defining each matrix to get everything to line up. But if we rewrite that using LaTeX instead of TeX, we can take advantage of something Spivak didn't have: The aligned sub-environment, which is designed to be nested inside of other equation environments (like each of the pmatrixes here), and makes the \formats unnecessary. With aligned it's child's play to line up the matrix members, and the code turns out so much cleaner.
\begin{pmatrix} \begin{aligned}
   \cos\theta && \sin\theta \\
{-\sin\theta} && \cos\theta
\end{aligned} \end{pmatrix}
\begin{pmatrix} \begin{aligned}
   \cos\phi && \sin\phi \\
{-\sin\phi} && \cos\phi
\end{aligned} \end{pmatrix}
=
\begin{pmatrix} \begin{aligned}
   \cos\rho && \sin\rho \\
{-\sin\rho} && \cos\rho
\end{aligned} \end{pmatrix},
\qquad \rho = \theta + \phi.
Which renders as...
Pretty faithful, I'd say. FeRDNYC (talk) 08:15, 20 September 2022 (UTC)

References

  1. ^ "What are the AMS packages (amsmath, etc.?)". TeXFAQ.

changing font size?

Probably a dumb question, but how does one change the font size?

For example, there are a few articles where I want to make the formulas larger. However, putting the formula inside {\Huge } gives me an error saying the function "Huge" is unknown. Ixfd64 (talk) 23:33, 5 October 2021 (UTC)

There's a bigmath template you could try:
  • {{math|1=''x'' + ''y'' = 77''z''}} yields x + y = 77z
  • {{bigmath|1=''x'' + ''y'' = 77''z''}} yields x + y = 77z
With the math HTML tag,
  • <math>x + y = 77z</math> yields ,
and you can increase it by wrapping the entire thing in an HTML tag such as big:
  • <big><math>x + y = 77z</math></big> yields .
I couldn't get \scalebox or \large to work.
I'm not sure how to arbitrarily change the size of individual elements of an equation. Probably it's not intended that this should be possible. Is there an example where this would be useful?
—DIV (1.145.91.247 (talk) 00:22, 31 October 2022 (UTC))
Support good-faith IP editors: insist that Wikipedia's administrators adhere to Wikipedia's own policies on keeping range-blocks as a last resort, with minimal breadth and duration, in order to reduce adverse collateral effects; support more precisely targeted restrictions such as protecting only articles themselves, not associated Talk pages, or presenting pages as semi-protected, or blocking only mobile edits when accessed from designated IP ranges.

Keep with in-text parentheses

Using the mvar template seems to keep the formula with in-text parentheses, but with the math tag it can break at the end of a line. What's the best way to avoid the latter, while keeping the exact same glyphs? See query at Talk:Greeks_(finance). —DIV (1.145.91.247 (talk) 00:26, 31 October 2022 (UTC))
Support good-faith IP editors: insist that Wikipedia's administrators adhere to Wikipedia's own policies on keeping range-blocks as a last resort, with minimal breadth and duration, in order to reduce adverse collateral effects; support more precisely targeted restrictions such as protecting only articles themselves, not associated Talk pages, or presenting pages as semi-protected, or blocking only mobile edits when accessed from designated IP ranges.

adjusting the font size for particular symbols

In most LaTeX document/equation environments it is possible to adjust the size of symbols somewhat precisely. There are various packages offering commands like \scalebox, \resizebox, \scalerel, \scaleto, \mathlarger, \relsize, \scalefont, etc., or as a hacky workaround recourse can be made to text mode with the various font size commands {\tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE \huge \Huge}, for example \text{\Large $ X $}. Being able to adjust the size is often very helpful for making tricky formulas legible or for repurposing symbols to work in other contexts.

As far as I can tell nothing like that is supported in Mediawiki's current LaTeX implementation. Is that right? Does anyone know any workarounds?

Most recently, I was hoping to resize \boxplus to use it as a large math operator approximately the same size as \bigoplus but this kind of thing comes up with some regularity.

For example there are equations where the display style of binomial coefficients is undesirably large but the inline style is illegibly small, where it would be very nice to be able to use an intermediate size. And so on. –jacobolus (t) 19:23, 2 March 2023 (UTC)

micro-

Do we have any means to type the SI prefix micro- (μ) inside <math>? \mu of course gives italicized μ, which is wrong; \mathrm{\mu} expectedly doesn't help; \textmu just gives an error (within or without \text{}); and <math>\SI{...}{\micro}</math> is also not supported. — Mikhail Ryazanov (talk) 02:02, 2 March 2023 (UTC)

Pretty sure Wikipedia's LaTeX implementation doesn't have any way to do this (there are like 10 different ways in a regular LaTeX document). Maybe just use plain wiki-markup when you need units. You can use {{math | &mu;}} to produce μ. –jacobolus (t) 05:33, 2 March 2023 (UTC)
It's interesting that the Phabricator ticket has absolutely no activity since its creation 1.5 year ago. Are there any technical difficulties? MathJax does support \textmu. PNG rendering should support everything without effort, I suppose. Is WP using something else, or it's simply that nobody cared to enable the textcomp package? — Mikhail Ryazanov (talk) 04:29, 3 March 2023 (UTC)