Wikipedia:Rendering math
Appearance
(Redirected from Wikipedia:MathML)
This is an essay. It contains the advice or opinions of one or more Wikipedia contributors. This page is not an encyclopedia article, nor is it one of Wikipedia's policies or guidelines, as it has not been thoroughly vetted by the community. Some essays represent widespread norms; others only represent minority viewpoints. |
This page in a nutshell: There exist at least three different forms of math formulae on Wikipedia pages, with at least seven ways to present them. None is completely satisfactory. |
This essay offers a comparison of different encodings and presentation of mathematical formulae. The three principal ones are the <math>
tag, raw wiki (or HTML) code, and "texhtml" templates. The <math>
and "texhtml" encoding may have different presentations for registered users, depending on user preferences and personal styles.
Comparison of markup encodings
[edit]Encoding | Advantages | Disadvantages |
---|---|---|
<math> LaTeX</math>
|
|
|
Raw wiki or HTML code |
|
|
"texhtml" templates, such as {{math}} |
|
|
Comparison of presentations
[edit]Encoding | Presentation | Advantages | Disadvantages |
---|---|---|---|
<math>
|
SVG with hidden MathML (Wikipedia's default) |
|
|
PNG |
| ||
Native MathML |
|
| |
MathJax |
|
| |
KaTeX |
|
| |
Raw wiki or HTML code |
|
| |
{{math}} ('texhtml' class) |
|
| |
Specific templates | |||
{{mvar}}: x |
|
| |
{{sqrt}}: √2 |
|
| |
{{radic}}: 3√2 |
|
| |
{{sfrac}}: 1/2 |
|
| |
{{frac}}: 1⁄2 |
|
| |
|
|
| |
Bra–ket notation: |
|
| |
{{vec}}: A→ |
|
| |
{{intmath}}: ∫+∞ 0 |
|
| |
|
|
Pros of HTML
[edit]- Formulas in HTML behave more like regular text. In-line HTML formulae always align properly with the rest of the HTML text and, to some degree, can be copied-and-pasted (this is not a problem if TeX is rendered using MathJax, and the alignment should not be a problem for PNG rendering now that bug 32694 is fixed).
- The formula's background and font size match the rest of HTML contents (this can be fixed on TeX formulas by using the commands
\pagecolor
and\definecolor
) and the appearance respects CSS and browser settings while the typeface is conveniently altered to help you identify formulae. - Pages using HTML code for formulae will load faster and they will create less clutter on your hard disk.
- Formulae typeset with HTML code will be accessible to client-side script links (a.k.a. scriptlets).
- The display of a formula entered using mathematical templates can be conveniently altered by modifying the templates involved; this modification will affect all relevant formulae without any manual intervention.
- The HTML code, if entered diligently, will contain all semantic information to transform the equation back to TeX or any other code as needed. It can even contain differences TeX does not normally catch, e.g.
{{math|''i''}}
for the imaginary unit and{{math|<var>i</var>}}
for an arbitrary index variable. - Unlike generated bitmaps, HTML is not sensitive to dots per inch variances between viewing platforms.
Pros of TeX
[edit]- TeX is semantically more precise than HTML.
- In TeX, "
x
" means mathematical variable "", whereas in HTML "x
" is generic and somewhat ambiguous. - On the other hand, if you encode the same formula as "
{{math|<var>x</var>}}
", adding the var tag doesn't affect the visual result x and provides the additional semantic description that x is a variable. This requires diligence and more typing that could make the formula harder to understand as you type it, and provides no help to most readers, but could be worth considering if no other rendering options are available.
- In TeX, "
- One consequence of point 1 is that TeX code can be transformed into HTML, but not vice versa.[4] This means that on the server side we can always transform a formula, based on its complexity and location within the text, user preferences, type of browser, etc. Therefore, where possible, all the benefits of HTML can be retained, together with the benefits of TeX. It is true that the current situation is not ideal, but that is not a good reason to drop information or contents. It is more a reason to help improve the situation.
- Another consequence of point 1 is that TeX can be converted to MathML (e.g. by MathJax) for browsers which support it, thus keeping its semantics and allowing the rendering to be better suited for the reader’s graphic device.
- TeX is the preferred text formatting language of most professional mathematicians, scientists, and engineers. It is easier to persuade them to contribute if they can write in TeX.
- TeX has been specifically designed for typesetting formulae, so input is easier and more natural if you are accustomed to it, and output is more aesthetically pleasing if you focus on a single formula rather than on the whole containing page.
- Once a formula is done correctly in TeX, it will render reliably, whereas the success of HTML formulae is somewhat dependent on browsers or versions of browsers. Another aspect of this dependency is fonts: the serif font used for rendering formulae is browser-dependent and it may be missing some important glyphs. While the browser is generally capable to substitute a matching glyph from a different font family, it need not be the case for combined glyphs (compare "a̅" and " a̅").
- When writing in TeX, editors need not worry about whether this or that version of this or that browser supports this or that HTML entity. The burden of these decisions is put on the software. This does not hold for HTML formulae, which can easily end up being rendered wrongly or differently from the editor’s intentions on a different browser.[5]
- TeX formulae, by default, render larger and are usually more readable than HTML formulae and are not dependent on client-side browser resources, such as fonts, and so the results are more reliably WYSIWYG.
- While TeX does not assist you in finding HTML codes or Unicode values (which you can obtain by viewing the HTML source in your browser), copying and pasting from a TeX PNG image in Wikipedia into simple text will return the LaTeX source.
- ^ Unless your wikitext follows the style of point 1.2
- ^ The entity support problem is not limited to mathematical formulae though; it can be easily solved by using the corresponding characters instead of entities, as the character repertoire links do, except for cases where the corresponding glyphs are visually indiscernible (e.g. – for ‘–’ and − for ‘−’).
In some cases it may be the best choice to use neither TeX nor the HTML substitutes, but instead Unicode or the simple ASCII symbols of a standard keyboard.
Discussions
[edit]- Help:Displaying a formula
- Wikipedia talk:MOSPHYS
- Wikipedia talk:WikiProject Mathematics/Archive/2013/Jan #Destruction of .7B.7Bmath.7D.7D and similar templates
- Discussion about MathJax vs MathML and the future of math formatting on Wikipedia
See also
[edit]- Wikipedia:WikiProject Mathematics/Typography
- Wikipedia:texvc, a
<math>
to HTML converter; not used for HTML anymore - Category:Mathematical formatting templates