This site is supported by donations to The OEIS Foundation.

Template:Math

From OeisWiki
(Redirected from JsMath)
Jump to: navigation, search

alt = This template is under construction...
This template is under construction.            

Please do not use this unfinished and/or still unreliable template.            


MS Edge chops the LaTeX PNG’s, whether we use the {{math}} template or the <math>...</math> tags.

NOTE: The {{math}} [experimental] OEIS Wiki utility template typesets [simple enough] mathematical expressions and/or their numerical results in either HTML+CSS or LaTeX, using MediaWiki templates (this template and mathematical formatting templates/mathematical function templates) without any JavaScript whatsoever [neither client-side nor server-side] (since the OEIS Wiki [MediaWiki] server currently supports neither client-side MathJax nor server-side MathJax) which avoids the “Flash Of Unstyled Content” issue that affects the client-side JavaScript based [client-side] MathJax.
(The Editorial Board might consider, or not, the installation of Extension:MathJax to the MediaWiki server in the future though.)

Currently, the OEIS Wiki server is configured to render mathematical expressions typeset in TeX (LaTeX) into raster (bitmap) images (usually PNG format, file extension .png) generated by Extension:Math installed on the MediaWiki server. Those raster images put an extra load on the MediaWiki server, take extra bandwith, slow down the page rendering, don't scale nicely from a small handheld display to a large monitor/projector display, as do vector images (e.g. SVG format, file extension .svg).

The raster images for inline math also don't usually align properly when used with LaTeX \textstyle (which we should be using if the font size of the rendered .png images matched with the font size of the surrounding text) or the \scriptstyle kludge (which we [unfortunately and inappropriately] have to resort using to get a closer match of font sizes, with the caveat that we don't get the proper spacing around binary operators and/or relations). The raster images for standalone math look great with LaTeX \displaystyle though. (The font size of \textstyle and \displaystyle are the same and should match the font size of the surrounding text as one observes in any mathematics book. The difference is, for example, in the use of subscript/superscript notation for text style large operators (e.g. sum, product, integral) instead of underscript/overscript notation for display style).

Usage

{{math|HTML+CSS markup (mathematical expression)|tex = LaTeX code (mathematical expression)|format}}

where format is among

  • $: LaTeX code (inline text style);
  • $$: LaTeX code (display style);
  • &: HTML+CSS markup (inline text style);
  • &&: HTML+CSS markup (display style).

Contents

Maintenance categories for the {{math}} template or the <math>...</math> tag

Category:Pages using the math template without HTML+CSS as first argument
Category:Pages using the math template without the tex argument
Category:Pages with math errors (lists pages with LaTeX syntax errors)
Category:Pages with math render errors (lists pages where a temporary error occurred in the mathematics LaTeX rendering process)

Enforcing (or not) HTML+CSS or LaTeX

Eventually, the OEIS administrators might decide to enforce LaTeX for inline [textstyle] math and/or standalone [displaystyle] math, to show PNG's or to support either server-side or client-side MathJax to get HTML+CSS or MathML or SVG's. Another possibility would be to let the user choose between the HTML+CSS obtained from the templates or LaTeX to be used by MathJax.

Enforcing (or not) HTML+CSS or LaTeX for inline [textstyle] math

To enforce (or not) HTML+CSS or LaTeX for inline [textstyle] math: {{math/textstyle}} with one of only 3 options: htm, tex or <blank>.

htm or tex to tell the {{math}} template how to render text style throughout OEIS Wiki, <blank> (empty string) to let {{math}} choose from & or $ argument.

NOTE: TO USE OPTIONS htm or tex ALL {{math|...|&}} AND {{math|...|$}} TEMPLATE CALLS THROUGHOUT OEIS WIKI MUST BE PROVIDED WITH HTML+CSS as {{{1}}} and LaTeX as {{{tex}}}!

Enforcing (or not) HTML+CSS or LaTeX for standalone [displaystyle] math

To enforce (or not) HTML+CSS or LaTeX for standalone [displaystyle] math: {{math/displaystyle}} with one of only 3 options: htm, tex or <blank>.

htm or tex to tell the {{math}} template how to render text style throughout OEIS Wiki, <blank> (empty string) to let {{math}} choose from && or $$ argument.

NOTE: TO USE OPTIONS htm or tex ALL {{math|...|&&}} AND {{math|...|$$}} TEMPLATE CALLS THROUGHOUT OEIS WIKI MUST BE PROVIDED WITH HTML+CSS as {{{1}}} and LaTeX as {{{tex}}}!

Baseline alignment with inline style

The following compares (for LaTeX rendered .png images and HTML+CSS) how good/bad is the baseline alignment with inline style:

  • the polynomials <math>\scriptstyle ax + b </math> and <math>\scriptstyle x^3 + x^2 + 1 </math> render as: the polynomials and (see how LaTeX uses vertical-align: middle; by default for the rendered images)
  • the polynomials <math style="vertical-align: baseline;">\scriptstyle ax + b </math> and <math style="vertical-align: baseline;">\scriptstyle x^3 + x^2 + 1 </math> render as: the polynomials and (using vertical-align: baseline; the baselines [sort of] align properly in this case; although vertical-align: middle; is what's needed if we have e.g. fractions)
  • the polynomials {{math| ''ax'' + ''b'' |&}} and {{math| ''x''{{^|3}} + ''x''{{^|2}} + 1 |&}} render as: the polynomials 
    ax + b
    and 
    x 3 + x 2 + 1
    (see how the baselines of the polynomials align properly with the surrounding text, at least when the tweaking of the {{math}} template is completed...).

LaTeX has the four style commands:

  • \displaystyle (display style is the default style; LaTeX uses Computer Modern 10 point font; big operators, e.g. sum, product and integral, use underscript/overscript notation; vertical-align: middle; used as default for the rendered .png images).
  • \textstyle (LaTeX uses Computer Modern 10 point font; big operators, e.g. sum, product and integral, use subscript/superscript notation; unfortunately this font is larger than the surrounding text font used in OEIS Wiki, and the baseline often doesn't align properly because of the use of vertical-align: middle; as default for the rendered .png images);
  • \scriptstyle (for subscripts or superscripts; LaTeX uses Computer Modern 7 point font; unfortunately, this is not that good a substitute for \textstyle since this font is somewhat smaller than the surrounding text font used in OEIS Wiki, and the baseline often doesn't align properly because of the use of vertical-align: middle; as default for the rendered .png images);
  • \scriptscriptstyle (for subscripts/superscripts of subscripts/superscripts of ..., i.e. second order and higher; LaTeX uses Computer Modern 5 point font);

Examples (since the font size of \textstyle is much larger than for the surrounding HTML text, while the font size of \scriptstyle almost matches, albeit a bit too small, we [unfortunately and inappropriately] have to resort to the use of \scriptstyle for inline formulas):

  • default style (\displaystyle): (...) where
    For block formulas, not for inline formulas, operators use underscripts and overscripts.
  • \displaystyle: (...) where
    For block formulas, not for inline formulas, operators use underscripts and overscripts.
  • \textstyle: (...) where and are (...); (...) we have since (...);
    For inline formulas, not for block formulas, operators use subscripts and superscripts, baselines should align but they don't because the PNG images have the vertical align: middle; (which works best for multiple row expressions, e.g. rational expressions, sums, products, and integrals) as default CSS attribute, instead of vertical align: baseline; (which works best for single row expressions, e.g. polynomial expressions); font size is larger than for the surrounding HTML text.
  • \scriptstyle: (...) where and are (...); (...) we have since (...);
    For first level of subscripts, superscripts, underscripts and overscripts.
  • \scriptscriptstyle: (...) where and are (...); (...) we have since (...);
    For second (and higher) level of subscripts, superscripts, underscripts and overscripts.

\textstyle vs \scriptstyle

Note: If we can figure out how to reduce the width of the math element by 75% (when we scale it down by 75%) we could use \textstyle instead of the \scriptstyle kludge for inline LaTeX with the {{math}} template.

The code

lorem ipsum <math>\textstyle ax + b, \text{ and } x^3 + x^2 + 1</math> lorem ipsum

yields the text style inline LaTeX

lorem ipsum lorem ipsum

The code

lorem ipsum <math height="75%" width="75%">\textstyle ax + b, \text{ and } x^3 + x^2 + 1</math> lorem ipsum

yields the text style inline LaTeX (can't resize this way!)

lorem ipsum lorem ipsum

The code

lorem ipsum <math style="height: 75%; width: 75%;">\textstyle ax + b, \text{ and } x^3 + x^2 + 1</math> lorem ipsum

yields the text style inline LaTeX (you get 75% of the window width this way, not what we want!)

lorem ipsum lorem ipsum

The code

lorem ipsum <span style="{{transform-scale|0.75|0.75}}"><math>\textstyle ax + b</math></span> lorem ipsum

yields the scaled down 75% text style inline LaTeX (unfortunately, we have to figure out how to reduce the width of the math element by 75%)

lorem ipsum lorem ipsum

The code

lorem ipsum <span style="margin: 0 -0.5em 0 -0.5em;<!-- trbl --> {{transform-scale|0.75|0.75}}"><math>\textstyle ax + b</math></span> lorem ipsum

yields the scaled down 75% text style inline LaTeX (unfortunately, we have to figure out how to reduce the width of the math element by 75%)

lorem ipsum lorem ipsum

The code

lorem ipsum <span style="margin: 0 -0.6em 0 -0.6em;<!-- trbl --> {{transform-scale|0.7|0.7}}"><math>\textstyle ax + b</math></span> lorem ipsum

yields the scaled down 70% text style inline LaTeX (unfortunately, we have to figure out how to reduce the width of the math element by 70%)

lorem ipsum lorem ipsum

The code

lorem ipsum <span style="margin: 0 -2em 0 -2em;<!-- trbl --> {{transform-scale|0.75|0.75}}"><math>\textstyle ax + b, \text{ and } x^3 + x^2 + 1</math></span> lorem ipsum

yields the scaled down 75% text style inline LaTeX (unfortunately, we have to figure out how to reduce the width of the math element by 75%)

lorem ipsum lorem ipsum

The code

lorem ipsum <span style="margin: 0 -2.4em 0 -2.4em;<!-- trbl --> {{transform-scale|0.7|0.7}}"><math>\textstyle ax + b, \text{ and } x^3 + x^2 + 1</math></span> lorem ipsum

yields the scaled down 70% text style inline LaTeX (unfortunately, we have to figure out how to reduce the width of the math element by 70%)

lorem ipsum lorem ipsum

The code

lorem ipsum <math>\scriptstyle ax + b, \text{ and } x^3 + x^2 + 1</math> lorem ipsum

yields the script style inline LaTeX (the \scriptstyle kludge doesn't give the spacings we need around binary operators and/or relations)

lorem ipsum lorem ipsum

Examples

The following examples are shown on a light grey background, i.e.     , to insure that the HTML+CSS and LaTeX renderings have a transparent background.

Note how the [single row] inline mathematical expressions have proper baseline alignment with the surrounding text (it should, once the tweaking is done...) when using & (inline style HTML+CSS markup) format, as opposed to $ (inline style LaTeX markup) format.

1.3688081078532235\ldots

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|1.3688081078532235{{...|ldots}}|&}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style HTML+CSS

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before 
1.3688081078532235
after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|1.3688081078532235{{...|ldots|tex}}|$}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style LaTeX

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : before {{math|1.3688081078532235{{...|ldots}}|&&}} after yields the display style HTML+CSS

1.3688081078532235

The code : before {{math| 1.3688081078532235{{...|ldots|tex}} |$$}} after yields the display style LaTeX

−1.3688081078532235\ldots

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|{{op|-}}1.3688081078532235{{...|ldots}}|&}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style HTML+CSS

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before 
 − 1.3688081078532235
after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|-1.3688081078532235{{...|ldots|tex}}|$}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style LaTeX

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : before {{math|{{op|-}}1.3688081078532235{{...|ldots}}|&&}} after yields the display style HTML+CSS

−1.3688081078532235

The code : before {{math|-1.3688081078532235{{...|ldots|tex}}|$$}} after yields the display style LaTeX

{ }_2 F_3

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|{{sub|2}}{{sp|1}}''F''{{sp|-1}}{{sub|3}}|&}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style HTML+CSS

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before 
2F3
after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|{ }_2 F_3|$}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style LaTeX

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : before {{math|{{sub|2}}{{sp|1}}''F''{{sp|-1}}{{sub|3}}|&&}} after yields the display style HTML+CSS

2F3

The code : before {{math|{ }_2 F_3|$$}} after yields the display style LaTeX

x^3 + 2x^2 + 10x - 20

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|''x''{{^|3}} {{op|+}} 2''x''{{^|2}} {{op|+}} 10''x'' {{op|-}} 20|&}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style HTML+CSS

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before 
x 3  +  2x 2  +  10x  −  20
after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|''x''{{^|3|tex}} {{op|+}} 2''x''{{^|2|tex}} {{op|+}} 10''x'' {{op|-}} 20|$}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style LaTeX

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : {{math|''x''{{^|3}} {{op|+}} 2''x''{{^|2}} {{op|+}} 10''x'' {{op|-}} 20|&&}} yields the display style HTML+CSS

x 3 + 2x 2 + 10x − 20

The code : {{math|''x''{{^|3|tex}} {{op|+}} 2''x''{{^|2|tex}} {{op|+}} 10''x'' {{op|-}} 20|$$}} yields the display style LaTeX

1 + \frac{22}{60} + \frac{7}{60^2} + \frac{42}{60^3} + \frac{33}{60^4} + \frac{4}{60^5} + \frac{40}{60^6}

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|1 + {{tfrac|22|60}} + {{tfrac|7|60{{^|2}}}} + {{tfrac|42|60{{^|3}}}} + {{tfrac|33|60{{^|4}}}} + {{tfrac|4|60{{^|5}}}} + {{tfrac|40|60{{^|6}}}}|&}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style HTML+CSS

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before 
1 +
22
60
+
7
60 2
+
42
60 3
+
33
60 4
+
4
60 5
+
40
60 6
after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 


The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|1 + {{frac|22|60|tex}} + {{frac|7|60{{^|2|tex}}|tex}} + {{frac|42|60{{^|3|tex}}|tex}} + {{frac|33|60{{^|4|tex}}|tex}} + {{frac|4|60{{^|5|tex}}|tex}} + {{frac|40|60{{^|6|tex}}|tex}}|$}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style LaTeX

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 


The code : {{math|1 + {{frac|22|60}} + {{frac|7|60{{^|2}}}} + {{frac|42|60{{^|3}}}} + {{frac|33|60{{^|4}}}} + {{frac|4|60{{^|5}}}} + {{frac|40|60{{^|6}}}}|&&}} yields the display style HTML+CSS

1 +
22
60
+
7
60 2
+
42
60 3
+
33
60 4
+
4
60 5
+
40
60 6

The code : {{math|1 + {{frac|22|60|tex}} + {{frac|7|60{{^|2|tex}}|tex}} + {{frac|42|60{{^|3|tex}}|tex}} + {{frac|33|60{{^|4|tex}}|tex}} + {{frac|4|60{{^|5|tex}}|tex}} + {{frac|40|60{{^|6|tex}}|tex}}|$$}} yields the display style LaTeX

\sqrt[7]{2}

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|{{root|2|7}}|&}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style HTML+CSS

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before 
7  2
after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : {{repeat|2|{{repeat|5|yadda{{nbsp}}}}{{nl}}}}before {{math|{{root|2|7|tex}}|$}} after{{repeat|2|{{nl}}{{repeat|5|yadda{{nbsp}}}}}} yields the text style LaTeX

yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 
before after
yadda yadda yadda yadda yadda 
yadda yadda yadda yadda yadda 

The code : {{math|{{root|2|7}}|&&}} yields the display style HTML+CSS

7  2

The code : {{math|{{root|2|7|tex}}|$$}} yields the display style LaTeX

Value of \sqrt[7]{2}

The code : before {{math|{{root|2|7|#}}{{...|ldots}}|&}} after yields the text style HTML+CSS

before 
1.1040895136738
after

The code : before {{math|{{root|2|7|#}}{{...|ldots|tex}}|$}} after yields the text style LaTeX

before after

The code : {{math|{{root|2|7|#}}{{...|ldots}}|&&}} yields the display style HTML+CSS

1.1040895136738

The code : {{math|{{root|2|7|#}}{{...|ldots|tex}}|$$}} yields the display style LaTeX

\sqrt[7]{2} = value of \sqrt[7]{2}

The code : before {{math|{{root|2|7}} {{=}} {{root|2|7|#}}{{...|ldots}}|&}} after yields the text style HTML+CSS

before 
7  2
= 1.1040895136738
after

The code : before {{math|{{root|2|7|tex}} {{=}} {{root|2|7|#}}{{...|ldots|tex}}|$}} after yields the text style LaTeX

before after

The code : {{math|{{root|2|7}} {{=}} {{root|2|7|#}}{{...|ldots}}|&&}} yields the display style HTML+CSS

7  2
= 1.1040895136738

The code : {{math|{{root|2|7|tex}} {{=}} {{root|2|7|#}}{{...|ldots|tex}}|$$}} yields the display style LaTeX

(x^2 + 1)(y^3 - 1)^2

The code : before {{math|({{sp|1}}''x''{{^|2}} {{op|+}} 1){{sp|1}}({{sp|2}}''y''{{^|3}} {{op|-}} 1){{^|2}}|&}} after yields the text style HTML+CSS

before 
( x 2  +  1) (  y 3  −  1) 2
after

The code : before {{math|(''x''{{^|2|tex}} {{op|+}} 1) (''y''{{^|3|tex}} {{op|-}} 1){{^|2|tex}}|$}} after yields the text style LaTeX

before after

The code : {{math|({{sp|1}}''x''{{^|2}} {{op|+}} 1){{sp|1}}({{sp|2}}''y''{{^|3}} {{op|-}} 1){{^|2}}|&&}} yields the display style HTML+CSS

( x 2 + 1) (  y 3 − 1) 2

The code : {{math|(''x''{{^|2|tex}} {{op|+}} 1) (''y''{{^|3|tex}} {{op|-}} 1){{^|2|tex}}|$$}} yields the display style LaTeX

(x - h)^2 / a^2 - (y - k)^2 / b^2 = 1

The code : before {{math|{{frac|({{sp|1}}''x'' {{op|-}} ''h''{{sp|1}}){{^|2}}|''a''{{^|2}}}} {{op|-}} {{frac|({{sp|2}}''y'' {{op|-}} ''k''{{sp|1}}){{^|2}}|''b''{{^|2}}}} {{=}} 1|&}} after yields the text style HTML+CSS

before 
( x  −  h ) 2
a 2
 − 
(  y  −  k ) 2
b 2
= 1
after

The code : before {{math|{{frac|(''x'' {{op|-}} ''h''){{^|2|tex}}|''a''{{^|2|tex}}|tex}} {{op|-}} {{frac|(''y'' {{op|-}} ''k''){{^|2|tex}}|''b''{{^|2|tex}}|tex}} {{=}} 1|$}} after yields the text style LaTeX

before after

The code : {{math|{{frac|({{sp|1}}''x'' {{op|-}} ''h''{{sp|1}}){{^|2}}|''a''{{^|2}}}} {{op|-}} {{frac|({{sp|2}}''y'' {{op|-}} ''k''{{sp|1}}){{^|2}}|''b''{{^|2}}}} {{=}} 1|&&}} yields the display style HTML+CSS

( xh ) 2
a 2
(  yk ) 2
b 2
= 1

The code : {{math|{{frac|(''x'' {{op|-}} ''h''){{^|2|tex}}|''a''{{^|2|tex}}|tex}} {{op|-}} {{frac|(''y'' {{op|-}} ''k''){{^|2|tex}}|''b''{{^|2|tex}}|tex}} {{=}} 1|$$}} yields the display style LaTeX

\frac{x^2 + 1}{y^3 - 1}

The code : before {{math|{{frac|''x''{{^|2}} {{op|+}} 1|''y''{{^|3}} {{op|-}} 1|htm}}|&}} after yields the text style HTML+CSS

before 
x 2  +  1
y 3  −  1
after

The code : before {{math|{{frac|''x''{{^|2|tex}} {{op|+}} 1|''y''{{^|3|tex}} {{op|-}} 1|tex}}|$}} after yields the text style LaTeX

before after

The code : {{math|{{frac|''x''{{^|2}} {{op|+}} 1|''y''{{^|3}} {{op|-}} 1|HTM}}|&&}} yields the display style HTML+CSS

x 2 + 1
y 3 − 1

The code : {{math|{{frac|''x''{{^|2|tex}} {{op|+}} 1|''y''{{^|3|tex}} {{op|-}} 1|tex}}|$$}} yields the display style LaTeX

\frac{x^2 + xy + 1}{y^3 - 1}

The code : before {{math|{{frac|''x''{{^|2}} {{op|+}} ''xy'' {{op|+}} 1|''y''{{^|3}} {{op|-}} 1}}|&}} after yields the text style HTML+CSS

before 
x 2  +  xy  +  1
y 3  −  1
after

The code : before {{math|{{frac|''x''{{^|2|tex}} {{op|+}} ''xy'' {{op|+}} 1|''y''{{^|3|tex}} {{op|-}} 1|tex}}|$}} after yields the text style LaTeX

before after

The code : {{math|{{frac|''x''{{^|2}} {{op|+}} ''xy'' {{op|+}} 1|''y''{{^|3}} {{op|-}} 1|HTM}}|&&}} yields the display style HTML+CSS

x 2 + xy + 1
y 3 − 1

The code : {{math|{{frac|''x''{{^|2|tex}} {{op|+}} ''xy'' {{op|+}} 1|''y''{{^|3|tex}} {{op|-}} 1|tex}}|$$}} yields the display style LaTeX

\frac{x^2 + \sqrt{xy} + 1}{y^3 - 1}

The code : before {{math|{{frac|''x''{{^|2}} {{op|+}} {{sqrt|''xy''}} {{op|+}} 1|''y''{{^|3}} {{op|-}} 1}}|&}} after yields the text style HTML+CSS

before 
x 2  + 
2  xy
 +  1
y 3  −  1
after

The code : before {{math|{{frac|''x''{{^|2|tex}} {{op|+}} {{sqrt|''xy''|tex}} {{op|+}} 1|''y''{{^|3|tex}} {{op|-}} 1|tex}}|$}} after yields the text style LaTeX

before after

The code : {{math|{{frac|''x''{{^|2}} {{op|+}} {{sqrt|''xy''}} {{op|+}} 1|''y''{{^|3}} {{op|-}} 1|HTM}}|&&}} yields the display style HTML+CSS

x 2 +
2  xy
+ 1
y 3 − 1

The code : {{math|{{frac|''x''{{^|2|tex}} {{op|+}} {{sqrt|''xy''|tex}} {{op|+}} 1|''y''{{^|3|tex}} {{op|-}} 1|tex}}|$$}} yields the display style LaTeX

\frac{x^2 + \sqrt{\tfrac{x - 1}{y}} + 1}{y^3 - 1}

The code : before {{math|{{frac|''x''{{^|2}} {{op|+}} {{sqrt|{{tfrac|''x'' {{op|-}} 1|''y''}}|HTM}} {{op|+}} 1|''y''{{^|3}} {{op|-}} 1}}|&}} after yields the text style HTML+CSS

before 
x 2  + 
2  
x  −  1
y
 +  1
y 3  −  1
after

The code : before {{math|{{frac|''x''{{^|2|tex}} + {{sqrt|{{tfrac|''x'' - 1|''y''|tex}}|tex}} + 1|''y''{{^|3|tex}} - 1|tex}}|$}} after yields the text style LaTeX

before after

The code : {{math|{{frac|''x''{{^|2}} {{op|+}} {{sqrt|{{tfrac|''x'' {{op|-}} 1|''y''}}|HTM}} {{op|+}} 1|''y''{{^|3}} {{op|-}} 1|HTM}}|&&}} yields the display style HTML+CSS

x 2 +
2  
x − 1
y
+ 1
y 3 − 1

The code : {{math|{{frac|''x''{{^|2|tex}} + {{sqrt|{{tfrac|''x'' - 1|''y''|tex}}|tex}} + 1|''y''{{^|3|tex}} - 1|tex}}|$$}} yields the display style LaTeX

\sqrt[31]{x^2 - \left( \tfrac{x + 1}{z - 1} \right) + 1}

The code : before {{math|{{root|''x''{{^|2}} {{op|-}} {{paren|l}}{{tfrac|''x'' {{op|+}} 1|''z'' {{op|-}} 1}}{{paren|r}} {{op|+}} 1|31|HTM}}|&}} after yields the text style HTML+CSS

before 
31  x 2  − 
(
x  +  1
z  −  1
)
 +  1 
after

The code : before {{math|{{root|''x''{{^|2|tex}} {{op|-}} {{paren|l|tex}}{{tfrac|''x'' {{op|+}} 1|''z'' {{op|-}} 1|tex}}{{paren|r|tex}} {{op|+}} 1|31|TEX}}|$}} after yields the text style LaTeX

before after

The code : {{math|{{root|''x''{{^|2}} {{op|-}} {{paren|l}}{{tfrac|''x'' {{op|+}} 1|''z'' {{op|-}} 1}}{{paren|r}} {{op|+}} 1|31|HTM}}|&&}} yields the display style HTML+CSS

31  x 2
(
x + 1
z − 1
)
+ 1 

The code : {{math|{{root|''x''{{^|2|tex}} {{op|-}} {{paren|l|tex}}{{tfrac|''x'' {{op|+}} 1|''z'' {{op|-}} 1|tex}}{{paren|r|tex}} {{op|+}} 1|31|TEX}}|$$}} yields the display style LaTeX

Examples with boxes

The code

: <table style="background: white; border: 1px solid black; padding: 0px;"><tr><td>{{math|{{frac|''x''{{^|2}} {{op|+}} {{sqrt|''xy''}} {{op|+}} 1|''y''{{^|3}} {{op|-}} 1|HTM}}|&&}}</td></tr></table>

yields the display style HTML+CSS

x 2 +
2  xy
+ 1
y 3 − 1

The code

: <table style="background: white; border: 1px solid black; padding: 0px;"><tr><td>{{math|{{frac|''x''{{^|2|tex}} {{op|+}} {{sqrt|''xy''|tex}} {{op|+}} 1|''y''{{^|3|tex}} {{op|-}} 1|tex}}|$$}}</td></tr></table>

yields the display style LaTeX (transparent background LaTeX within HTML+CSS table)

Examples with color

The code

: before <table style="display: inline-table; vertical-align: middle; background: yellow;"><tr><td>{{math|<div style{{=}}"color: red;">{{frac|({{sp|1}}''x'' {{op|-}} ''h''{{sp|1}}){{^|2}}|''a''{{^|2}}}} {{op|-}} {{frac|({{sp|2}}''y'' {{op|-}} ''k''{{sp|1}}){{^|2}}|''b''{{^|2}}}} {{=}} 1</div>|&}}</td></tr></table> after

yields the text style HTML+CSS

before
( x  −  h ) 2
a 2
 − 
(  y  −  k ) 2
b 2
= 1
after

The code

: before <table style="display: inline-table; vertical-align: middle; background: yellow;"><tr><td>{{math|{\color{red} {{frac|(''x'' {{op|-}} ''h''){{^|2|tex}}|''a''{{^|2|tex}}|tex}} {{op|-}} {{frac|(''y'' {{op|-}} ''k''){{^|2|tex}}|''b''{{^|2|tex}}|tex}} {{=}} 1 }|$}}</td></tr></table> after

yields the text style LaTeX (transparent background LaTeX within HTML+CSS table)

before
after

The code

: <table style="background: yellow;"><tr><td>{{math|<div style{{=}}"color: red;">{{frac|({{sp|1}}''x'' {{op|-}} ''h''{{sp|1}}){{^|2}}|''a''{{^|2}}}} {{op|-}} {{frac|({{sp|2}}''y'' {{op|-}} ''k''{{sp|1}}){{^|2}}|''b''{{^|2}}}} {{=}} 1</div>|&&}}</td></tr></table>

yields the display style HTML+CSS

( xh ) 2
a 2
(  yk ) 2
b 2
= 1

The code

: <table style="background: yellow;"><tr><td>{{math|{\color{red} {{frac|(''x'' {{op|-}} ''h''){{^|2|tex}}|''a''{{^|2|tex}}|tex}} {{op|-}} {{frac|(''y'' {{op|-}} ''k''){{^|2|tex}}|''b''{{^|2|tex}}|tex}} {{=}} 1 }|$$}}</td></tr></table>

yields the display style LaTeX (transparent background LaTeX within HTML+CSS table)

Examples with wiki links

Bekenstein–Hawking equation for the entropy of a black hole.

The code : before {{math|{{Wikipedia|Bekenstein-Hawking entropy|''S''{{sub|BH}}}} {{=}} {{frac|{{Wikipedia|Boltzmann's constant|''k''}}{{sp|1}}{{Wikipedia|Speed of light|''c''}}{{^|3}}|4{{sp|1}}{{Wikipedia|Reduced Planck constant|''{{sym|hbar}}''}}{{sp|1}}''{{Wikipedia|Gravitational constant|G}}''}} {{abbr|Area of event horizon|''A''}}|tex = S_{\rm BH} {{=}} \frac{k c^3}{4 \hbar G} A|&}} after yields the text style HTML+CSS

before
SBH =
kc 3
4 ħG
A
after

The code : before {{math|S_{\rm BH} {{=}} \frac{k c^3}{4 \hbar G} A|$}} after yields the text style LaTeX (unfortunately, no links... unless we can overlay an invisible table with invisible text with links...)

before after

The code : {{math|{{Wikipedia|Bekenstein-Hawking entropy|''S''{{sub|BH}}}} {{=}} {{frac|{{Wikipedia|Boltzmann's constant|''k''}}{{sp|1}}{{Wikipedia|Speed of light|''c''}}{{^|3}}|4{{sp|1}}{{Wikipedia|Reduced Planck constant|''{{sym|hbar}}''}}{{sp|1}}''{{Wikipedia|Gravitational constant|G}}''}} {{abbr|Area of event horizon|''A''}}|tex = S_{\rm BH} {{=}} \frac{k c^3}{4 \hbar G} A|&&}} yields the display style HTML+CSS

SBH =
kc 3
4 ħG
A

The code : {{math|S_{\rm BH} {{=}} \frac{k c^3}{4 \hbar G} A|$$}} yields the display style LaTeX (unfortunately, no links... unless we can overlay an invisible table with invisible text with links...)

More examples

For more examples, see {{math/tests}}.


For examples of the following:

  • arithmetic operators: see {{op|+}} and {{op|-}}
  • exponents: see {{^}}
  • matrices (raw, parenthesized, bracketed, determinant): see {{matrix}}


  • math environments (e.g. align, cases): see {{begin}} and {{end}}
    • "alignment mark": see {{&}}
    • "aligning equal sign": see {{&=}}
    • "aligning decimal point": see {{&.}}
    • "row separator": see {{\\}}
  • align environment: see {{align}}
  • cases environment: see {{cases}}

Tests

10,000 character limit for template arguments

Tests pertaining to: “Error: String exceeds 10,000 character limit.”

Trying to determine whether the following count:

  • comments (do I need to wrap comments within <noinclude>...</noinclude> in all mathematical typesetting templates?)
  • spaces and newlines (I use a lot of spaces to indent the code to make it readable: in Wikipedia the code is often collapsed in one big lump with minimal use of spaces, which I'm afraid means that spaces probably count, even though browsers treat consecutive spaces and/or newlines as a single space when rendering HTML!)

The code (each group of ten lines with comments has 1000 = 10 x 100 chars, not including new line characters)

{{indent}}{{math|
0000000000          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

1111111111          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

2222222222          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

3333333333          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

4444444444          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

5555555555          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

6666666666          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

7777777777          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

8888888888          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->

9999999999          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
<!-- 0 -->          <!-- 0 -->          <!-- 0 --><!-- 0 -->          <!-- 0 -->          <!-- 0 -->
|&&}}

yields

     
0000000000

1111111111

2222222222

3333333333

4444444444

5555555555

6666666666

7777777777

8888888888

9999999999

Alternatives

MathJax

Main article page: MathJax

MathJax[1] is an open-source JavaScript display engine for mathematics which takes either MathML, LaTeX or ASCIIMathML[2] as input to get either HTML+CSS, MathML or SVG as output, that works in all modern browsers (with JavaScript enabled, that is). (It is the successor of jsMath.)

Examples with MathJax

The Lorenz equations:

[ 
begin{matrix}
dot{x} & = & sigma(y-x) \
dot{y} & = & rho x - y - xz \
dot{z} & = & -beta z + xy
end{matrix} 
]

The Cauchy-Schwarz inequality:

[ left( sum_{k=1}^n a_k b_k right)^2 leq left( sum_{k=1}^n a_k^2 right) left( sum_{k=1}^n b_k^2 right) ]

A cross product formula:

[
mathbf{V}_1 times mathbf{V}_2 =  

begin{vmatrix}
mathbf{i} & mathbf{j} & mathbf{k} \
frac{partial X}{partial u} &  frac{partial Y}{partial u} & 0 \               
frac{partial X}{partial v} &  frac{partial Y}{partial v} & 0
end{vmatrix} 
]

Probability of getting (k) heads when flipping (n) coins:

[ P(E) = {n choose k} p^k (1-p)^{ n-k} ]

An identity of Ramanujan:

[ 
frac{1}{(sqrt{phi sqrt{5}}-phi) e^{frac25 pi}} =
1 + frac{e^{-2 pi}} {1 + frac{e^{-4 pi}} {1 + frac{e^{-6 pi}} {1+frac{e^{-8pi}} {1+ldots} } } } 
]

STIX fonts

MathJax uses STIX fonts, which are [scalable] Web fonts. (Web fonts allow Web designers to use fonts that are not installed on the viewer's computer.)

jsMath

Main article page: jsMath

jsMath.js is an Ajax-based math rendering system developed by Davide Cervone in 2004. (It has been superseded by MathJax, its successor.)

Examples with jsMath

Using the "jsMath HTML" option in

http://planetmath.org

the mathematical formulae are rendered with jsMath.js.

Note that in the examples below, some LaTeX has already been converted into HTML character entities, e.g. &lt; instead of < and &amp; instead of &, since the contents of an HTML element cannot be < or & because they are respectively the start of a closing HTML tag and the start of an HTML entity.

Inline display examples:


<span class="math">$D$</span>
<span class="math">$X$</span>
<span class="math">$x \in X$</span>
<span class="math">$y \in D$</span>
<span class="math">$d(x,y) &lt; \varepsilon$</span>
<span class="math">$\mathbb{Q}$</span>
<span class="math">$\mathbb{R} \setminus \mathbb{Q}$</span>
<span class="math">$\aleph_0$</span>
<span class="math">$d(X)$</span>
<span class="math">$|X| \le 2^{2^{d(X)}}$</span>

Block display examples:


<div class="math">
\int^1_\kappa \left[ \bigl( 1 - w^2 \bigr) \bigl( \kappa^2 - w^2 \bigr) \right]^{-1/2} dw =
\frac{4}{\left( 1 + \sqrt{\kappa} \, \right)^2} K \left( \left( \frac{1 - \sqrt{\kappa}}{1 + \sqrt{\kappa}} \right)^{\!\!2} \right)
</div>

<div class="math">
\mathop{\rm grd} \phi(z) = \left( a + \frac{2d}{\pi} \right) v_\infty \, \overline{f'(z)} =
v_\infty \left[ \pi a + \frac{2d}{\pi a + 2dw^{-1/2}(w-1)^{1/2}} \right]^-
</div>

<div class="math">
- \sum^n_{m=1} \left( \, \sum^\infty_{k=1} \frac{ h^{k-1} }{\left( w_m - z_0 \right)^2} \right) = \sum^\infty_{k=1} s_k \, h^{k-1}
</div>

tex2math

The tex2math.js plugin converts

  • $ ... $ or \( ... \) into <span class="math"> ... </span> for inline math, and
  • $$ ... $$ or \[ ... \] into <div class="math"> ... </div> for display math.

TeX fonts

jsMath.js uses TeX fonts.

MathML

Main article page: MathML

MathML has two halves:

  • a presentation language, and
  • a content language.

With MathML, users are responsible for installing the appropriate fonts.

ASCIIMathML.js

Noncommercial translation program: ASCIIMathML.

ASCIIMathML.js (ver 2.0): Translating ASCII math notation to MathML and graphics

TeX/LaTeX

Main article page: LaTeX

The math [server-side] processor for the MediaWiki server is a program called texvc, which generates PNG images for complex expressions but outputs HTML for simple ones.

The best known mathematical browser (client-side) plug-in is techexplorer.

Examples

\nabla \times \mathbf{E} = -\frac{\partial \mathbf{B}} {\partial{t}}

Comparison of math renderings for MathML (Firefox) vs MathJax (Firefox) vs PNG (Firefox) vs Chrome Server Side SVG

Math rendering (MathML vs MathJax vs PNG vs Server Side SVG).png

See also


  • {{math/font}} (which yields font-size: 1.15em; font-family: 'Computer Modern', STIXGeneral, 'Times New Roman'; to be used within style="")
  • {{mathfont}} (for HTML+CSS typesetting of very simple mathematical expressions/numbers in section labels, labels of wikilinks and labels of external links) (for mathematical numbers only: NOT for dates, times, chapters, book sections, pages, ...)
  • {{math}} (for typesetting of mathematical expressions in either HTML+CSS or LaTeX)
  • {{intseq}} (for integer sequences)


Notes

References

  • Donald Knuth, The TeXbook.

External links

  • Hayes, Brian (2009), “Writing Math on the Web: The Web would make a dandy blackboard if only we could scribble an equation”, American Scientist 92 (2): 98, doi:10.1511/2009.77.98 .
  • JsMath/MathJax (TeX for Web) — Wiki of the Department of Mathematics of the University of Toronto.
  • Jukka “Yucca” Korpela. Math in HTML (and CSS) — Section Mathematics & physics and IT of the free information site IT and communication.

jsMath (links)

MathJax (links)

Mathoid (links)

  • Moritz Schubotz, Gabriel Wicke, Mathoid: Robust, Scalable, Fast and Accessible Math Rendering for Wikipedia, 2014. arXiv:1404.6179

Web fonts (links)

SVG (links)

TeX fonts (links)

MathML (links)

TeX/LaTeX (links)