Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
You must create an account or log in to edit.

Help:KaTeX: Difference between revisions

Help page
Content deleted Content added
No edit summary
Tag: 2017 source edit
No edit summary
Tag: 2017 source edit
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''KaTeX''' (stylised <tex>\KaTeX</tex>) is a [[wikipedia:TeX|TeX]] (stylised <tex>\TeX</tex>) rendering library &mdash; put simply, it processes TeX and produces correctly formatted text. It can be used for formatting [[wikipedia:mathematics|mathematics]], [[wikipedia:chemistry|chemistry]], and [[wikipedia:physical quantity|physical quantities]].
'''KaTeX''' is a [[wikipedia:TeX|TeX]] rendering library&mdash;put simply, it processes TeX and produces correctly formatted text. It can be used for formatting [[wikipedia:mathematics|mathematics]], [[wikipedia:chemistry|chemistry]], and [[wikipedia:physical quantity|physical quantities]].


The following MediaWiki parser tags are supported:
The following MediaWiki parser tags are supported:
Line 23: Line 23:
**<code>mode="display"</code>: Center the TeX on the page and disable text wrapping.
**<code>mode="display"</code>: Center the TeX on the page and disable text wrapping.
*<code>fleqn</code>: Render the TeX flush left with a {{code|lang=css|inline=y|2em}} left margin.
*<code>fleqn</code>: Render the TeX flush left with a {{code|lang=css|inline=y|2em}} left margin.
*<code>leqno</code>: Render <code>\tag</code> on the left instead of the right.
*<code>leqno</code>: Render {{code|lang=tex|inline=y|\tag}} on the left instead of the right.

==Errors==
When you input invalid TeX into a parser tag, it will output it back out with the error available on hover.

An example would be <tex>\\\gasdfg\\?G/sdAS{\fgasdfgadfg</tex>.


==Math==
==Math==
Line 32: Line 37:


==Chemistry==
==Chemistry==
Refer to the [https://mhchem.github.io/MathJax-mhchem/ mhchem for KaTeX guide]. (specifically, {{code|lang=tex|inline=y|\ce}})
Refer to the [https://mhchem.github.io/MathJax-mhchem/ mhchem for KaTeX guide] (specifically, {{code|lang=tex|inline=y|\ce}}).


<syntaxhighlight lang="html">Some example inline chemistry: <chem>\ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}</chem></syntaxhighlight>
<syntaxhighlight lang="html">Some example inline chemistry: <chem>^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem></syntaxhighlight>
Some example inline chemistry: <chem>\ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}</chem>
Some example inline chemistry: <chem>^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem>


<syntaxhighlight lang="html"><chem mode="display">\ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}</chem></syntaxhighlight>
<syntaxhighlight lang="html"><chem mode="display">^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem></syntaxhighlight>
<chem mode="display">\ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}</chem>
<chem mode="display">^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem>


<syntaxhighlight lang="html"><chem mode="display" fleqn>\ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}</chem></syntaxhighlight>
<syntaxhighlight lang="html"><chem mode="display" fleqn>^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem></syntaxhighlight>
<chem mode="display" fleqn>\ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}</chem>
<chem mode="display" fleqn>^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem>


==Quantities==
==Quantities==
Refer to the [https://mhchem.github.io/MathJax-mhchem/ mhchem for KaTeX guide] (specifically, {{code|lang=tex|inline=y|\pu}})
Refer to the [https://mhchem.github.io/MathJax-mhchem/ mhchem for KaTeX guide] (specifically, {{code|lang=tex|inline=y|\pu}}).


<syntaxhighlight lang="html">The weight of an apple is around <quantity>100 g*N/n\Omega</quantity>.</syntaxhighlight>
<syntaxhighlight lang="html">The weight of an apple is around <quantity>100 g*N/n\Omega</quantity>.</syntaxhighlight>
Line 52: Line 57:
The weight of an apple is around <quantity>100 A*B/C2/D-4</quantity>.
The weight of an apple is around <quantity>100 A*B/C2/D-4</quantity>.


==Examples==
*[[Distant Worlds Equations]]
[[Category:Author: tesinormed]]
[[Category:Author: tesinormed]]

Latest revision as of 21:00, May 13, 2025

KaTeX is a TeX rendering library—put simply, it processes TeX and produces correctly formatted text. It can be used for formatting mathematics, chemistry, and physical quantities.

The following MediaWiki parser tags are supported:

  • <tex>
  • <math>
  • <ce>
  • <chem>
  • <quantity>

Tag parameters

When using KaTeX, the general format is:

<tex mode="display" fleqn>\TeX</tex>

The parts of the tag are:

  • <tex> and </tex>: These are the markers which tell MediaWiki where your TeX begins and ends.
  • mode="display" and fleqn: Parameters which change the way the TeX is rendered.
  • \TeX: The TeX to be rendered by KaTeX.

The following parameters are supported:

  • mode
    • mode="display": Center the TeX on the page and disable text wrapping.
  • fleqn: Render the TeX flush left with a 2em left margin.
  • leqno: Render \tag on the left instead of the right.

Errors

When you input invalid TeX into a parser tag, it will output it back out with the error available on hover.

An example would be \\\gasdfg\\?G/sdAS{\fgasdfgadfg.

Math

Refer to the KaTeX supported functions page.

<math mode="display">x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}</math>

x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}

Chemistry

Refer to the mhchem for KaTeX guide (specifically, \ce).

Some example inline chemistry: <chem>^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem>

Some example inline chemistry: \ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}

<chem mode="display">^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem>

\ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}

<chem mode="display" fleqn>^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th</chem>

\ce{^{235}_{92}U -> ^{4}_{2}He + ^{231}_{90}Th}

Quantities

Refer to the mhchem for KaTeX guide (specifically, \pu).

The weight of an apple is around <quantity>100 g*N/n\Omega</quantity>.

The weight of an apple is around \pu{100 g*N/n\Omega}.

The weight of an apple is around <quantity>100 A*B/C2/D-4</quantity>.

The weight of an apple is around \pu{100 A*B/C2/D-4}.

Examples