# Difference between revisions of "User:TW466/MathJaxTest"

(Add display formula delimiters; layout improvements.) |
(Apparently the MediaWiki:Common.js hack works now!) |
||

Line 37: | Line 37: | ||

== Edit previews == | == Edit previews == | ||

− | Thanks to a hack in [[MediaWiki:Common.js]], maths now show up in edit previews | + | Thanks to a hack in [[MediaWiki:Common.js]], maths now show up in edit previews. |

## Latest revision as of 18:08, 12 March 2019

\(\LaTeX\) can be included in wiki articles by using `<math>...</math>`

tags, `\( ... \)`

or `\[ ... \]`

.

## Contents

## <math> tags

For instance, the following line...

Quadratic equations of the form <math>0 = ax^2 + bx + c</math> can be solved by using <math>x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2 a}</math>.

...results in:

- Quadratic equations of the form [math]0 = ax^2 + bx + c[/math] can be solved by using [math]x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2 a}[/math].

## Brackets and display formulas

`\[ ... \]`

results in a "display" formula instead of an "inline" one. This is best if the equation is meant to stand on its own, without surrounding flow text:

\[ x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2 a} \]

\[ x_{1,2} = \frac{-b \pm \sqrt{b^2 - 4 a c}}{2 a} \]

`\( ... \)`

can also be used as delimiters for inline maths, for instance:
`\( \nabla B = \nabla \times \vec Q \)`

becomes \( \nabla B = \nabla \times \vec Q \).

## Escaping

<nowiki> tags don't escape the bracket delimiters unfortunately (but do escape <math> tags).

Brackets can be escaped by including a `<span></span>`

between the `\`

and the opening/closing bracket, like so:

\<span></span>( \nabla B = \nabla \times \vec Q \<span></span>)

## Chemical formulas

SimpleMathJax also supports <chem> tags, like so:

<chem>CO2 + C -> 2 CO</chem>

[math]\ce{CO2 + C -> 2 CO}[/math]

## Edit previews

Thanks to a hack in MediaWiki:Common.js, maths now show up in edit previews.