Template:Math/doc: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
>Illviljan
mNo edit summary
>TheFrz
mNo edit summary
Line 5: Line 5:
For a detailed guide to LaTeX markup see [[Wikipedia:Help:Displaying a formula]].
For a detailed guide to LaTeX markup see [[Wikipedia:Help:Displaying a formula]].


==Parameters==
==Usage==
Code <code><nowiki>{{math|2+3}}</nowiki></code> renders as: {{math|2+3}}
 
===Parameters===
The following parameters are available
The following parameters are available
{| class="wikitable sortable"
{| class="wikitable"
! Parameter !! Required !! Description
! Parameter !! Description
|-
|formula || {{yes}} || Define the latex equation here.
|-  
|-  
|nr      || {{no}}  || Activates numbered equations. Don't forget to use unique numbers.
| <code><nowiki>|formula=</nowiki></code> || Use it if formula contains <code>=</code> sign.
|-
| <code><nowiki>|display=</nowiki></code> || [https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Display_attribute Display attribute] with  possible values:
* <code><nowiki>block</nowiki></code>: equation is rendered in its own paragraph and has indent
* <code><nowiki>inline</nowiki></code>: there will be no new paragraph and the operators will be rendered to consume only a small amount of vertical space
* not specified: no new paragraph and renders similar to <code><nowiki>block</nowiki></code>
|-  
|-  
|display || {{no}}  || [https://en.wikipedia.org/wiki/Help:Displaying_a_formula#Display_attribute Display attribute] with  possible values of <code>inline</code> and <code>block</code>.  
| <code><nowiki>|nr=</nowiki></code> || Activates numbered equations. Don't forget to use unique numbers.
* <code>inline</code> there will be no new paragraph for the equation and the operators will be rendered to consume only a small amount of vertical space.
* <code>block</code> the equation is rendered in its own paragraph and the operators are rendered consuming less horizontal space.
|}
|}


==Usage==
===Basic usage===
Place a formula as a value of a parameter <code>formula</code> of {{tlx|math}}. For example:
====Display====
{|
{| class="wikitable"
|
'''default'''
<pre>The sum {{math
|formula=\sum_{i=0}^\infty 2^{-i}
}} converges to 2.</pre>
|
The sum {{math|formula=\sum_{i=0}^\infty 2^{-i} }} converges to 2.
|-
|
|
<pre>{{math|formula=
'''block'''
x^2 + y^2 + z^2 = 1
<pre>The sum {{math
}}</pre>
|display=block
|formula=\sum_{i=0}^\infty 2^{-i}
}} converges to 2.</pre>
|
|
&nbsp;&nbsp;{{math|formula=x^2 + y^2 + z^2 = 1}}
The sum {{math|display=block|formula=\sum_{i=0}^\infty 2^{-i} }} converges to 2.
|}
|-
 
Instead of default <code><nowiki><math>...</math></nowiki></code> tags:
{|
|
|
<pre><math>
'''inline'''
x^2 + y^2 + z^2 = 1
<pre>The sum {{math
</math></pre>
|display=inline
|formula=\sum_{i=0}^\infty 2^{-i}
}} converges to 2.</pre>
|
|
&nbsp;&nbsp;<math>x^2 + y^2 + z^2 = 1</math>
The sum {{math|display=inline|formula=\sum_{i=0}^\infty 2^{-i} }} converges to 2.
|}
|}


===Advanced usage===
===Advanced usage===
====Numbered equations====
====Numbered equations====
The equations can be numbered using the <code>nr</code> parameter. The equation can then be referenced with {{tlx|EquationNote}}. For example
The equations can be numbered using the <code>nr</code> parameter. The equation can then be referenced with {{tlx|EquationNote}}. For example:
{| width=100%
 
|
<pre>{{math|nr=1|formula=
<pre>{{math|nr=1|formula=
x^2 + y^2 + z^2 = 1
x^2 + y^2 + z^2 = 1  
}}
}}
Equation {{EquationNote|1}} shows the equation for an sphere centered around origo.</pre>
Equation {{EquationNote|1}} shows the equation for an sphere centered around origo.</pre>
|
{{math|nr=1|formula=x^2 + y^2 + z^2 = 1}}
&nbsp;&nbsp;{{math|nr=1||formula=x^2 + y^2 + z^2 = 1}}
Equation {{EquationNote|1}} shows the equation for a [https://en.wikipedia.org/wiki/Sphere sphere] centered around origo.
Equation {{EquationNote|1}} shows the equation for an [https://en.wikipedia.org/wiki/Sphere sphere] centered around origo.
|}
 


====Semantic queries====
====Semantic queries====
Line 73: Line 82:
}}
}}


==Troubleshooting==
==Limitations==
===Error with multiple braces===
===Error with multiple braces===
====Problem====
====Problem====

Revision as of 18:26, 11 July 2016

This subpage provides documentation for Template:Math.

The {{math}} template is a wrapper for <math> tag which is a part of Math extension. The template is mainly used to change the default rendering colors (black text on white background) to custom ones that fit the color scheme of the wiki, but also adds possibilities for using another templates inside of <math>.

For a detailed guide to LaTeX markup see Wikipedia:Help:Displaying a formula.

Usage

Code {{math|2+3}} renders as:

Parameters

The following parameters are available

Parameter Description
|formula= Use it if formula contains = sign.
|display= Display attribute with possible values:
  • block: equation is rendered in its own paragraph and has indent
  • inline: there will be no new paragraph and the operators will be rendered to consume only a small amount of vertical space
  • not specified: no new paragraph and renders similar to block
|nr= Activates numbered equations. Don't forget to use unique numbers.

Basic usage

Display

default

The sum {{math
|formula=\sum_{i=0}^\infty 2^{-i}
}} converges to 2.

The sum converges to 2.

block

The sum {{math
|display=block
|formula=\sum_{i=0}^\infty 2^{-i}
}} converges to 2.
The sum
converges to 2.

inline

The sum {{math
|display=inline
|formula=\sum_{i=0}^\infty 2^{-i}
}} converges to 2.

The sum converges to 2.

Advanced usage

Numbered equations

The equations can be numbered using the nr parameter. The equation can then be referenced with {{EquationNote}}. For example:

{{math|nr=1|formula=
x^2 + y^2 + z^2 = 1 
}}
Equation {{EquationNote|1}} shows the equation for an sphere centered around origo.

Equation 1 shows the equation for a sphere centered around origo.

Semantic queries

With this template it is possible to use inline queries such as the parser functions #ask, #show and other extensions such as #expr. For example:

{{math|formula=
Enfeeble Base Radius - Maximum Leech Rate Per Second + Maximum Endurance Charges 
  =          {{#show: Enfeeble |?Has primary radius=}} - {{#expr:{{#ask: [[-Has subobject::Character]] [[Has stat id::maximum_life_leech_rate_%_per_minute]] |?Has stat value#= |mainlabel=- |limit=1}} /60}} + {{SMW character query|stat=max_endurance_charges}} 
  = {{#expr: {{#show: Enfeeble |?Has primary radius=}} - {{#expr:{{#ask: [[-Has subobject::Character]] [[Has stat id::maximum_life_leech_rate_%_per_minute]] |?Has stat value#= |mainlabel=- |limit=1}} /60}} + {{SMW character query|stat=max_endurance_charges}} }}
}}

yields: Failed to parse (syntax error): \color[RGB]{163,141,109} Enfeeble Radius - Maximum Leech Rate Per Second + Maximum Endurance Charges = {{#show: Enfeeble |?Has primary radius=}} - <strong class="error">Expression error: Unrecognized punctuation character &quot;{&quot;.</strong> + [[:Template:SMW character query]] = <strong class="error">Expression error: Unrecognized punctuation character &quot;{&quot;.</strong>

Limitations

Error with multiple braces

Problem

Placing multiple opening/closing braces together (e.g. {{ or }}) if there are no closing/opening brackets, causes error. This happens because interpreter thinks they are a part of a template when in fact they are a part of a math markup. For example, the following code:

{{math|formula=
DR(A, D_{raw}) = {A \over A + 10 \times D_{raw}}
}}
Failed to parse (syntax error): \color[RGB]{163,141,109} DR(A, D_{raw}) = {A \over A + 10 \times D_{raw

}}

Solution

In order to prevent this either space braces:

{{math|formula=
DR(A, D_{raw}) = {A \over A + 10 \times D_{raw} } 
}}

  

or use the following templates:

{{math|formula=
DR(A, D_{raw}) = {A \over A + 10 \times D_{raw{{))}} 
}}

  

Absolute value denotation

Problem

Absolute values are usually denoted |x|. However using | in templates will result in the following issue.

{{math|formula=
|x|
}}

  

Solution

Use \vert or {{!}}:

{{math|formula=
\vert x\vert
}}

  

{{math|formula=
{{!}}x{{!}}
}}