Help:Contributing/math: Difference between revisions

From Wikibase
Jump to navigation Jump to search
Document editing math expressions (Special:UpdateMath) — AI-assisted (opencode) (via update-page on MediaWiki MCP Server)
document MathJax $…$ inline/display math in page text (SimpleMathJax); keep the KaTeX snippet flow (via update-page on MediaWiki MCP Server)
Line 1: Line 1:
Mathematical expressions are stored as items whose content is LaTeX source; embeds render them with KaTeX.
Mathematical expressions can be put on a page in two ways:
 
* '''Math in page text''' — LaTeX written directly in the wikitext, delimited with <syntaxhighlight lang="wikitext" inline>$…$</syntaxhighlight> (inline) or <syntaxhighlight lang="wikitext" inline>$$…$$</syntaxhighlight> (display); typeset in the browser by MathJax.
* '''Math snippets''' — an expression stored as an [[Help:Contributing/entities|item]] with [[Special:AddMath]], whose embeds render with KaTeX. Use these when the expression should be reusable and citable (like [[Help:Contributing/quotation|quotations]]).
 
== Math in page text (MathJax) ==
 
Write LaTeX directly in the page text between delimiters:
 
{| class="wikitable"
|-
! Delimiter !! What it does
|-
| <syntaxhighlight lang="wikitext" inline>$…$</syntaxhighlight> || inline math inside a sentence
|-
| <syntaxhighlight lang="wikitext" inline>$$…$$</syntaxhighlight> || display math on its own line, centred
|-
| <syntaxhighlight lang="wikitext" inline><math>…</math></syntaxhighlight> || inline math (tag form — works in templates)
|}
 
<syntaxhighlight lang="wikitext">The famous identity is $e^{i\pi} + 1 = 0$.</syntaxhighlight>
 
Result: The famous identity is $e^{i\pi} + 1 = 0$.
 
For a formula on its own line, use double dollars:
 
<syntaxhighlight lang="wikitext">$$\int_0^1 x^2 \, dx = \frac{1}{3}$$</syntaxhighlight>
 
Result:
 
$$\int_0^1 x^2 \, dx = \frac{1}{3}$$
 
<blockquote>
Rendering happens '''in your browser''' (MathJax). The raw LaTeX source is shown when JavaScript is unavailable or while the page is still loading.
</blockquote>
 
=== Literal dollar signs ===
 
MathJax treats a balanced <syntaxhighlight lang="wikitext" inline>$…$</syntaxhighlight> pair in prose as math. A lone dollar (prices, amounts) is escaped as <syntaxhighlight lang="wikitext" inline>\$</syntaxhighlight>:
 
<syntaxhighlight lang="wikitext">The licence fee is \$5 per copy.</syntaxhighlight>
 
=== Code stays literal ===
 
Code blocks and inline code ([[Help:Contributing/code]]) are never typeset — dollars inside them stay literal:
 
<syntaxhighlight lang="wikitext">price=$5.00</syntaxhighlight>


== Adding an expression ==
== Adding an expression ==
Line 10: Line 56:
| Label || A short description of the expression (e.g. <code>E = mc²</code> or "Newton's second law").
| Label || A short description of the expression (e.g. <code>E = mc²</code> or "Newton's second law").
|-
|-
| Content || The LaTeX source. Enclosing delimiters (<code>$…$</code>, <code>$$…$$</code>, <code>\(…\)</code> or <code>\[…\]</code>) are stripped automatically on save — paste from Markdown or MediaWiki as-is.
| Content || The LaTeX source. Enclosing delimiters (<syntaxhighlight lang="wikitext" inline>$…$</syntaxhighlight>, <syntaxhighlight lang="wikitext" inline>$$…$$</syntaxhighlight>, <syntaxhighlight lang="wikitext" inline>\(…\)</syntaxhighlight> or <syntaxhighlight lang="wikitext" inline>\[…\]</syntaxhighlight>) are stripped automatically on save — paste from Markdown or MediaWiki as-is.
|-
|-
| Describes || Optional: the concept the expression is about — search and pick the entity (several allowed, comma-separated).
| Describes || Optional: the concept the expression is about — search and pick the entity (several allowed, comma-separated).
Line 25: Line 71:
== Editing an expression ==
== Editing an expression ==


Open the expression's item page and click '''Edit content''' under the title — or go to [[Special:UpdateMath]] with the item's id (e.g. <code>Special:UpdateMath/Q100</code>). The content field shows the stored LaTeX exactly as entered (delimiters stay stripped), and the '''Preview''' button renders it with KaTeX before you save. Fields you leave blank keep their existing values.
Open the expression's item page and click '''Edit content''' under the title — or go to [[Special:UpdateMath]] with the item's id (e.g. <syntaxhighlight lang="text" inline>Special:UpdateMath/Q100</syntaxhighlight>). The content field shows the stored LaTeX exactly as entered (delimiters stay stripped), and the '''Preview''' button renders it with KaTeX before you save. Fields you leave blank keep their existing values.


== See also ==
== See also ==
Line 31: Line 77:
* [[Help:Contributing/quotation]] — adding quotations
* [[Help:Contributing/quotation]] — adding quotations
* [[Help:Contributing/code]] — code blocks and syntax highlighting
* [[Help:Contributing/code]] — code blocks and syntax highlighting
* [[Help:Contributing/diagrams]] — PlantUML, GraphViz, Mscgen and Mermaid diagrams
* [[Help:Contributing]] — the hub
* [[Help:Contributing]] — the hub

Revision as of 15:18, 4 September 2026

Languages: English · français · Esperanto

Mathematical expressions can be put on a page in two ways:

  • Math in page text — LaTeX written directly in the wikitext, delimited with $…$ (inline) or $$…$$ (display); typeset in the browser by MathJax.
  • Math snippets — an expression stored as an item with Special:AddMath, whose embeds render with KaTeX. Use these when the expression should be reusable and citable (like quotations).

Math in page text (MathJax)

Write LaTeX directly in the page text between delimiters:

Delimiter What it does
$…$ inline math inside a sentence
$$…$$ display math on its own line, centred
<math>…</math> inline math (tag form — works in templates)
The famous identity is $e^{i\pi} + 1 = 0$.

Result: The famous identity is $e^{i\pi} + 1 = 0$.

For a formula on its own line, use double dollars:

$$\int_0^1 x^2 \, dx = \frac{1}{3}$$

Result:

$$\int_0^1 x^2 \, dx = \frac{1}{3}$$

Rendering happens in your browser (MathJax). The raw LaTeX source is shown when JavaScript is unavailable or while the page is still loading.

Literal dollar signs

MathJax treats a balanced $…$ pair in prose as math. A lone dollar (prices, amounts) is escaped as \$:

The licence fee is \$5 per copy.

Code stays literal

Code blocks and inline code (Help:Contributing/code) are never typeset — dollars inside them stay literal:

price=$5.00

Adding an expression

Open Special:AddMath and fill the form:

Field What it is
Label A short description of the expression (e.g. E = mc² or "Newton's second law").
Content The LaTeX source. Enclosing delimiters ($…$, $$…$$, \(…\) or \[…\]) are stripped automatically on save — paste from Markdown or MediaWiki as-is.
Describes Optional: the concept the expression is about — search and pick the entity (several allowed, comma-separated).
Attributed to / Source / Date Provenance, same as quotations.

Click Preview to render the content with KaTeX before saving (the preview strips the delimiters exactly like the save step).

Saving creates the item and redirects to it.

From the item page, click Copy embed code and paste the snippet on any page; the expression renders as KaTeX (the raw LaTeX source is shown if JavaScript is unavailable).

Editing an expression

Open the expression's item page and click Edit content under the title — or go to Special:UpdateMath with the item's id (e.g. Special:UpdateMath/Q100). The content field shows the stored LaTeX exactly as entered (delimiters stay stripped), and the Preview button renders it with KaTeX before you save. Fields you leave blank keep their existing values.

See also