Help:Displaying a formula#Unsorted (new stuff)
{{Short description|Wikipedia help page about displaying math formulas}}
{{Redirect|WP:MATH}}
{{Wikipedia how-to|WP:FORMULA|WP:MATH|WP:MATHS|WP:LATEX}}
File:Editing a formula using VisualEditor.png. The window is opened by typing "
There are three methods for displaying formulas in Wikipedia: raw HTML, HTML with math templates (abbreviated here as {{tl|math}}), and a subset of {{stylized LaTeX}} implemented with the HTML markup
For example, the famous Einstein formula can be entered in raw HTML as
Use of raw HTML
Variable names and many symbols look very different with raw HTML and the other display methods. This may be confusing in the common case where several methods are used in the same article. Moreover, mathematicians who are used to reading and writing texts written with LaTeX often find the raw HTML rendering awful.
So, raw HTML should normally not be used for new content. However, raw HTML is still present in many mathematical articles. It is generally a good practice to convert it to {{tl|math}} format, but coherency must be respected; that is, such a conversion must be done in a whole article, or at least in a whole section. Moreover, such a conversion must be identified as such in the edit summary, and making other changes in the same edit should be avoided. This is for helping other users to identify changes that are possibly controversial (the "diff" of a conversion may be very large, and may hide other changes).
Converting raw HTML to {{tl|math}} is rather simple: when the formula is enclosed with {{tl|nowrap}}, it suffices to change "nowrap" into "math". However, if the formula contains an equal sign, one has to add
LaTeX vs. <nowiki>{{math}}</nowiki>
{{anchor|LaTeX vs. math template}}
These two ways of writing mathematical formulas each have their advantages and disadvantages. They are both accepted by the manual of style MOS:MATH. The rendering of variable names is very similar. Having a variable name displayed in the same paragraph with {{tlx|math}} and
The disadvantages of LaTeX are the following:
On some browser configurations, LaTeX inline formulas appear with a slight vertical misalignment, or with a font size that may be slightly different from that of the surrounding text. This is not a problem with a block displayed formula, and also typically not with inline formulas that exceed the normal line height marginally (for example formulas with subscripts and superscripts).
The use of LaTeX in a piped link or in a section heading does not appear in blue in the linked text or the table of content. Moreover, links to section headings containing LaTeX formulas do not always work as expected.
Finally, having many LaTeX formulas may significantly increase the processing time of a page. LaTeX formulas should be avoided in image captions or footnotes, because when the image is clicked for a larger display or a footnote is selected on a mobile device, LaTeX in the caption or footnote will not render.
Disadvantages of {{tl|math}} include that not all formulas can be displayed, and while it may be possible to display a complicated formula with {{tl|math}}, it may be poorly rendered. Except for the most common symbols such as letters, numerals, and basic punctuation, rendering of Unicode mathematical symbols can be inconsistent in size or alignment where fallback fonts do not match, and some readers may not have any font which includes certain uncommon symbols. Spaces within a formula must be directly managed (for example by including explicit hair or thin spaces). Variable names must be italicized explicitly, and superscripts and subscripts must use an explicit tag or template. Except for short formulas, the source of a formula typically has more markup overhead and can be difficult to read.
The common practice of most members of WikiProject mathematics is the following:
- Use of {{tl|mvar}} and {{tl|math}} for isolated variables and {{tl|math}} for simple inline formulas; or alternately the use of LaTeX for these purposes (optionally using the {{tl|tmath}} template), especially on articles with many complex formulas or where rendering seems inconsistent
- Use of {{tl|mvar}} and {{tl|math}} for formulas in image captions, even if the rendering is mediocre
- Use of LaTeX for separately displayed formulas and more complicated inline formulas
- Use of LaTeX for formulas involving symbols that are not regularly rendered in Unicode (see MOS:BBB)
- Avoid formulas in section headings, and when this is necessary, use raw HTML (see Finite field for an example)
The choice between {{tl|math}} and LaTeX depends on the editor. Converting a page from one format to another must be done with stronger reasons than editor preference.
= Display format of LaTeX =
{{see also|mw:Extension:Math}}
By default SVG images with non-visible MathML are generated. The text-only form of the LaTeX can be set via user preferences at My Preferences – Appearance – Math.
The hidden MathML can be used by screen readers and other assistive technology. To display the MathML in Firefox:
- Install the [https://addons.mozilla.org/en-US/firefox/addon/native-mathml/ Native MathML] extension
- Or copy [https://github.com/fred-wang/webextension-native-mathml/blob/master/content-scripts/mediawiki.css its CSS rules] to your Wikipedia user stylesheet.
In either case, you must have fonts that support MathML ([https://developer.mozilla.org/en-US/docs/Mozilla/MathML_Project/Fonts see developer.mozilla.org]) installed on your system. For copy-paste support in Firefox, you can also install [https://addons.mozilla.org/en-US/firefox/addon/mathml-copy/ MathML Copy].
Use of HTML templates
{{Shortcut|WP:MATHSYMBOL}}
{{See also|Wikipedia:Rendering math}}
TeX markup is not the only way to render mathematical formulas. For simple inline formulas, the template {{tl|math}} and its associated templates are often preferred. The following comparison table shows that similar results can be achieved with the two methods. See also Help:Special characters.
class="wikitable" |
TeX syntax
! TeX rendering |rowspan=5| ! HTML syntax ! HTML rendering |
---|
| | | {{math|α}} or {{mvar|α}} |
| | | {{math|1=f(x) = x2}} |
| | | {{math|{{mset|1, e, π}}}} |
| | | {{math|{{abs|z}} ≤ 2}} |
Here is a summary of the mathematical templates:
{{math templates|notation}}
Care should be taken when writing sets within {{tl|math}}, as braces, equal signs, and vertical bars can conflict with template syntax. The {{tl|mset}} template is available for braces, as shown in the example above. Likewise, {{tl|abs}} encloses its parameter inside vertical bars to help with the pipe character conflicting with template syntax. For a single vertical bar, use {{tlx|!}}, and for an equal sign, use {{tlx|{{=}}}}.
= HTML entities =
Though Unicode characters are generally preferred, sometimes HTML entities are needed to avoid problems with wiki syntax or confusion with other characters:
{{aligned table|cols=10|style=text-align:center;|row1class=unicode|row2class=mw-code
| < | > | − | • |′ | ″ | ⋅ | ·| – | —
| < | > | − | • | ′ | ″ | ⋅ | · | – | — }}
In the table below, the codes on the left produce the symbols on the right, but these symbols can also be entered directly in the wikitext either by typing them if they are available on the keyboard, by copy-pasting them, or by using menus below the edit windows. (When editing any Wikipedia page in a desktop web browser, use the "Insert" pulldown menu immediately below the article text, or the "Special characters" menu immediately above the article text.) Normally, lowercase Greek letters should be entered in italics, that is, enclosed between two single quotes (
class="wikitable" border=1 |
HTML syntax
! Rendering |
---|
style="vertical-align:middle;"
| α β γ δ ε ζ | α β γ δ ε ζ |
style="vertical-align:middle;"
| Γ Δ Θ Λ Ξ Π | Γ Δ Θ Λ Ξ Π |
style="vertical-align:middle;"
| ∫ ∑ ∏ − ± ∞ | ∫ ∑ ∏ − ± ∞ |
style="vertical-align:middle;"
| ∈ ∉ ∩ ∪ ⊂ ⊃ ⊆ ⊇ | ∈ ∉ ∩ ∪ ⊂ ⊃ ⊆ ⊇ |
= Superscripts and subscripts =
{{aligned table|cols=3|style=text-align:center;|row1class=unicode|row2class=mw-code|x2 | x3 | x{{su|b=1|p=2|lh=1}} |
= Spacing =
To avoid line-wrapping in the middle of a formula, use {{tl|math}}. If necessary, a non-breaking space ( ) can be inserted with " ". When an inline formula is long enough, it can be helpful to allow it to break across lines. Whether using LaTeX or templates, split the formula at each acceptable breakpoint into separate
Typically whitespace should be a regular space ( ) or none at all. In rare circumstances, such as where one character overlaps another due to one being in italics, a thin space can be added with {{tl|thin space}}.
= More =
For more on Wikipedia howtos and math style guidelines:
- MOS:FRAC for how to input fractions in various circumstances
- MOS:RADICAL for how to square and other roots in various circumstances
- Per MOS:ELLIPSIS, "..." (three ASCII periods) is used instead of "…" (single character)
- {{section link|Arrow (symbol)|Arrows in Unicode}}
- Mathematical operators and symbols in Unicode
- Wikipedia:Manual of Style (mathematics)
For more on special characters:
- [http://www.unicode.org/charts/charindex.html Unicode character name index] can be used to find the Unicode number of a character.
- [http://www.w3.org W3C] list of MathML characters indexed by [http://www.w3.org/TR/MathML2/bycodes.html code] or [http://www.w3.org/TR/MathML2/byalpha.html name]
- List of XML and HTML character entity references – includes all named entities
- Glossary of mathematical symbols
LaTeX basics
Math markup goes inside
can be used in place of
The TeX code has to be put literally: MediaWiki templates, predefined templates, and parameters cannot be used within math tags: pairs of double braces are ignored and "#" gives an error message. However, math tags work in the then and else part of #if, etc. See {{tim|Demo of attempt to use parameters within TeX}} for more information.
The now deprecated tag
was considered too ambiguous, and it has been replaced by
= LaTeX commands =
LaTeX commands are case-sensitive, and take one of the following two formats:
- They start with a backslash
\
and then have a name consisting of letters only. Command names are terminated by a space, a number or any other "non-letter" character. - They consist of a backslash
\
and exactly one non-letter.
Some commands need an argument, which has to be given between curly braces {}
after the command name. Some commands support optional parameters, which are added after the command name in square brackets []
. The general syntax is:
\commandname[option1,option2,...]{argument1}{argument2}...
= Special characters =
The following symbols are reserved characters that either have a special meaning under LaTeX or are unavailable in all the fonts. If you enter them directly in your text, they will normally not render, but rather do things you did not intend.
# $ % ^ & _ { } ~ \
These characters can be entered by prefixing the escape character backslash \
or using special sequences:
\# \$ \% ^\wedge \& \_ \{ \} \sim \backslash
yielding:
{{block indent|1=
}}
The backslash character \
can not be entered by adding another backslash in front of it (\\
); this sequence is used for line breaking. For introducing a backslash in math mode, you can use \backslash
instead which gives .
The command \tilde
produces a tilde which is placed over the next letter. For example, \tilde{a}
gives . To produce just a tilde character ~, use \tilde{\ }
which gives , placing a ~ over an empty box. Alternatively \sim
produces , a large centred ~ which may be more appropriate in some situations.
The command \hat
produces a hat over the next character, for example \hat{o}
produces . For a stretchable version, use \widehat{abc}
giving . The wedge \wedge
is normally used as a mathematical operator . The sequence {}^\wedge
produces the best equivalent to the ASCII caret ^ character.
= Spaces =
"Whitespace" characters, such as blank or tab, are treated uniformly as "space" by LaTeX. Several consecutive whitespace characters are treated as one "space". See below for commands that produces spaces of different size.
= LaTeX environments =
Environments in LaTeX have a role that is quite similar to commands, but they usually have effect on a wider part of formula. Their syntax is:
\begin{environmentname}
text to be influenced
\end{environmentname}
Environments supported by Wikipedia include matrix, align, etc. See below.
= Rendering =
The font sizes and types are independent of browser settings or CSS. Font sizes and types will often deviate from what HTML renders. Vertical alignment with the surrounding text can also be a problem; a work-around is described in the "Alignment with normal text flow" section below. The CSS selector of the images is
Apart from function and operator names, as is customary in mathematics, variables and letters are in italics; digits are not. For other text, (like variable labels) to avoid being rendered in italics like variables, use
: .
LaTeX does not have full support for Unicode characters, and not all characters render. Most Latin characters with accents render correctly. However some do not, in particular those that include multiple diacritics (e.g. with Latin letters used in Vietnamese) or that cannot be precomposed into a single character (such as the uppercase Latin letter W with ring), or that use other diacritics (like the ogonek or the double grave accent, used in Central European languages like Polish, or the horn attached above some vowels in Vietnamese), or other modified letter forms (used in IPA notations, or African languages, or in medieval texts), some digram ligatures (like IJ in Dutch), or Latin letters borrowed from Greek, or small capitals, as well as superscripts and subscript letters. For example,
The normal way of entering quotation marks in text mode (two back ticks for the left and two apostrophes for the right), such as
== Force-rerendering of formulas ==
MediaWiki stores rendered formulas in a cache so that the images of those formulas do not need to be created each time the page is opened by a user. To force the rerendering of all formulas of a page, you must open it with the getter variables action=purge&mathpurge=true
. Imagine for example there is a wrong rendered formula in the article Integral. To force the re-rendering of this formula you need to open the URL
https://en.wikipedia.org/w/index.php?title=Integral&action=purge&mathpurge=true
Afterwards you need to bypass your browser cache so that the new created images of the formulas are actually downloaded.
Formatting using LaTeX
=Functions, symbols, special characters=
{| class="wikitable"
|-
!colspan="2"|
==Accents and diacritics==
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Standard numerical functions==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Bounds==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Projections==
|-
|
|
|-
!colspan="2"|
==Differentials and derivatives==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Letter-like symbols or constants==
|-
|
|
|-
|
|
|-
!colspan="2"|
==Modular arithmetic==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Radicals==
|-
|
|
|-
!colspan="2"|
==Operators==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Sets==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Relations==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Geometric==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Logic==
|-
|
|
|-
|
|
|-
|
don't use \or
which is now deprecated
|
|-
|
don't use \and
which is now deprecated
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Arrows==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Special==
|-
|
|
|-
|
|
|-
|
|
|-
!colspan="2"|
==Unsorted (new stuff)==
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|-
|
|
|}
For a little more semantics on these symbols, see this brief [https://web.archive.org/web/20160305074303/https://www.math.upenn.edu/tex-stuff/cookbook.pdf TeX Cookbook] or here [https://www3.nd.edu/~powers/ame.332/TeXcookbook.pdf TeX Cookbook].
=Larger expressions=
==Subscripts, superscripts, integrals==
class="wikitable" style="border-collapse:collapse" | ||
Feature | Syntax | How it looks rendered |
---|---|---|
Superscript
| | ||
Subscript
| | ||
rowspan="2"| Grouping
| | ||
rowspan="2"| Combining sub & super without and with horizontal separation
| | ||
Super super
| | ||
rowspan="2"| Preceding and/or additional sub & super
| | ||
rowspan="4"| Stacking
| | ||
rowspan="2"| Derivatives
| | ||
Derivative dots
| | ||
rowspan="3"| Underlines, overlines, vectors
| | ||
Arc (workaround)
| | ||
Arrows
| | ||
Overbraces
| | ||
Underbraces
| | ||
Sum
| | ||
Sum (force | | ||
Sum in a fraction (default | | ||
Sum in a fraction (force | | ||
Sum in a fraction (alternative limits style)
| | ||
Product
| | ||
Product (force | | ||
Coproduct
| | ||
Coproduct (force | | ||
Limit
| | ||
Limit (force | | ||
Integral
| | ||
Integral (alternative limits style)
| | ||
Integral (force | | ||
Integral (force | | ||
Double integral
| | ||
Triple integral
| | ||
Quadruple integral
| | ||
Line or path integral
| | ||
Closed line or path integral
| | ||
Intersections
| | ||
Unions
| |
= Fractions, matrices, multilines =
class="wikitable"
! Feature ! Syntax ! How it looks rendered |
Fractions
| | |
Small fractions (force | | |
Large (normal) fractions (force | | |
Large (nested) fractions
| | |
Cancellations in fractions
| | |
Binomial coefficients
| | |
Small binomial coefficients (force | | |
Large (normal) binomial coefficients (force | | |
rowspan="7" | Matrices
| -x & y \\ z & -v \end{matrix} | -x & y \\ z & -v \end{matrix} |
-x & y \\ z & -v \end{vmatrix} | -x & y \\ z & -v \end{vmatrix} |
-x & y \\ z & -v \end{Vmatrix} | -x & y \\ z & -v \end{Vmatrix} |
0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0 \end{bmatrix} | 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0 \end{bmatrix} |
x & y \\ z & v \end{Bmatrix} | x & y \\ z & v \end{Bmatrix} |
x & y \\ z & v \end{pmatrix} | x & y \\ z & v \end{pmatrix} |
\bigl( \begin{smallmatrix} a&b\\ c&d \end{smallmatrix} \bigr) | \bigl( \begin{smallmatrix} a&b\\ c&d \end{smallmatrix} \bigr) |
Case distinctions
| f(n) = \begin{cases} n/2, & \text{if }n\text{ is even} \\ 3n+1, & \text{if }n\text{ is odd} \end{cases} | \begin{cases} n/2, & \text{if }n\text{ is even} \\ 3n+1, & \text{if }n\text{ is odd} \end{cases} |
Simultaneous equations
| 3x + 5y + z \\ 7x - 2y + 4z \\ -6x + 3y + 2z \end{cases} | 3x + 5y + z \\ 7x - 2y + 4z \\ -6x + 3y + 2z \end{cases} |
rowspan="2" | Multiline equations
| \begin{align} f(x) & = (a+b)^2 \\ & = a^2+2ab+b^2 \\ \end{align} | \begin{align} f(x) & = (a+b)^2 \\ & = a^2+2ab+b^2 \\ \end{align} |
\begin{alignat}{2} f(x) & = (a-b)^2 \\ & = a^2-2ab+b^2 \\ \end{alignat} | \begin{alignat}{2} f(x) & = (a-b)^2 \\ & = a^2-2ab+b^2 \\ \end{alignat} |
rowspan="2" | Multiline equations with multiple alignments per row
| \begin{align} f(a,b) & = (a+b)^2 && = (a+b)(a+b) \\ & = a^2+ab+ba+b^2 && = a^2+2ab+b^2 \\ \end{align} | \begin{align} f(a,b) & = (a+b)^2 && = (a+b)(a+b) \\ & = a^2+ab+ba+b^2 && = a^2+2ab+b^2 \\ \end{align} |
\begin{alignat}{3} f(a,b) & = (a+b)^2 && = (a+b)(a+b) \\ & = a^2+ab+ba+b^2 && = a^2+2ab+b^2 \\ \end{alignat} | \begin{alignat}{3} f(a,b) & = (a+b)^2 && = (a+b)(a+b) \\ & = a^2+ab+ba+b^2 && = a^2+2ab+b^2 \\ \end{alignat} |
Multiline equations (must define number of columns used ({lcl})) (should not be used unless needed)
| \begin{array}{lcl} z & = & a \\ f(x,y,z) & = & x + y + z \end{array} | z & = & a \\ f(x,y,z) & = & x + y + z \end{array} |
Multiline equations (more)
| \begin{array}{lcr} z & = & a \\ f(x,y,z) & = & x + y + z \end{array} | z & = & a \\ f(x,y,z) & = & x + y + z \end{array} |
Multiline alignment using & to left align (top example) versus && to right align (bottom example) the last column
| F:\; && C(X) && \;\to\; & C(X) \\ && g && \;\mapsto\; & g^2 \end{alignat} F:\; && C(X) && \;\to\; && C(X) \\ && g && \;\mapsto\; && g^2 \end{alignat} | F:\; && C(X) && \;\to\; & C(X) \\ && g && \;\mapsto\; & g^2 \end{alignat} F:\; && C(X) && \;\to\; && C(X) \\ && g && \;\mapsto\; && g^2 \end{alignat} |
Breaking up a long expression so that it wraps when necessary (this sometimes requires workarounds for correct spacing)
| | The function is defined by |
Arrays
| \begin{array}{|c|c|c |
\hline
0 & 0 & 1 \\
0 & 1 & 1 \\
1 & 0 & 1 \\
1 & 1 & 0 \\
\end{array}
|
\begin{array}
c|c|c |
\hline
0 & 0 & 1 \\
0 & 1 & 1 \\
1 & 0 & 1 \\
1 & 1 & 0 \\
\end{array}
|}
= Parenthesizing big expressions, brackets, bars =
class="wikitable"
! Feature !! Syntax !! How it looks rendered |
Bad ✗
| | |
Good ✓
| | |
You can use various delimiters with \left and \right:
class="wikitable"
! Feature ! Syntax ! How it looks rendered |
Parentheses
| | |
Brackets
| | |
Braces
| | |
Angle brackets
| | |
Bars and double bars
| | |
Floor and ceiling functions:
| | |
Slashes and backslashes
| | |
Up, down, and up-down arrows
| | |
Delimiters can be mixed, as long as \left and \right match | | |
Use \left. and \right. if you do not want a delimiter to appear | | |
rowspan="7" | Size of the delimiters (add "l" or "r" to indicate the side for proper spacing)
| | |
| |
| |
| |
| |
| |
| |
=Display attribute=
The {{tag|math|o}} tag can take a display
attribute with possible values of inline
and block
.
==Inline==
If the value of the {{code|display}} attribute is {{code|inline}}, the contents will be rendered in inline mode: there will be no new paragraph for the equation and the operators will be rendered to consume only a small amount of vertical space.
The sum converges to 2.
The next line-width is not disturbed by large operators.
The code for the math example reads:
:
The quotation marks around inline
are optional and
is also valid.{{cite web|url=https://html.spec.whatwg.org/#attributes-2|title=HTML Living Standard|website=Web Hypertext Application Technology Working Group (WHATWG)}}
Technically, the command \textstyle will be added to the user input before the TeX command is passed to the renderer. The result will be displayed without further formatting by outputting the image or MathML element to the page.
==Block==
In block-style the equation is rendered in its own paragraph and the operators are rendered consuming less horizontal space. The equation is indented.
The sum converges to 2.
It was entered as
:
Technically, the command \displaystyle will be added to the user input (if the user input does not already contain the string \displaystyle or \align) before the TeX command is passed to the renderer. The result will be displayed in a new paragraph.
Therefore, the style of the MathImage is altered, i.e. the style attribute "display:block;margin:auto" is added.
For MathML it is ensured that display=inline is replaced by display block which produces a new paragraph
==Not specified==
If nothing is specified, the equation is rendered in the same display style as "block", but without using a new paragraph. If the equation does appear on a line by itself, it is not automatically indented.
The sum converges to 2.
The next line-width is disturbed by large operators.
Or:
The sum
converges to 2.
In both cases, the math is coded as:
:
= Equation numbering =
{{Shortcut|WP:DISPLAYTAG}}
The templates {{tl|NumBlk}} and {{tl|EquationRef}} can be used to number equations. The template {{tl|EquationNote}} can be used to refer to a numbered equation from surrounding text. For example, the following syntax:
:
produces the following result (note the equation number in the right margin):
{{NumBlk|:||{{EquationRef|1}}}}
Later on, the text can refer to this equation by its number using syntax like this:
:
The result looks like this:
: As seen in equation ({{EquationNote|1}}), example text...
The equation number produced by {{tl|EquationNote}} is a link that the user can click to go immediately to the cited equation.
=Alphabets and typefaces=
{{See also|Wikipedia:LaTeX symbols#Fonts}}
Texvc cannot render arbitrary Unicode characters. Those it can handle can be entered by the expressions below. For others, such as Cyrillic, they can be entered as Unicode or HTML entities in running text, but cannot be used in displayed formulas.
class="wikitable" |
colspan="2"| Greek alphabet |
---|
| |
| |
| |
| |
| |
| |
\varGamma \varDelta \varTheta \varLambda \varXi \varPi \varSigma \varPhi \varUpsilon \varOmega | \varGamma \varDelta \varTheta \varLambda \varXi \varPi \varSigma \varPhi \varUpsilon \varOmega |
\varepsilon \digamma \varkappa \varpi \varrho \varsigma \vartheta \varphi | \varepsilon \digamma \varkappa \varpi \varrho \varsigma \vartheta \varphi |
colspan="2"| Hebrew symbols |
| |
colspan="2"| Blackboard bold/scripts |
| |
| |
| |
colspan="2"| Boldface |
| |
| |
| |
| |
| |
| |
colspan="2"| Boldface (Greek) |
| |
| |
| |
| |
| |
| |
| |
| |
colspan="2"| Italics (default for Latin alphabet) |
| |
colspan="2"| Greek italics (default for lowercase Greek) |
| |
| |
| |
colspan="2"| Greek uppercase boldface italics |
| |
| |
colspan="2"| Roman typeface |
| |
| |
| |
| |
| |
| |
colspan="2"| Sans serif |
| |
| |
| |
| |
| |
| |
colspan="2"| Sans serif Greek (capital only) |
| |
| |
| |
colspan="2"| Calligraphy/script |
| |
| |
| |
| |
| |
| |
colspan="2"| Fraktur typeface |
| |
| |
| |
| |
| |
| |
colspan="2"| Small scriptstyle text |
| |
==Mixed text faces==
class="wikitable" |
Feature
! Syntax ! How it looks rendered |
---|
Italicised characters (spaces are ignored)
| | |
Non-italicised characters
| | |
Mixed italics (bad)
| | |
Mixed italics (good)
| | |
Mixed italics (alternative: ~ or "\ " forces a space)
| | |
=Color=
Equations can use color with the \color
command. For example,
class="wikitable" |
How it looks rendered
! Syntax ! Feature |
---|
| | |
| {{nowrap|1= | |
The \color
command colors all symbols to its right.
However, if the \color
command is enclosed in a pair of braces (e.g. {\color{Red}...}
) then no symbols outside of those braces are affected.
class="wikitable" |
How it looks rendered
! Syntax ! Feature |
---|
| | Colors red everything to the right of |
| | |
| | |
| {{nowrap|1= | The outermost braces in |
There are several alternate notations styles
class="wikitable" |
How it looks rendered
! Syntax ! Feature |
---|
| | works with both texvc and MathJax |
| {{nowrap|1= | works with both texvc and MathJax |
| | only works with MathJax |
Some color names are predeclared according to the following table, you can use them directly for the rendering of formulas (or for declaring the intended color of the page background).
{{Formula Supported Named Colors}}
Color should not be used as the only way to identify something, because it will become meaningless on black-and-white media or for color-blind people. See WP:Manual of Style (accessibility)#Color.
Latex does not have a command for setting the background color. The most effective way of setting a background color is by setting a CSS styling rule for a table cell:
class="wikitable" align="center"
| style="background-color: gray;" | | style="background-color: Goldenrod;" | |
Rendered as:
class="wikitable" align="center"
| style="background-color: gray;" | | style="background-color: Goldenrod;" | |
Custom colors can be defined using:
:
=Formatting issues=
==Spacing==
{{See also|Quad (typography)}}
TeX handles most spacing automatically, but you may sometimes want manual control.
class="wikitable"
! Feature !! Syntax !! How it looks rendered | ||
double quad space | ||
quad space | ||
text space | ||
text space in text mode | ||
large space | ||
medium space | {{n/a|Not supported}} | |
small space | ||
tiny space (use for multiplication of factors) | ||
tiny space (syntax space ignored) | ||
no space (use for multi-letter variables) | ||
small negative space | ||
zero-width space | {{n/a|Not supported}} |
Automatic spacing may be broken in very long expressions (because they produce an overfull hbox in TeX):
:
:
This can be remedied by putting a pair of braces { } around the whole expression:
:
:
When relational symbols such as are employed as ordinary symbols, for example in bra–ket notation, additional spacing may have to be avoided:
class="wikitable" |
Feature
! Syntax ! How it looks rendered |
---|
without special formatting
| | |
explicit opening and closing delimiter
| | |
with additional braces
| | |
arrow as ordinary symbol
| | |
=== Empty horizontal or vertical spacing ===
The phantom
commands create empty horizontal and/or vertical space the same height and/or width of the argument.
class="wikitable"
! Feature ! Syntax ! How it looks rendered |
Empty horizontal and vertical spacing
| | |
Empty vertical spacing
| | |
Empty horizontal spacing
| | |
==Alignment with normal text flow==
Because of the default CSS
an inline expression like should look good.
If you need to align it otherwise, use
and play with the
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.
=Unimplemented elements and workarounds=
The current Mathoid–MathJax backend has the following elements unimplemented (see also [https://docs.mathjax.org/en/v2.7-latest/tex.html?highlight=differences#differences MathJax's own description of differences]):
== Special integral operators ==
The following integral operators that are not supported by the default font of MathJax 2.7 are available
they have poor horizontal spacing, generate cropped SVG images unless used with other tall characters, and appear different from the usual integral symbol
:
cf. phab:T348587. However, they render fine when MathML is used.
==<syntaxhighlight lang="latex" inline>\oiint</syntaxhighlight> and <syntaxhighlight lang="latex" inline>\oiiint</syntaxhighlight>==
Elements which are not yet implemented are
These elements appear in many contexts:
:
class="toccolours collapsible collapsed" width="80%" style="text-align:left"
! |
:
:
:
: |
However, since no standardisation exists as yet, any workaround like this (which uses many
Note that
===<syntaxhighlight lang="latex" inline>\oiint</syntaxhighlight> and <syntaxhighlight lang="latex" inline>\oiiint</syntaxhighlight> as PNG images===
These symbols are available as PNG images which are also integrated into two templates, {{tl|oiint}} and {{tl|oiiint}}, which take care of the formatting around the symbols.
The templates have three parameters:
;preintegral: the text or formula immediately before the integral
;intsubscpt: the subscript below the integral
;integrand: the text or formula immediately after the integral
====Examples====
- Stokes' theorem:
{{oiint | intsubscpt= | integrand=}}
: {{Oiint|intsubscpt=|integrand=}}
- Ampère's law + correction:
{{oiint
| preintegral=
| intsubscpt =
| integrand =
}}
: {{oiint
| preintegral=
| intsubscpt =
| integrand =
}}
- Continuity of 4-momentum flux (in general relativity):{{Cite book|title=Gravitation|author1=J. A. Wheeler |author2=C. Misner |author3=K. S. Thorne | year=1973|publisher=W. H. Freeman & Co|edition=2nd|isbn=0-7167-0344-0}}
{{oiiint | preintegral= | intsubscpt= | integrand=
}}
{{Oiiint|preintegral=|intsubscpt=|integrand=
}}
===Oriented <syntaxhighlight lang="latex" inline>\oiint</syntaxhighlight> and <syntaxhighlight lang="latex" inline>\oiiint</syntaxhighlight> as PNG images===
Some variants of
==Arc notation <syntaxhighlight lang="latex" inline>\overarc</syntaxhighlight>==
For longer arcs, use {{tl|Overarc}}:
3.{{overarc|142857}}
==Triple dot <syntaxhighlight lang="latex" inline>\dddot</syntaxhighlight>==
.
==Starred operatorname <syntaxhighlight lang="latex" inline>\operatorname*</syntaxhighlight>==
The starred version of \operatorname
is not currently supported. A workaround for
is either
or
==Strikethrough==
Strikethrough like
:
==Formatting in \text ==
Formatting in {{code|\text}} is not supported. In other words, you can't use:
but have to use:
More specifically, in Mathoid's MathJax, no processing is done to the contents of {{code|\text}} at all. The texvcjs component blocks the use of macros, but another way this behavior leaks through is in the processing of quotation marks, where the Unicode version must be used instead of {{code|`}}:
:
It is currently impossible to get straight (typewriter) quotes in MathJax.
==Automatic line-breaking==
The current image-based implementation precludes automatic line-breaking of inline formulae after binary operators and "=" as seen in TeX. The only workarounds are to not write long formulae inline, or to split the formula into separate parts at each acceptable break point.
Readers wishing to enable automatic line-breaking can try to have the browser render the MathML itself or to use an alternate in-browser renderer.
=Syntax to avoid=
==Unicode characters==
{{tracked|T50032}}
Non-ASCII Unicode characters like {{pi}} work in MathML, but not in Mathoid (server-side MathJax in SVG/PNG mode, after validation by texvcjs). They should be avoided for maximum compatibility.
MathJax itself supports Unicode characters in \text{}
, but the texvcjs validator insists on blocking them (replicating old texvc behavior). A formal feature request and discussion is required to fix this.
===Invisible Unicode characters===
A rare but very frustrating cause of inexplicable syntax errors is invisible Unicode characters copied from some other source. For example, the Windows Calculator includes Unicode Bidirectional text control characters in its output: U+202D (left-to-right override) at the beginning and U+202C (pop directional formatting) at the end. These characters can be invisibly pasted into the Wikipedia editor, but will cause {{error|Failed to parse (syntax error):}} messages from the LaTeX renderer, despite the source appearing to be correct. It can usually be fixed by deleting and manually retyping the beginning and end of the pasted text.
==Deprecated syntax==
The texvc processor accepted some non-standard control sequences. These are now deprecated for Wikipedia use because the MathJax-based renderers do not support them. This is part of an effort to update the math engine.
See mw:Extension:Math/Roadmap for details. A bot User:Texvc2LaTeXBot will replace this syntax on the English Wikipedia.
{{aligned table|class=wikitable
|cols=3|row1header=y
|col1style=font-family:monospace;|style1.1=
|col2style=font-family:monospace;|style1.2=
|style6.2=font-style:oblique;
| texvc syntax
| Suggested replacement
| Comment
| $ | \$ | redefinition would involve changing the character code
| % | \% | redefinition would involve changing the character code
| \or | \lor | causes the teubner TeX package to fail{{cite web |url=https://tex.stackexchange.com/questions/418490 |title = Redefine \or form within a nested if statement? - TeX - LaTeX Stack Exchange}}
| \and | \land | causes normal align environment to fail
| \pagecolor | (remove) | not needed and not working anymore, done manually
| \part | \partial | acceptable if the document doesn't use sectioning with {{code|\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{o}
, which is ő.
| \bold | \mathbf |
| \Bbb | \mathbb |
}}
Chemistry
{{shortcut|WP:MATHCHEM}}
There are three ways to render chemical sum formulas as used in chemical equations:
- {{xtag|chem|p}} ({{xtag|ce|p}} is a deprecated alias for it)
- {{xtag|math|p|params=chem}}
- {{tlx|chem}} and {{tlx|chem2}}
{{xtag|chem|p|content=X}} is short for
(where X
is a chemical sum formula)
Technically, {{xtag|math|params=chem}} is a math
tag with the extension mhchem
enabled, according to the [http://docs.mathjax.org/en/latest/input/tex/extensions/mhchem.html MathJax documentation].
Wikipedia:Manual of Style/Chemistry advises avoiding the {{xtag|chem}} and {{xtag|math|params=chem}} markup methods when possible.
Note that the commands \cee
and \cf
are disabled, because they are marked as deprecated in the [http://www.ctan.org/pkg/mhchem mhchem LaTeX package documentation].
If the formula reaches a certain "complexity", spaces might be ignored (
might be rendered as if it were
with a positive charge). In that case, write
(and not
as was previously suggested). This will allow auto-cleaning of formulas once the bug is fixed and/or a newer version of mhchem
is available.
Please note that there are still [https://phabricator.wikimedia.org/T140217 major issues] with mhchem support in MediaWiki. Some issues can be solved by enabling the extension using {{xtag|math|params=chem}} and formatting individual items with \ce
. For example, {{markup2|m=
=Molecular and condensed formula=
class="wikitable" style="text-align:center"
! mhchem !! {{tlx|chem}} !! {{tlx|chem2}} !! Equivalent HTML |
style="vertical-align:bottom"|
{{markup | | | }} |class="mw-collapsible mw-collapsed"| {{automarkup |{{((}}chem{{!}}H{{!}}2{{!}}O{{))}} |{{((}}chem{{!}}Sb{{!}}2{{!}}O{{!}}3{{))}} |{{((}}chem{{!}}({{((}}chem{{!}}N{{!}}H{{!}}4{{))}}){{!}}2{{!}}S{{))}} }} |class="mw-collapsible mw-collapsed"| {{automarkup |{{((}}chem2{{!}}H2O{{))}} |{{((}}chem2{{!}}Sb2O3{{))}} |{{((}}chem2{{!}}(NH4)2S{{))}} }} |class="mw-collapsible mw-collapsed"| {{automarkup |H2O |Sb2O3 |(NH4)2S }} |
=Bonds=
class="wikitable" style="text-align:center"
! mhchem !! Equivalent {{tlx|chem}} and HTML !! {{tlx|chem2}} |
style="vertical-align:bottom"|
{{markup | | }} |class="mw-collapsible mw-collapsed"| {{markup | C6H5-CHO |{{chem|C|6|H|5}}-{{chem|C|H|O}} C6H5-CHO |A-B{{=}}C≡D |N/A }} |class="mw-collapsible mw-collapsed"| {{markup | |{{chem2|C6H5\sCHO}} | |{{chem2|1=A\sB=C≡D}} }} |
=Charges=
class="wikitable" style="text-align:center"
! mhchem !! {{tlx|chem}} !! {{tlx|chem2}} !! Equivalent HTML |
style="vertical-align:bottom"|
{{markup | | | | | | }} |class="mw-collapsible mw-collapsed"| {{automarkup |{{((}}chem{{!}}H{{!}}+{{))}} |{{((}}chem{{!}}N{{!}}O{{!}}3{{!}}-{{))}} |{{((}}chem{{!}}Cr{{!}}O{{!}}4{{!}}2-{{))}} |{{((}}chem{{!}}Ag{{!}}Cl{{!}}2{{!}}-{{))}} |{{((}}chem{{!}}[{{((}}chem{{!}}Ag{{!}}Cl{{!}}2{{))}}]{{!}}-{{))}} |{{((}}chem{{!}}Y{{!}}99+{{))}} }} |class="mw-collapsible mw-collapsed"| {{automarkup |{{((}}chem2{{!}}H+{{))}} |{{((}}chem2{{!}}NO3(-){{))}} |{{((}}chem2{{!}}CrO4(2-){{))}} |{{((}}chem2{{!}}AgCl2(-){{))}} |{{((}}chem2{{!}}[AgCl2](-){{))}} |{{((}}chem2{{!}}Y(99+){{))}} }} |class="mw-collapsible mw-collapsed"| {{automarkup |H+|NO3−|CrO42-|AgCl2−|[AgCl2]−|Y99+}} |
=Addition compounds and stoichiometric numbers=
class="wikitable" style="text-align:center"
! mhchem !! {{tlx|chem}} !! {{tlx|chem2}} |
style="vertical-align:middle"|
{{markup|style=vertical-align:middle | | | | }} |class="mw-collapsible mw-collapsed"| {{markup|style=vertical-align:middle | |{{chem|Mg|S|O|4}}·7{{chem|H|2|O}} | |{{chem|K|Cr|({{chem|S|O|4}})|2}}·12{{chem|H|2|O}} | |{{chem|Ca|S|O|4}}·½{{chem|H|2|O}} + 1½{{chem|H|2|O}} → {{chem|Ca|S|O|4}}·2{{chem|H|2|O}} | |{{frac|25|2}}{{chem|O|2}} + {{chem|C|8|H|18}} → 8{{chem|C|O|2}} + 9{{chem|H|2|O}} }} |class="mw-collapsible mw-collapsed"| {{markup|style=vertical-align:middle | | | | }} |
=Wiki linking=
class="wikitable" style="width:100%"
! {{tlx|chem}} |{{markupv|width=100%|style="vertical-align:middle" |m= |r=25 {{chem|link=oxygen|O|2}} + 2 {{chem|link=octane|C|8|H|18}} → 16 {{chem|link=Carbon dioxide|C|O|2}} + 18 {{chem|link=water|H|2|O}} }} |
{{tlx|chem2}}
|{{markupv|width=100%|style="vertical-align:middle" |m= |r={{chem2|25 O2 + 2 C8H18 -> 16 CO2 + 18 H2O}} }} |
---|
=(Italic) Math=
class="wikitable" style="width:100%"
! mhchem |{{markupv|width=100%|style="vertical-align:middle" |m= |r= }} |
{{tlx|chem}}
|{{markupv|width=100%|style="vertical-align:middle" |m= |r={{chem|C|x|H|y}} + z{{chem|O|2}} → x{{chem|C|O|2}} + {{sfrac|y|2}}{{chem|H|2|O}} }} |
---|
{{tlx|chem2}}
| {{markupv|width=100%|style="vertical-align:middle" |m= |r={{chem2|C_{x}H_{y} + z O2 -> x CO2}} + {{sfrac|y|2}} {{chem2| H2O}} }} |
=Oxidation states=
class="wikitable" style="text-align:center"
! mhchem |style="vertical-align:bottom"| {{markupv |m= |r= |
{{tlx|chem}} with {{tag|sup}}
|{{markupv |m= |r={{chem|Fe|II|Fe|III|2|O|4}} }} |
---|
{{tlx|chem2}}
|{{markupv |m= |r={{chem2|Fe^{II}Fe^{III}2O4}} }} |
=Greek characters=
class="wikitable" style="text-align:center;"
! mhchem !! Equivalent {{tlx|chem}} and HTML !! {{tlx|chem2}} |
style="vertical-align:center;"|
{{markup|style=vertical-align:center | | }} |class="mw-collapsible mw-collapsed"| {{markup|style=vertical-align:center | | [Fe(η5-C5H5)2] |[{{chem|Fe|(η5-{{chem|C|5|H|5}})|2}}] [Fe(η5-C5H5)2] }} |class="mw-collapsible mw-collapsed"| {{automarkup| |{{((}}chem2{{!}}μ\sCl{{))}} |{{((}}chem2{{!}}[Fe(\h^{5}\sC5H5)2]{{))}} }} |
=Isotopes=
class="wikitable" style="text-align:center;"
! mhchem !! Equivalent {{tlx|chem}} and HTML |
style="vertical-align:center;"|
{{markup|style=vertical-align:center | | }} |class="mw-collapsible mw-collapsed"| {{markup|style=vertical-align:center | | |
1}}n−|{{chem|0 |
1}}n−
}} |
=States=
Subscripting states is not an IUPAC recommendation.
class="wikitable" style="text-align:center"
! mhchem !! {{tlx|chem}} |
style="vertical-align:bottom;"|
{{markup | | | | }} |class="mw-collapsible mw-collapsed"| {{automarkup |{{((}}chem{{!}}H{{!}}2(aq){{))}} |{{((}}chem{{!}}C{{!}}O{{!}}3{{!}}2-{{))}}(aq) }} |
=[[Precipitate]] and gas formation=
class="wikitable" style="width:100%"
! mhchem |{{markupv|width=100%|style="vertical-align:middle" |m= |
{{tlx|chem}}
|{{markupv|width=100%|style="vertical-align:middle" |m= |r={{chem|Ba|2+}} + {{chem|S|O|4|2-}} → {{chem|Ba|S|O|4}}↓ }} |
---|
{{tlx|chem2}}
|{{markupv|width=100%|style="vertical-align:middle" |m= |r={{chem2|Ba(2+) + SO4(2-) -> BaSO4↓}} }} |
Equivalent HTML
|{{markupv|width=100%|style="vertical-align:middle" |m= |r=Ba2+ + SO42− → BaSO4↓ }} |
mhchem
|{{markupv|width=100%|style="vertical-align:middle" |m= |
=Reaction arrows=
{{markup|style=vertical-align:middle
|
|
|
|
|
|
|
|Unsupported{{efn|Expected result is File:Bi-dir reaction arrows.svg (longer {{code|\rightleftarrows}})}}
|
|
|
|
|
|
|
|
|
|
|
|
}}
== Comparison of arrow symbols ==
{{markup
|
|
|
|
|
|
|
}}
=Further examples using ordinary LaTeX tags=
\overbrace{\ce{2Fe3O4}}^{\text{magnetite}} + \ce{1/2 O2 ->}\ &{\color{Brown}\overbrace{\ce{3(\lambda{-}Fe2O3)}}^{\text{maghemite}}}\\
\underbrace{\ce{2Fe3O4}}_{\text{magnetite}} + \ce{1/2 O2 ->}\ &{\color{Red}\underbrace{\ce{3(\alpha{-}Fe2O3)}}_{\text{hematite}}}
\end{align}
:
\overbrace{\ce{2Fe3O4}}^{\text{magnetite}} + \ce{1/2 O2 ->}\ &{\color{Brown}\overbrace{\ce{3(\lambda{-}Fe2O3)}}^{\text{maghemite}}}\\
\underbrace{\ce{2Fe3O4}}_{\text{magnetite}} + \ce{1/2 O2 ->}\ &{\color{BrickRed}\underbrace{\ce{3(\alpha{-}Fe2O3)}}_{\text{hematite}}}
\end{align}
To align the equations or color them, use {{xtag|math chem}} and {{code|\ce}}.
{{-}}
Commutative diagrams
=1 step method =
\begin{array}{lcl}
& X & \overset{f}\rightarrow & Z & \\
& g \downarrow && \downarrow g'\\
& Y & \underset{f'}\rightarrow & W & \\
\end{array}
\begin{array}{lcl}
& X & \overset{f}\rightarrow & Z & \\
& g \downarrow && \downarrow g'\\
& Y & \underset{f'}\rightarrow & W & \\
\end{array}
=3 step method =
File:First isomorphism theorem (plain).svg
To make a commutative diagram, there are three steps:
- write the diagram in TeX
- convert to SVG
- upload the file to Wikimedia Commons
==Diagrams in TeX==
[http://www.tug.org/applications/Xy-pic/ Xy-pic]{{efn|Use the barr option for commutative diagrams, e.g., \usepackage[cmtip,all,barr]{xy}
.}} ([http://tex.loria.fr/graph-pack/doc-xypic/xyguide-html/xyguide-html.html online manual]) is the most powerful and general-purpose diagram package in TeX. Diagrams created using it can be found at Commons: Category:Xy-pic diagrams.
Simpler packages include:
- AMS's [http://www.dante.de/CTAN//help/Catalogue/entries/amscd.html amscd]
- Paul Taylor's [http://www.ctan.org/tex-archive/macros/generic/diagrams/taylor/ diagrams]
- François Borceux [http://www.ctan.org/tex-archive/help/Catalogue/entries/borceux.html Diagrams]
The following is a template for Xy-pic:
\documentclass[border=10pt]{standalone} % Crop to size, remove page numbers, leave margin
\usepackage[all]{xy} % Loading the XY-Pic package
\begin{document}
\SelectTips{eu}{} % Euler (shorter) arrowheads (tips)
$$
\xymatrix{
%%% Diagram goes here %%%
}
$$
\end{document}
Using postscript drivers may in some cases give smoother curves and will handle fonts differently:
==Convert to SVG==
Once you have produced your diagram in LaTeX (or TeX), you can convert it to an SVG file using the following sequence of commands:
pdflatex file.tex
pdf2svg file.pdf file.svg
The [http://pdfcrop.sourceforge.net pdfcrop] and [http://www.cityinthesky.co.uk/opensource/pdf2svg pdf2svg] utilities are needed for this procedure. You can alternatively use [http://www.pdftron.com/pdf2svg/ pdf2svg] from PDFTron for the last step.
If you do not have pdfTeX (which is unlikely) you can use the following commands to replace the first step (TeX → PDF):
latex file.tex
dvipdfm file.dvi
In general, you will not be able to get anywhere with diagrams without TeX and Ghostscript, and the
These programs are:
- a working TeX distribution, such as TeX Live
- Ghostscript
- pstoedit
- Inkscape
==Upload the file==
{{See also|commons:Commons:First steps/Upload form}}
{{See also|Help:Contents/Images and media}}
As the diagram is your own work, upload it to Wikimedia Commons, so that all projects (notably, all languages) can use it without having to copy it to their language's Wiki. (If you've previously uploaded a file to somewhere other than Commons, to Commons.)
; Check size: Before uploading, check that the default size of the image is neither too large nor too small by opening in an SVG application and viewing at default size (100% scaling), otherwise adjust the -y
option to dvips
.
; Name: Make sure the file has a meaningful name.
; Upload: Login to Wikimedia Commons, then [http://commons.wikimedia.org/w/index.php?title=Special:Upload&uselang=ownwork upload the file]; for the Summary, give a brief description.
Now go to the image page and add a description, including the source code, using this template:
{{Information
|description =
{{en|1= Description topic}}
|source = {{own}}, created as per:
:en:Help:Displaying a formula#Commutative diagrams;
source code below.
|date = The Creation Date, like 1999-12-31
|author = Your Real Name
|permission = {{self|PD-self (or other license)
|author = Your Real Name}}
}}
==TeX source==
% TeX source here
Category:Images with LaTeX source code
; Source code
:*Include the source code in the image page, in the {{mono|Source}} section of the
template, so that the diagram can be edited in future.
:*Include the complete .tex
file, not just the fragment, so future editors do not need to reconstruct a compilable file.
:*You may optionally make the source code section collapsible, using the
or
templates.
:*(Don't include it in the Summary section, which is just supposed to be a summary.)
; License
: The most common license for commutative diagrams is PD-self
; some use PD-ineligible
, especially for simple diagrams, or other licenses. Please do not use the [http://www.gnu.org/copyleft/fdl.html GFDL], as it requires the entire text of the GFDL to be attached to any document that uses the diagram.
; Description
: If possible, link to a Wikipedia page relevant to the diagram. (The 1=
is necessary if you use nest templates within the description, and harmless otherwise.)
; Category
: Include
, so that it appears in commons:Category:Commutative diagrams. There are also subcategories, which you may choose to use.
; Include image
: Now include the image on the original page via
. Use
to invert colors in dark mode.
==Examples==
A sample conforming diagram is commons:File:PSU-PU.svg.
Semantics and links
While links from formulas using LaTeX macros such as \href or \url or are currently not supported, one can link individual math expressions to Wikidata items to explain the meaning of individual terms of mathematical expressions. For example,
{{markupv
|r=
|m=
}}
links to [https://en.wikipedia.org/wiki/Special:MathWikibase?qid=Q35875 a special page that displays additional information on that formula].
To change the information shown on the special page, navigate to the Wikidata item linked at the bottom of the special page. Use the has part property to link parts of the equation to other Wikidata items with their respective Wikipedia articles. This is not limited to individual identifiers, but can also be used to link more complex terms.
A condensed version of that special page might be shown in the future as a popup: phab:T239357.
Examples of implemented TeX formulas
=Quadratic polynomial=
{{markupv
|r=
|m=
}}
=Quadratic formula=
{{markupv
|r=
|m=
}}
=Tall parentheses and fractions=
{{markupv
|r=
|m=
\frac{\left(3-x\right) \times 2}{3-x}
\right)
}}
{{markupv
|r=
|m=
}}
=Integrals=
{{markupv
|r=
|m=
= \int_a^x f(y)(x-y)\,dy
}}
{{markupv
|r=
|m=
}}
=Matrices and determinants=
{{markupv
|r=
|m=
}}
=Summation=
{{markupv
|r=
|m=
}}
{{markupv
|r=
|m=
}}
=Differential equation=
{{markupv
|r=
|m=
}}
=Complex numbers=
{{markupv
|r=
|m=
|(\bar{z})^n| = |z|^n,
\arg(z^n) = n \arg(z)
}}
=Limits=
{{markupv
|r=
|m=
}}
=Integral equation=
{{markupv
|r=
\frac{1}{4\pi^2\kappa^2} \int_0^\infty
\frac{\sin(\kappa R)}{\kappa R}
\frac{\partial}{\partial R}
\left [ R^2\frac{\partial D_n(R)}{\partial R} \right ] \,dR
|m=
\frac{1}{4\pi^2\kappa^2} \int_0^\infty
\frac{\sin(\kappa R)}{\kappa R}
\frac{\partial}{\partial R}
\left [ R^2\frac{\partial D_n(R)}{\partial R} \right ] \,dR
}}
=Example=
{{markupv
|r=
|m=
0.033C_n^2\kappa^{-11/3},\quad
\frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}
}}
=Continuation and cases=
{{markupv
|r=
\frac{1}{2} & x = 0 \\ 1 - x^2 & \text{otherwise}\end{cases}
|m=
\begin{cases}
1 & -1 \le x < 0 \\
\frac{1}{2} & x = 0 \\
1 - x^2 & \text{otherwise}
\end{cases}
}}
=Prefixed subscript=
{{markupv
|r=
|m=
= \sum_{n=0}^\infty
\frac{(a_1)_n\cdots(a_p)_n}{(c_1)_n\cdots(c_q)_n}
\frac{z^n}{n!}
}}
=Fraction and small fraction=
{{markupv
|r=
|m=
}}
=Area of a quadrilateral=
{{markupv
|r=
|m=
}}
=Volume of a sphere-stand=
{{markupv
|r=
|m=
}}
=Multiple equations=
The altered newline code \\[0.6ex]
below adds a vertical space between the two lines of length equal to times the height of a single 'x
' character.
{{markupv
|r=
u & = \tfrac{1}{\sqrt{2}}(x+y) \qquad & x &= \tfrac{1}{\sqrt{2}}(u+v) \\[0.6ex]
v & = \tfrac{1}{\sqrt{2}}(x-y) \qquad & y &= \tfrac{1}{\sqrt{2}}(u-v)
\end{align}
|m=
u & = \tfrac{1}{\sqrt{2}}(x+y) \qquad & x &= \tfrac{1}{\sqrt{2}}(u+v) \\[0.6ex]
v & = \tfrac{1}{\sqrt{2}}(x-y) \qquad & y &= \tfrac{1}{\sqrt{2}}(u-v)
\end{align}
}}
See also
- {{tl|Math}}
- MathJax{{snd}}Javascript library that converts LaTeX to MathML
- Typesetting of mathematical formulas
- Help:Score (a tag for tablatures, "sheet music") and Help:Musical symbols
- List of mathematical symbols
- WP:Rendering math
- blahtex: a LaTeX to MathML converter for Wikipedia
- commons:Category:Images which should use TeX
- Handwriting recognition{{snd}}another way to put formulas, in a visual manner
References
=Footnotes=
{{Notelist|30em}}
=Citations=
{{Reflist}}
External links
{{Wikibooks|LaTeX}}
- [https://phabricator.wikimedia.org/T45058 Task:Creating a visual VisualEditor plugin tool to add/edit maths blocks] in Wikimedia Phabricator
- [http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/ A LaTeX tutorial]
- [http://www.codecogs.com/latex/eqneditor.php LaTex online editor]
- {{Citation
|last= Doob
|first= Michael
|title= A Gentle Introduction to TeX: A Manual for Self-study
|url= http://www.ctan.org/tex-archive/info/gentle/gentle.pdf
|doi= |ref=none}}. A paper introducing TeX — see page 39 onwards for a good introduction to the maths side of things.
- {{Citation
|last= Oetiker
|first= Tobias
|last2= Partl
|first2= Hubert
|last3= Hyna
|first3= Irene
|last4= Schlegl
|first4= Elisabeth
|title= The Not So Short Introduction to LaTeX 2ε
|date= December 13, 2009
|edition= 4.27
|url= http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf
|doi= |ref=none}}. A paper introducing LaTeX — skip to page 49 for the math section. See page 63 for a complete reference list of symbols included in LaTeX and AMS-LaTeX.
- [http://ctan.org/tex-archive/info/symbols/comprehensive/symbols-letter.pdf The Comprehensive LaTeX Symbol List]—symbols not found here may be documented there.
- [http://mirrors.ctan.org/macros/latex/contrib/esint/esint-doc.pdf The esint package for closed double integrals]
- [http://www.ams.org/tex/amslatex.html AMS-LaTeX guide].
- {{cite web | title=Handwriting Recognition |publisher=Mathpix| url=https://mathpix.com/handwriting-recognition}} Optical character recognition of handwritten mathematical formulas into LaTeX and other formats, offering 10 free snips a month (registration required).
- cancel package [http://www.ctan.org/pkg/cancel homepage] and [http://mirrors.ctan.org/macros/latex/contrib/cancel/cancel.pdf PDF documentation]
- [http://us.metamath.org/symbols/symbols.html A set of public domain fixed-size math symbol bitmaps].
- [http://milde.users.sourceforge.net/LUCR/Math/unimathsymbols.html List of mathematical symbols with their Unicode characters and their LaTeX commands]
- MathML: A product of the W3C [http://www.w3.org/Math/ Math working group], is a low-level specification for describing mathematics as a basis for machine-to-machine communication
- [https://www.w3.org/MarkUp/html3/maths.html HTML Math and the
{{Help navigation}}
{{Wikipedia technical help|collapsed}}
{{MathematicalSymbolsNotationLanguage}}