Template:Math/doc

From Path of Exile Wiki
Revision as of 22:46, 5 July 2016 by >Illviljan (→‎Solution)
Jump to navigation Jump to search

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.

Parameters

The following parameters are available

Parameter Required Description
formula
Define the latex equation here.
nr
Activates numbered equations. Don't forget to use unique numbers.

Usage

Place a formula as a value of a parameter formula of {{math}}. For example:

{{math|formula=
x^2 + y^2 + z^2 = 1
}}

  

Instead of default <math>...</math> tags:

<math>
x^2 + y^2 + z^2 = 1
</math>

  

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.

  No formula given. Equation 1 shows the equation for an 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>

Troubleshooting

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 (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): \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{{!}}
}}