Help:MathTestNative
This page aims to cover a wide range of mathematical expressions and was generated from the documentation of the English Wikipedia [1]. Please refer to phab:T346795 for further information and to Help:MathTest for a version of this page that uses the configured rendering mode.
This page forces rendering using the new native MathML mode.
Test-Tables
Functions, symbols, special characters
For a little more semantics on these symbols, see the brief TeX Cookbook.
Larger expressions
Subscripts, superscripts, integrals
Fractions, matrices, multilines
Parenthesizing big expressions, brackets, bars
Feature | Syntax | How it looks rendered |
---|---|---|
Bad | ( \frac{1}{2} )
|
|
Good | \left ( \frac{1}{2} \right )
|
You can use various delimiters with \left and \right:
Equation numbering
The templates {{NumBlk}}
and {{EquationRef}}
can be used to number equations. The template {{EquationNote}}
can be used to refer to a numbered equation from surrounding text. For example, the following syntax:
{{NumBlk|:|<math forcemathmode='native'>x^2 + y^2 + z^2 = 1 \,</math>|{{EquationRef|1}}}}
produces the following result (note the equation number in the right margin):
Later on, the text can refer to this equation by its number using syntax like this:
As seen in equation ({{EquationNote|1}}), blah blah blah...
The result looks like this:
- As seen in equation (Template:EquationNote), blah blah blah...
Note that the equation number produced by {{EquationNote}}
is a link that the user can click to go immediately to the cited equation.
Alphabets and typefaces
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.
Mixed text faces
Color
Equations can use color:
{\color{Blue}x^2}+{\color{YellowOrange}2x}-{\color{OliveGreen}1}
x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}
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.
Note that 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 Wikipedia:Manual of Style (accessibility).
Formatting issues
Spacing
Note that Template:TeX handles most spacing automatically, but you may sometimes want manual control.
Automatic spacing may be broken in very long expressions (because they produce an overfull hbox in Template:TeX):
This can be remedied by putting a pair of braces { } around the whole expression:
Alignment with normal text flow
Due to the default CSS
img.tex { vertical-align: middle; }
an inline expression like should look good.
If you need to align it otherwise, use style="vertical-align:-100%;">...
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.
Also note that if you rely on this workaround, if/when the rendering on the server gets fixed in future releases, as a result of this extra manual offset your formulae will suddenly be aligned incorrectly. So use it sparingly, if at all.
Centering
We introduce the new attribute display with the two options "inline" and "block".
Inline
If the the value of the display attribute is inline the render will render math in inline mode, i.e. there will be no new paragraph for the equation and the operators will be rendered consuming only little vertical space.
Example
The next line-width is not disturbed by large operators.
The code for the math example reads:
<math forcemathmode='native' display="inline">\sum_{i=0}^\infty 2^{-i}</math>
Technical implementation
Technically it will add 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 by outputting the image or MathMLelement to the page.
Remark
The convention https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style_(mathematics)#Using_HTML is really annoying. I'd prefer to use inline math for that, since it helps to differentiate between math and other elements.
Block
In block-style the equation is rendered in its own paragraph and the operator are rendered consuming less horizontal space.
Example
The equation is used in a joke about mathematicians entering a bar and ordering beer.
It was entered as
<math forcemathmode='native' display="block">\text{geometric series:}\quad \sum_{i=0}^\infty 2^{-i}=2 </math>
Technical implementation
Technically it will add the command \displaystyle will be added to the user input, if the user input does not 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
Discussion
Fréderic Wang would prefer that displaystyle is always added in depended of the fact if \displaystlye is already in the equation. He remarks that it has to be checked if that works if the equation starts with \begin.
Not specified
If nothing is specified the current behavior is preserved. That means all equation are rendered in display style but not using a new paragraph.
Example
The next line-width is disturbed by large operators.
The code for the math example reads:
<math forcemathmode='native'>\sum_{i=0}^\infty 2^{-i}</math>
The equation
is used in a joke about mathematicians entering a bar and ordering beer.
It was entered as
<math forcemathmode='native'>\text{geometric series:}\quad \sum_{i=0}^\infty 2^{-i}=2 </math>
Examples of implemented Template:TeX formulas
Quadratic polynomial
<math forcemathmode='native'>ax^2 + bx + c = 0</math>
Quadratic formula
<math forcemathmode='native'>x={-b\pm\sqrt{b^2-4ac} \over 2a}</math>
Tall parentheses and fractions
<math forcemathmode='native'>2 = \left(
\frac{\left(3-x\right) \times 2}{3-x}
\right)</math>
<math forcemathmode='native'>S_{\text{new}} = S_{\text{old}} - \frac{ \left( 5-T \right) ^2} {2}</math>
Integrals
<math forcemathmode='native'>\int_a^x \!\!\!\int_a^s f(y)\,dy\,ds
= \int_a^x f(y)(x-y)\,dy</math>
Matrices and determinants
<math forcemathmode='native'>\det(\mathsf{A}-\lambda\mathsf{I}) = 0</math>
Summation
<math forcemathmode='native'>\sum_{i=0}^{n-1} i</math>
<math forcemathmode='native'>\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}
{3^m\left(m\,3^n+n\,3^m\right)}</math>
Differential equation
<math forcemathmode='native'>u'' + p(x)u' + q(x)u=f(x),\quad x>a</math>
Complex numbers
<math forcemathmode='native'>|\bar{z}| = |z|,
|(\bar{z})^n| = |z|^n,
\arg(z^n) = n \arg(z)</math>
Limits
<math forcemathmode='native'>\lim_{z\rightarrow z_0} f(z)=f(z_0)</math>
Integral equation
<math forcemathmode='native'>\phi_n(\kappa) =
\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</math>
Example
<math forcemathmode='native'>\phi_n(\kappa) =
0.033C_n^2\kappa^{-11/3},\quad
\frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}</math>
Continuation and cases
<math forcemathmode='native'>
f(x) =
\begin{cases}
1 & -1 \le x < 0 \\
\frac{1}{2} & x = 0 \\
1 - x^2 & \text{otherwise}
\end{cases}
</math>
Prefixed subscript
<math forcemathmode='native'>{}_pF_q(a_1,\dots,a_p;c_1,\dots,c_q;z)
= \sum_{n=0}^\infty
\frac{(a_1)_n\cdots(a_p)_n}{(c_1)_n\cdots(c_q)_n}
\frac{z^n}{n!}</math>
Fraction and small fraction
<math forcemathmode='native'>\frac{a}{b}\ \tfrac{a}{b}</math>
Area of a quadrilateral
<math forcemathmode='native'>S=dD\,\sin\alpha\!</math>
Volume of a sphere-stand
<math forcemathmode='native'>V=\frac16\pi h\left[3\left(r_1^2+r_2^2\right)+h^2\right]</math>
Multiple equations
Test cases from parserTests
- pre-save transform: comment containing math
- BUG 1887: A
<math>
with a thumbnail- we don't render math in the parsertests by default, so math is not stripped and turns up as escaped <math> tags. - BUG 1887, part 2: A
<math>
with a thumbnail- math enabled - Math section safety when disabled
- BUG 26380: Add \widetilde support to match \widehat
- BUG 27324: Euro symbol for math
- BUG 27754: Archaic Greek letters for math (may require texlive-lang-greek)
- BUG 19547: Apostrophe / single quotes in math \text{...}
- BUG 6722: Spacing fix for functions in math HTML output:
- BUG 18912: Add \sen function for Spanish sin to math
- BUG 18912: \operatorname{sen} x gets wrong spacing in math:
- BUG 31442: Multiple math accents without braces fails to parse:
- BUG 31442: Math accents with math font fail to parse if braces not used:
- BUG 31824: Empty math tag returns uniq:
- BUG 31824: Empty math tag returns uniq: