Help talk:Displaying a formula

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Wikipedia Help Project (Rated 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.
 NA  This page does not require a rating on the project's quality scale.
 Mid  This page has been rated as Mid-importance on the project's importance scale.

LaTeX Incorrect Rendering[edit]

(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?[edit]

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?[edit]

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 — 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[edit]

I perceived that


generates an error, and


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[edit]

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[edit]

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)