Wikipedia:Rendering math

Frá Wikipedia, hin frælsa alfrøðin

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 encodings[rætta wikitekst]

Encoding Advantages Disadvantages
<math> Well-known and standardized.
Portable to/from scientific papers.
Clearly distinguishes semantics from appearance.
Can handle all formulae.
Requires knowledge of LaTeX markup language.
Lacks some characters (such as Cyrillic script).
Unable to place wikilinks on parts of formulae.
Raw wiki or HTML code Flexible and easy to learn.
Same markup as the rest of wiki.
Encodes the appearance of a formula rather than its semantics.
Unable to handle square roots, vertical fractions, and other common formula types.
Proper use (italic variables, protected spaces around operators) requires care and is a frequent source of mistakes.
"texhtml" templates, such as {{math}} Simplifies many of the problematic and failure-prone parts of raw wiki markup.
Distinguishes semantics from appearance.
More polished appearance than wiki/HTML code and faster rendering than mathJax.
Vulnerable to changes in templates and styles.
The ubiquitous = symbol requires special care.
Unable to handle complex formulae such as those involving summations and limits.

Comparison of presentations[rætta wikitekst]

Encoding Presentation Advantages Disadvantages
<math> [[LaTeX|Fyrimynd:LaTeX]] renderer
(Wikipedia’s default)
Robust.
Little overhead in a browser.
A bitmap image format that does not match article text in size and cannot be copied and pasted.
MathML with SVG fallback Robust.
Easy for registered users to use.
Little overhead in a browser.
Not usable by unregistered readers. Requires modern browsers. Has minor formatting bugs (e.g. mismatched baselines)
MathJax The best look. Easy for registered users to use. Text-friendly (except for hyperlinks). Uses very little server-side computation. Not usable by unregistered readers. Uses more client-side (in-browser) computation. Causes errors in vertical position after jumping to a #-link. Requires a modern browser. Slow to fix reported bugs. Fonts are downloaded from server unless the user has manually installed them.
Raw wiki or HTML code Avoids switching font families in running text.
Minimal overhead.
Appearance does not depend on user (account) preferences.
Does not distinguish a formula from the running text.
The kerning often looks ugly and even illegible (such as in F−1), which is difficult to rectify.
In articles mixing raw wiki with <math> formulae, the appearance of the same variable in the two types of formula does not match (serif vs sans-serif).
{{math}} ('texhtml' class) Distinguishes a formula from the running text.
Close match to the appearance of inline <math>.
Mixing of font families (sans-serif for English, serif for math), in running text, can be jarring.
Specific templates
{{mvar}}: x A shorthand for variables like {{math|''x''}}.
Clean semantics.
Cannot be used for vectors.
{{sqrt}}: 2 Clean semantics. The vinculum is slightly interrupted.
Does not look well under {{math}} or so, itself.
{{radic}}: 32 Clean semantics. Same as above.
{{sfrac}}: 1/2 Clean semantics. Occupies too much vertical space in a running text. Embedded sub- and superscript causes vertical misalignment.
{{frac}}: 12 Clean semantics. Discouraged by WP:MOSMATH.
{{open-open}}: Fyrimynd:Open-open
{{open-closed}}: Fyrimynd:Open-closed
{{closed-open}}: Fyrimynd:Closed-open
{{closed-closed}}: Fyrimynd:Closed-closed
Semantically distinguishes intervals from other types of formula. Because the interval endpoints are coded as a single parameter, the semantics is a bit obscure.
Bra–ket notation:
{{ket}} |ψ
{{bra}} ψ|
{{bra-ket}} ψ|ξ
Semantically distinguishes bra–ket notation from other types of formula. Avoids complex html coding for angular bracket characters ⟨ &#amp;x27E8; or {{langle}}, ⟩ &#x27E9; or {{rangle}}, and vertical bar | &#124; and prevents incorrect usage of less-than/greater-than signs for these characters. Angular brackets may not render on all browsers.
{{vec}}: A Clean semantics. The arrow may not be precisely centered over certain letters
{{intmath}}: +∞
0
Clean semantics. Name differs from math/LaTeX coding conventions.
{{overset}}: A, ~A

{{underset}}: A, A~

Clean semantics. Produces bad spacing when combined with fraction templates.

Discussions[rætta wikitekst]