Template:Math

From Wikibooks, open books for an open world
Jump to: navigation, search
Template documentation[edit] [history] [purge]

Formats HTML - or wikimarkup generated - mathematical formulas in the same manner as HTML based TeX formulas, which uses a serif-based font. Use this template for non-complex formulas as an alternative to using the math tags.

Template parameters

This template prefers inline formatting of parameters.

Parameter Description Type Status
Big big

Request if the font in a bigger (165%) size. by adding 1

Default
empty
Example
1, unused
Auto value
empty
Boolean optional
Font Size size

Used to specify your own font size.

Default
empty
Example
11px, 1.2em, 120%
Auto value
empty
Number optional
Equation 1

The HTML text to display. Note that equal signs must be inputted as {{=}} and absolute value bars as {{!}}

Default
empty
Example
f(x) = x<sup>2</sup> + 2x + 1
Auto value
empty
Content suggested

Rationale for This Template[edit]

The Math template formats HTML- or wikimarkup generated mathematical formulas in the same manner as HTML based TeX formulas, which uses a serif-based font. The generated formula is displayed using the same-size font as the adjoining text. The template will prevent line-wrapping.

Use this template for non-complex formulas as an alternative to using the "math" tags: <math>...</math>.

Examples[edit]

Use this template to wrap an inline formula in wikitext. For example,

What's Written What's Displayed Notes
{{math|''x''<sup>2</sup> + ''y''<sup>2</sup> {{=}} ''r''<sup>2</sup>}} x2 + y2 = r2
{{math|{{mapply|sin <i>π</i>}} {{=}} 0}} sin π = 0. The coding "<i>" puts italic font, same as "<var>"
'''{{math|{{frac|1|2}} − {{frac|1|3}} {{=}} {{frac|1|6}}}}''' 1213 = 16 The triple-apostrophes was interpreted by the wiki; boldface was set.
{{math|1 + 2 {{=}} 3|big=1}} 1 + 2 = 3

Known Bugs[edit]

Because of this template's simplicity, there are some bugs that arise due to the fact that the template is handled through the wiki. This means that keywords and symbols may be inadvertently processed.

Equal Signs[edit]

If a single equals-sign ("=") is used, some bugs may occur because the wiki interprets the equal sign as a parameter assignment. It may show up as "{{{1}}}" or as undefined behavior if this template was used inside another template. For example, you should not write

{{math|1 + 2 = 3}}
This renders whatever is shown after the colon and before the comma: , which is not what you would want.

To resolve this, either:

(a) Start the formula with "1=" {{math|1=1 + 2 = 3}} 1 + 2 = 3, which displays it since you have manually defined the unnamed parameter.
(b) Include the equals-sign in double-braces "{{=}}" {{math|1 + 2 {{=}} 3}} 1 + 2 = 3, which displays it because the wiki interprets {{=}} as an equal sign in the template.
(c) Use the HTML entity name for the equal sign &#61; {{math|1 + 2 &#61; 3}} 1 + 2 = 3, which displays it because your browser interprets &#61; as an equal sign when displaying this page.

Absolute Signs[edit]

If the bar ("|") is used, some bugs may occur because the wiki interprets the bar as a new parameter or as a table component. For example, you should not write

{{math||1 + 2| {{=}} 3}}
This renders whatever is shown after the colon and before the comma: 1 + 2, which is not what you would want.

To resolve this, either:

(a) Write "{{!}}" instead {{math|{{!}}1 + 2{{!}} {{=}} 3}} 1 + 2| = 3, which displays it because the wiki interprets {{!}} as a bar in the template.
(b) Use the HTML entity name for the equal sign &#124; {{math||1 + 2| = 3}} ") when displaying this page.