Help talk:Displaying a formula

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
WikiProject iconWikipedia Help NA‑class Mid‑importance
WikiProject iconThis page is within the scope of the Wikipedia Help Project, a collaborative effort to improve Wikipedia's help documentation for readers and contributors. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks. To browse help related resources see the Help Menu or Help Directory. Or ask for help on your talk page and a volunteer will visit you there.
NAThis page does not require a rating on the project's quality scale.
MidThis page has been rated as Mid-importance on the project's importance scale.

Use of raw HTML[edit]

Help:Displaying a formula#Use of raw HTML mentions that LaTeX is better than raw HTML, but then describes converting to {{math}}, which does not support LaTeX, rather than to <math>...</math>, which does. Shouldn't it at least mention the later and give a link to #LaTeX vs. {{math}}?

BTW, how do I escape braces in a wikilink? Shmuel (Seymour J.) Metz Username:Chatul (talk) 15:37, 20 February 2023 (UTC)[reply]

For using braces in a wikilink, you must use a pipe. For example, nth root may written as [[Nth root|{{mvar|n}}th root]]. D.Lazard (talk) 17:19, 20 February 2023 (UTC)[reply]
I'm not asking about braces in the displayed text, I'm asking about braces in the page or section name; in this case, Help:Displaying a formula#Use #LaTeX vs. {{braces|math}}
A related issue is that <math>...</math> looks like raw HTML to the uninitiated, but in raw HTML the contents are interpreted as MATHML while in wikitext the contents are interpreted as LaTeX. -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 09:50, 8 May 2023 (UTC)[reply]

Vertical alignment advice seems outdated?[edit]

This help page says:

If you need to align it otherwise, use <math style="vertical-align:-100%;">...</math> and play with the vertical-align argument until you get it right; however, how it looks may depend on the browser and the browser settings.
If you rely on this workaround, if and when the rendering on the server gets fixed in a future release, this extra manual offset will suddenly make every affected formula align incorrectly. So use it sparingly, if at all.

This seems wrong. Looks like the software now explicitly sets vertical-align to some specific value and does not allow user adjustment. For example and are not aligned to the same baseline (the one with the fraction is a bit too high), but if I try to set vertical-align explicitly nothing happens: even something dramatic like <math style="vertical-align:-500%;">\tfrac12\pi r^2</math> still appears like which is unchanged. If I want to adjust I need to wrap in a span like: <span style="vertical-align:-.03em;"><math>\tfrac12\pi r^2</math></span> <span style="vertical-align:-.02em;"><math>2\pi r.</math></span> But since even the basic TeX is not quite right (at least on my computer/browser/skin) I don’t intend to do this in practice on Wiki articles.

Perhaps that section should be removed or at least amended. –jacobolus (t) 03:54, 20 March 2023 (UTC)[reply]

"Rendering" TeX/LaTeX[edit]

I've just reverted my deletions from Weak gravitational lensing. I thought I was looking at source-code for some formula-renderer, I didn't realize that rendition was what Wikipedia intends.

I've never come across this notation before; it certainly wasn't taught to me at school. Who learns it now? Is this knowledge restricted to people write formulae for publication? Most wikipedians have never written a formula for publication.

To me, that notation looks like a transfer format, for passing a description of a formula to a proper formula renderer, one that uses the customary notation. Does such a renderer exist?

So can someone disable the use of this notation for now (e.g. on pages where it hasn't already been used)? Or at least, give some clear warning at the top of the page that, for now, this isn't the best way to present formulae to the general public?

MrDemeanour (talk) 18:31, 3 May 2023 (UTC)[reply]

Sorry, I don't understand. Are you asking what TeX/LaTeX is? Mgnbar (talk) 18:46, 3 May 2023 (UTC)[reply]
It seems that you read the source code of the article instead of reading the article itself. The TeX/LaTeX commands that appear in the source code are not intended to be read by non-specialists (of mathematical typography), and have nothing to do with a notation. Their aim is to produce a rendering that agrees with standards of mathematical notation. D.Lazard (talk) 19:22, 3 May 2023 (UTC)[reply]
> It seems that you read the source code of the article instead of reading the article itself.
Not true. The source code is delimited by <math> tags; the rendered output contains ASCII notation delimited by dollar signs.
And I know what TeX and LaTeX are. They are respectively a math typesetting language invented by Knuth, and a simplified version of the same (and no - I don't know either language). The rendered output of these languages should be publication-quality formulae expressed using traditional formula notation, not some ASCII notation that as far as I know is private to TeX and LaTeX.
Judging by the amount of space in this page devoted to learning the TeX and LaTeX languages, I conclude that this is the approved way of marking-up formulae in wiki pages. What I'm saying is that I think the "approved way" should produce rendered output that looks like a publication-quality formula. If the closest we can manage is TeX and LaTeX, and this Perl-like rendered output, that's disappointing.
MrDemeanour (talk) 10:10, 4 May 2023 (UTC)[reply]
Not quite: TeX is a markup language and LaTeX ia a set of macros written in TeX; in practice people use some of the underlying TeX commands when using LaTeX. TeX uses $ to delimit formulae; as others have suggested, check your profile. With normal settings you shoul not be seeing raw TeX. -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 13:24, 4 May 2023 (UTC)[reply]
WP:FORMULAE has a discussion of rendering formulae. The preferred way is to use LaTeX inside of <math>...</math>. Even outside of wiki, LaTeX is a bog standard markup language; its uses go well beyond mathematical and scientific papers.
An alternative is to use {{math}} and {{mvar}}.
NB: Always look at the rendered text before changing markup. -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 19:38, 3 May 2023 (UTC)[reply]
> it is entered as <math>E=mc^2</math>, and rendered as $ E=mc^{2} $
Frankly, "E=mc^2" seems to me a clearer and more broadly-recognized notation than "$ E=mc^{2} $". The latter includes syntactic sugar that might be helpful for a real formula-renderer, but is of no help to a human reader at all.
Am I perhaps lacking some plugin for rendering LaTeX output as a properly-typeset formula?
MrDemeanour (talk) 10:19, 4 May 2023 (UTC)[reply]
Is this knowledge restricted to people write formulae for publication? – This knowledge is available to anyone willing to read the relevant documentation or any of the many guides/tutorials available online or any of the many relevant books, etc. (La)TeX is the primary markup language used for scientific communication around the world, and is used for all kinds of documents, especially any which include mathematical formulas. TeX and Mediawiki are both entirely open projects, and there are no hidden secrets involved here. It does take a bit of getting used to though. –jacobolus (t) 21:29, 3 May 2023 (UTC)[reply]
Why do I need to read "many relevant books" to learn to read math formulae on Wikipedia, when I already know how to read math formulae, provided they're typeset in the customary way?
I didn't come here to complain; I came to get some enlightenment on WP policy concerning formulae, and possibly concerning how my browser is set up. Specifically, is there some plugin that will convert that dollar notation into a proper formula?
It seems to me that WP used to contain proper typeset formulae, and that suddenly all formulae seem to be using this dollar notation. Here is an image example of a typeset formula:
https://upload.wikimedia.org/wikipedia/commons/7/75/MathematicaTypesetExpression.png
I can't now find any example of a proper typeset formula. Everywhere I look, I see this ASCII dollar notation. That's why I suspect I have some kind of configuration problem.
MrDemeanour (talk) 10:39, 4 May 2023 (UTC)[reply]
Yes, you have some configuration problem. No, you are not supposed to see any dollar signs. It must be frustrating, to experience this issue, and have all of us mis-understand you. :)
I'm not an expert on such issues, but by reading Help:Displaying a formula#Display format of LaTeX, I would guess that, in your Preferences / Appearance / Math, you have somehow chosen to display LaTeX source rather than SVG. Does changing that setting help? Mgnbar (talk) 11:47, 4 May 2023 (UTC)[reply]
Oh good catch, that setting does do this. I didn't realize that was even a possibility. @MrDemeanour go to Special:Preferences § Appearance and under the "Math" setting tick the "SVG" radio button instead of "LaTeX source". –jacobolus (t) 18:11, 4 May 2023 (UTC)[reply]
I did indeed have "Display LaTeX source" selected, rather than SVG. I don't know why I would have changed that; I don't use a text browser. I've now selected SVG, and it works. Thank you!
Yes, it has been a little frustrating; But if I was not understood, thast must be in part because I wasn't expressing myself clearly. I assume good intentions on the part of my fellow editors!
That config option is not very clear; I don't want to see LaTeX source or SVG, I want to see rendered formulae. But it's radio buttons; you have to choose one or the other.
MrDemeanour (talk) 08:31, 5 May 2023 (UTC)[reply]
I'm glad that you've made progress, but your last comment concerns me. You're not seeing SVG code, right? The math, that you're seeing, should be formulas rendered beautifully, like in a well-made textbook (except maybe for discrepancies, in type face or size, with respect to the surrounding text). If not, then make sure your web browser supports SVG? Mgnbar (talk) 17:43, 5 May 2023 (UTC)[reply]
I think the complaint is that the name "SVG" shown in the preferences is not meaningful to non-expert readers, not that the SVG formulas are being rendered improperly. This seems like a fair criticism: someone who accidentally toggles this display setting is not necessarily going to be able to recognize that their settings are misconfigured or be able to figure out how to undo the change, as the setting itself is not the easiest to find or most clearly labeled. –jacobolus (t) 17:54, 5 May 2023 (UTC)[reply]
Ah, that makes more sense. Mgnbar (talk) 18:42, 5 May 2023 (UTC)[reply]
Not exactly. The "complaint" is that SVG is markup, and LaTeX is markup. So I'm given radio buttons to choose between viewing formulae as this kind of markup, or that kind of markup. But I don't wat to see formulae as markup at all.
One of the choices should be "Don't display formulae as markup". That's what the SVG radio button does, but that's not what its label says.
To be honest, I don't know why this config option exists at all. If someone wants to view the markup for a formula, they can simply view the page source. I don't know what the use-case is for viewing markup in a rendered page.
MrDemeanour (talk) 12:14, 7 May 2023 (UTC)[reply]
My guess is that there are browser that support TeX markup and there are browsers that don't support SVG. What is the proper venue to suggest that the button labels LaTeX source (for text browsers) and SVG (MathML can be enabled via browser plugin) be clarified? -- Shmuel (Seymour J.) Metz Username:Chatul (talk) 13:17, 7 May 2023 (UTC)[reply]
I think that the option exists to support text-only web browsers. This may or may not include screen readers; I don't know enough. But your point stands. I'll try to raise it in the appropriate forum somewhere (unless someone can beat me to it...). Mgnbar (talk) 13:34, 7 May 2023 (UTC)[reply]
From the perspective of the "LaTeX" on the page, SVG is an output format. The browser natively understands how to render SVG, but not TeX source. But the label should probably be changed to "typeset formulas"; previously I believe there were more than 2 options. –jacobolus (t) 19:38, 8 May 2023 (UTC)[reply]
Something is definitely wrong: You should not ever be seeing LaTeX markup in rendered output (unless someone temporarily messed up a page's source), and if you are seeing those site-wide then there’s something going wrong. Did you try looking with another browser, in a "private browsing" window, or on another machine? You do not need to know anything about LaTeX to read Wikipedia articles, only to write them. (And to write mathematical Wikipedia articles you can start with a quick tutorial somewhere; my point in mentioning books is to say that there are a wide variety of resources available for helping LaTeX authors, not that you need to be an expert up front). –jacobolus (t) 18:04, 4 May 2023 (UTC)[reply]

Chemical formulas via <math>[edit]

If its not recommended to use chem or math chem tags, could we add chemical formulas to math tag? Juandev (talk) 09:01, 5 October 2023 (UTC)[reply]

OCR tools[edit]

There is at least one OCR tool that can convert a handwritten formula to Latex and other formats. Mathpix allows 10 snips a month free. I don't know enough to edit the body of the Help page (I've not yet used Mathpix so don't know how good it is, and how compatible with Wikipedia, and don't know what else is out there), but I think there should be a Tools section with this sort of information. For now I've added an external link - feel free to delete if it's thought too commercial. Best wishes, Pol098 (talk) 22:57, 17 October 2023 (UTC)[reply]

Comments?[edit]

I read somewhere that % was the comment-character in TeX; but that seems to render actual percentage-signs:

How can I write a comment in the source-code that doesn't appear in the rendered output? ELLIOTTCABLE (talk) 21:31, 18 October 2023 (UTC)[reply]

As far as I know comments are not supported in Mediawiki's LaTeX implementation. –jacobolus (t) 02:04, 1 December 2023 (UTC)[reply]

Adding a countour around a character in LaTeX Equations[edit]

How can we add contours (an outline around the character) to LaTeX equations, especially when an equation is using colors that cannot be clearly visible on white, such as yellow? Abhiramakella (talk) 21:48, 30 November 2023 (UTC)[reply]

Can you be a little clearer about what you mean? Equations should not in general be using colors, or if they are the use should be restrained; there is no reason to ever use yellow in an equation on Wikipedia. –jacobolus (t) 02:03, 1 December 2023 (UTC)[reply]
Sorry for contrib-stalking, but I got to do it to figure out the context. It looks like you're talking about the colors on Kruskal–Wallis one-way analysis of variance. My recommendation is: don't. The colors do not add much usefulness to the equations. Well, it's somewhat useful on the three kinds of r, but beyond that, don't. Artoria2e5 🌉 23:43, 2 January 2024 (UTC)[reply]

Dumping all the texvc mentions[edit]

The help page retains a lot of mentions of the legacy OcaML texvc, which validates tex syntax and calls a real LaTeX program to do the rendering. It has ceased being a thing since MediaWiki 1.32 (2018), so it would make sense to stop referring to it. (Not texvcjs though: that's a bona fide part of Mathoid, the new stuff.)

The following sections need to be changed:

  • Help:Displaying a formula#Alphabets and typefaces starts with saying texvc can't do stuff. The good news is Mathoid also can't (because texvcjs decides to), so just swap the mention out.
  • Help:Displaying a formula#Color has some prominent mention of texvc. This one is going to be a little more complicated, because I'm honestly not sure whether the incompatibility in the last example is caused by the LaTeX program behind texvc or really "texvc" itself. This distinction matters because the Math extension (before version 1.39 -- is it old enough to be ignored?) has the ability to call a real LaTeX program in "png" mode.
    • In addition, we may also need to check compatibility with NIST's LaTeXML service. That, like the "png" mode, is obviously useless for English Wikipedia, but it could still be a good-to-have because this help page serves as some sort of a "global Extension:Math help page".
  • Help:Displaying a formula#Unicode characters has one small mention. This is easy to fix, I should be able to do it right now.
  • I think the legacy syntax list can stay for a while longer.

Artoria2e5 🌉 12:12, 3 January 2024 (UTC)[reply]