Template:Math/doc: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
>Illviljan
m (Changed style so it's easier and clearer where to copy/paste equations.)
>Illviljan
(Added that parser functions can be used.)
Line 28: Line 28:
x^2 + y^2 + z^2 = 1
x^2 + y^2 + z^2 = 1
</math>
</math>
===Advanced usage===
With this template it is possible to use [https://www.semantic-mediawiki.org/wiki/Help:Inline_queries inline queries] such as the parser functions <code>#ask</code>, <code>#show</code> and other [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions extensions] such as <code>#expr</code>. For example:
<pre>
{{Math|formula=
Enfeeble Base Radius - Maximum Default Leech Rate Per Second + Maximum Default 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}} }}
}}
</pre>
yields:
{{Math|formula=
Enfeeble 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}} }}
}}


==Troubleshooting==
==Troubleshooting==

Revision as of 11:01, 3 July 2016

This subpage provides documentation for Template:Math.

The {{math}} template is a wrapper for <math>...</math> tags which are a part of Math extension. It is used to change the default rendering colors (black text on white background) to custom ones that fit this wiki.

Usage

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

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

produces:


While using default <math>...</math> tags like this:

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

produces:

Advanced usage

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 Default Leech Rate Per Second + Maximum Default 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

Placing multiple braces together (e.g. }}}) causes errors. For example, the following code:

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

}}

In order to prevent this either space braces like this:

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

or use the following templates:

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