Template:Math

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

Template documentation[view] [edit] [history] [purge]


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 display-style and displays it in its own paragraph
  • inline: Displays formula inline with surrounding text. Renders text-style, for a smaller vertical footprint
  • Default: Displays formula inline with surrounding text. Renders display-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 {{EquationRef}}. Requires display = block

Formula

The formula is written by providing LaTeX syntax with |formula= or |1=.

{{math|formula=E=mc^2}}

Display options

Default

The default display option has |display= omitted or left blank. This option displays the formula inline with the surrounding text. The formula is rendered display-style.

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

The sum converges to 2.

Block

With |display= set to block, the formula is always displayed in its own paragraph. The formula is rendered display-style.

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

Use |indent= to specify the number of times to indent the formula display.

{{math
|display = block
|indent = 1
|formula = u = \dfrac{1}{\sqrt{2} }(x+y)
}}

Use |ref= to provide a label to reference the formula by. {{EquationRef}} is typically used for this purpose in conjunction with {{EquationNote}}.

{{math
|display = block
|ref = {{EquationRef|1|Eq. 1}}
|formula = x^2 + y^2 + z^2 = 1
}}

{{EquationNote|1|Equation 1}} shows the equation for a sphere centered on the origin.
(Eq. 1)

Equation 1 shows the equation for a sphere centered on the origin.

Inline

With |display= set to inline, the formula is displayed inline with the surrounding text. The formula is also rendered text-style, which takes up less vertical space.

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

The sum converges to 2.

Using queried data in formulas

Formulas may contain parser functions and templates. It is possible to query certain game data with Cargo then display it inside of a formula. Doing so can help ensure that articles stay up to date.

In the following example, the base value of the character stat maximum_life_leech_rate_%_per_minute is queried using {{character query}} and defined as a variable called life_leech_rate with the #vardefine parser function. The value of life_leech_rate is used in an expression with #var. The expression is evaluated using #expr.

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

Failed to parse (unknown function "\begin{align}"): \color[RGB]{163,141,109} \begin{align} M & = 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> \end{align}

Troubleshooting common problems

There are several common problems that arise because LaTeX uses characters that are also used for transcluding templates in wikitext.

Equals signs

If the formula contains an equals sign (=), it is imperative to give the name of the formula parameter explicitly. Write |1= or |formula=.

Incorrect Correct
{{math|E=mc^2}}
{{math|1=E=mc^2}}
No formula given.

Consecutive closing braces

Multiple closing braces placed together (}}) are interpreted by the wikitext parser as being part of the syntax for template transclusion. If the formula syntax needs consecutive closing braces, they should be separated with a space.

Incorrect Correct
{{math|formula=DR(A, D_{raw}) = \frac{A}{A + 10 \times D_{raw}}}}
{{math|formula=DR(A, D_{raw}) = \frac{A}{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}) = \frac{A}{A + 10 \times D_{raw }}

Absolute value denotation

The absolute value of is denoted as . The pipe character (|) is interpreted by the wikitext parser as being part of the syntax for template transclusion. Use \vert instead.

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

See also