Template:Math/doc: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
(category)
>TheFrz
mNo edit summary
Line 1: Line 1:
{{documentation subpage}}
{{documentation subpage}}


The {{tlx|math}} template is a wrapper for <code><nowiki><math>...</math></nowiki></code> tags which are a part of [https://www.mediawiki.org/wiki/Extension:Math Math extension]. It is used to change the default rendering colors (black text on white background) to custom ones that fit this wiki.
The {{tlx|math}} template is a wrapper for <code><nowiki><math></nowiki></code> tag which is a part of [https://www.mediawiki.org/wiki/Extension:Math 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 <code><nowiki><math></nowiki></code>.


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]].
Line 7: Line 7:
==Usage==
==Usage==
Place a formula as a value of a parameter <code>formula</code> of {{tlx|math}}. For example:
Place a formula as a value of a parameter <code>formula</code> of {{tlx|math}}. For example:
<pre>
{|
{{math|formula=
|
<pre>{{math|formula=
x^2 + y^2 + z^2 = 1
x^2 + y^2 + z^2 = 1
}}
}}</pre>
</pre>
|
 
&nbsp;&nbsp;{{math|formula=x^2 + y^2 + z^2 = 1}}
produces:
|}
:{{math|formula=
x^2 + y^2 + z^2 = 1
}}
 
 
While using default <code><nowiki><math>...</math></nowiki></code> tags like this:
<pre>
<math>
x^2 + y^2 + z^2 = 1
</math>
</pre>


produces:
Instead of default <code><nowiki><math>...</math></nowiki></code> tags:
:<math>
{|
|
<pre><math>
x^2 + y^2 + z^2 = 1
x^2 + y^2 + z^2 = 1
</math>
</math></pre>
|
&nbsp;&nbsp;<math>x^2 + y^2 + z^2 = 1</math>
|}


===Advanced usage===
===Advanced usage===
Line 35: Line 30:


<pre>
<pre>
{{Math|formula=
{{math|formula=
Enfeeble Base Radius - Maximum Leech Rate Per Second + Maximum Endurance Charges  
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}}  
   =          {{#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}}  
Line 43: Line 38:


yields:
yields:
{{Math|formula=
{{math|formula=
Enfeeble Radius - Maximum Leech Rate Per Second + Maximum Endurance Charges  
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}}  
   =          {{#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}}  
Line 52: Line 47:
===Error with multiple braces===
===Error with multiple braces===
====Problem====
====Problem====
Placing multiple opening/closing braces together (e.g. <code><nowiki>{{</nowiki></code> or <code><nowiki>}}</nowiki></code>) if there are no closing/opening brackets, causes errors. 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:
Placing multiple opening/closing braces together (e.g. <code>{{</code> or <code>}}</code>) 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:
<pre>
{|
{{math|formula=
|
<pre>{{math|formula=
DR(A, D_{raw}) = {A \over A + 10 * D_{raw}}
DR(A, D_{raw}) = {A \over A + 10 * D_{raw}}
}}
}}</pre>
</pre>
|}
 
:{{math|formula=
:{{math|formula=
DR(A, D_{raw}) = {A \over A + 10 * D_{raw}}
DR(A, D_{raw}) = {A \over A + 10 * D_{raw}}
Line 64: Line 59:


====Solution====
====Solution====
In order to prevent this either space braces like this:
In order to prevent this either space braces:
<pre>
{|
{{math|formula=
|
<pre>{{math|formula=
DR(A, D_{raw}) = {A \over A + 10 * D_{raw} }  
DR(A, D_{raw}) = {A \over A + 10 * D_{raw} }  
}}</pre>
}}</pre>
 
|
:{{math|formula=DR(A, D_{raw}) = {A \over A + 10 * D_{raw} } }}
&nbsp;&nbsp;{{math|formula=DR(A, D_{raw}) = {A \over A + 10 * D_{raw} } }}
|}


or use the following templates:
or use the following templates:
Line 80: Line 77:
* [[Template:(((]]
* [[Template:(((]]


<pre>
{|
{{math|formula=
|
<pre>{{math|formula=
DR(A, D_{raw}) = {A \over A + 10 * D_{raw{{))}}  
DR(A, D_{raw}) = {A \over A + 10 * D_{raw{{))}}  
}}
}}</pre>
</pre>  
|
 
&nbsp;&nbsp;{{math|formula=DR(A, D_{raw}) = {A \over A + 10 * D_{raw{{))}} }}
:{{math|formula=
|}
DR(A, D_{raw}) = {A \over A + 10 * D_{raw{{))}}  
}}


===Absolute value denotation===
===Absolute value denotation===
====Problem====
====Problem====
[https://en.wikipedia.org/wiki/Absolute_value Absolute values] are usually denoted |x|. However using <code>|</code> in templates will result in the following issue.
[https://en.wikipedia.org/wiki/Absolute_value Absolute values] are usually denoted |x|. However using <code>|</code> in templates will result in the following issue.
<pre>
{|
{{math|formula=
|
<pre>{{math|formula=
|x|
|x|
}}
}}</pre>
</pre>
|
yields:
&nbsp;&nbsp;{{math|formula=|x|}}
{{math|formula=
|}
|x|
}}


====Solution====
====Solution====
Use [[Template:!]]:
Use [[Template:!]]:
<pre>
{|
{{math|formula=
|
<pre>{{math|formula=
{{!}}x{{!}}
{{!}}x{{!}}
}}
}}</pre>
</pre>
|
yields:
&nbsp;&nbsp;{{math|formula={{!}}x{{!}}}}
{{math|formula=
|}
{{!}}x{{!}}
}}


<includeonly>
<includeonly>
[[Category:Formatting templates]]
[[Category:Formatting templates]]
</includeonly>
</includeonly>

Revision as of 17:58, 5 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

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

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 (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} 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 * D_{raw}}
}}
Failed to parse (syntax error): \color[RGB]{163,141,109} DR(A, D_{raw}) = {A \over A + 10 * D_{raw

}}

Solution

In order to prevent this either space braces:

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

  

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 Template:!:

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