Template:Mbox: Difference between revisions

Template page
No edit summary
(steal unused template for a new high-level meta-template (for interaction between {{ambox}}, {{imbox}} and {{cmbox}})
Line 1: Line 1:
<span style="white-space: nowrap;">{{{|{{{1}}}}}}</span><noinclude>
{{ {{#switch:{{NAMESPACE}}
----
|{{ns:0}}=ambox
This template prevents line breaks during HTML mathematics. It is a practical alternative to excessive use of [[non-breaking space]]s (&#38;nbsp;).
|{{ns:Image}}=imbox
 
|{{ns:Category}}=cmbox
==Use==
  |#default=ambox
In a math article, included math such as
}}
<pre>''f'': ''X'' × ''Y'' → [0, 1]</pre>
|{{#if:{{{type|}}}|type|}}={{{type|}}}
may end up broken between lines.  This can be fixed using nonbreaking spaces:
|{{#if:{{{image|}}}|image|}}={{{image|}}}
<pre>''f'':&#38;nbsp;''X''&#38;nbsp;×&#38;nbsp;''Y''&#38;nbsp;→&#38;nbsp;[0,&#38;nbsp;1]</pre>
|{{#if:{{{style|}}}|style|}}={{{style|}}}
However, this results in cumbersome source code which can be difficult to edit.  Using this template, the same result can be achieved with:
|{{#if:{{{textstyle|}}}|textstyle|}}={{{textstyle|}}}
<pre>{{mbox| ''f'': ''X'' × ''Y'' → [0, 1]}}</pre>
|{{#if:{{{text|}}}|text|}}={{{text|}}}
 
}}
===Dealing with equations===
Because of Wikipedia limitations on templates, mbox doesn't function as stated above if the math contains an equals sign.  In this case, the following syntax should be used:
<pre>{{mbox|= 2''x'' + 3''y'' + 5''z'' = 7}}</pre>
Using |= instead of | also works for non-equations.
[[Category:Mathematics templates|{{PAGENAME}}]]
</noinclude>

Revision as of 10:44, 20 May 2008