Template:Math/doc

From Path of Exile 2 Wiki
Jump to navigation Jump to search

This subpage provides documentation for Template:Math.

This template is a wrapper for the <math> tag, which is implemented by the Math extension. It is generally preferable to use this template to display formulas as opposed to using <math> tags directly in wikitext. The primary purpose of this template is to change the default text rendering color so that formulas are legible on the wiki's dark background. This template provides some useful options for displaying formulas, such as indented and numbered blocks. Additionally, it allows parser functions and templates to be used inside of formulas.

Usage

Use this template anywhere you wish to display formulas, equations, mathematical symbols, etc., as you would normally do using <math> tags. It is preferable to use this template instead of using <math> tags directly in wikitext.

Parameters

Parameter Optional Description
1, formula No LaTeX syntax used to designate the formula
display Yes Display option – Possible values are:
  • block: Renders formula block-style and displays it in its own paragraph
  • inline: Displays formula inline with surrounding text. Renders inline-style, for a smaller vertical footprint
  • Default: Displays formula inline with surrounding text. Renders block-style
indent Yes How many times to indent the formula display. Used only if display = block
ref Yes Label to reference the formula by. Typically used with {{EquationNote}}. Requires display = block

Basic usage

For more examples, see Template:Math/testcases.

Display

default

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

The sum 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]{0.6392156862745098,0.5529411764705883,0.42745098039215684}\sum _{i=0}^{\infty }2^{-i} converges to 2.

block

The sum {{math
|display=block
|formula=\sum_{i=0}^\infty 2^{-i}
}} converges to 2.
The sum
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/":): {\displaystyle \color [rgb]{0.6392156862745098,0.5529411764705883,0.42745098039215684}\sum _{i=0}^{\infty }2^{-i}}
converges to 2.

inline

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

The sum 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/":): {\textstyle \color [rgb]{0.6392156862745098,0.5529411764705883,0.42745098039215684}\sum _{i=0}^{\infty }2^{-i}} 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.

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]{0.6392156862745098,0.5529411764705883,0.42745098039215684}x^{2}+y^{2}+z^{2}=1 Equation 1 shows the equation for a sphere centered around origo.

Combining with queried data

It is possible to query data with various parser functions such as #cargo_query, #ask and other parser functions such as #expr. Which helps making sure equations stay up date even if the game changes. For example:

{{#vardefine:life_leech_rate| {{Character query|maximum_life_leech_rate_%_per_minute}} }}
{{math|formula=
Maximum Leech Rate Per Minute / 60
  =          {{#var:life_leech_rate}} / 60
  = {{#expr: {{#var:life_leech_rate}} / 60 }}
}}

yields:

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} Maximum Leech Rate Per Minute / 60 = <div class="error">Error: Table generic_stats not found.</div> / 60 = <strong class="error">Expression error: Unexpected &lt; operator.</strong>

Troubleshooting common problems

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} } 
}}

  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} }

or use the following templates:

{{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}}

Absolute value denotation

Problem

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

{{math|formula=
|x|
}}

  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} x

Solution

Use \vert or {{!}}:

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

  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} \vert x\vert

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

  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} |x|

Template forces new line in lists

Problem

When using the template with unordered/ordered lists the template forces a new line.

# The highest-level talisman is counted '''three''' times, {{Math|H}}.
# The middle three talismans are counted '''twice''', {{Math|[M_1, M_2, M_3]}}.
# The lowest-level talisman is counted '''once''', {{Math|L}}.
  1. The highest-level talisman is counted three times, 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} H .
  2. The middle three talismans are counted twice, 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} [M_1, M_2, M_3] .
  3. The lowest-level talisman is counted once, 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} L .

Solution

In order to prevent this use html lists.

<ol>
<li> The highest-level talisman is counted '''three''' times, {{Math|H}}. </li>
<li> The middle three talismans are counted '''twice''', {{Math|[M_1, M_2, M_3]}}. </li>
<li> The lowest-level talisman is counted '''once''', {{Math|L}}. </li>
</ol>
  1. The highest-level talisman is counted three times, 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} H .
  2. The middle three talismans are counted twice, 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} [M_1, M_2, M_3] .
  3. The lowest-level talisman is counted once, 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} L .

See also