tex2wiki is a button on the edit toolbar which turns a passage of LaTeX into wikitext: select the LaTeX and press it, or press it with nothing selected and the whole box is converted. It keeps the company of TeX2unicode, dates2wiki and mdtable2wiki, and of the two buttons already sitting beside it in MediaWiki:Common.js, the PDF-mending flask and the Eq promoter.
Written with Claude Opus 5 on 1 September (2026). Version 1.1. The code is at MediaWiki:Gadget-tex2wiki.js and it is on for everyone by default.
The contents of $…$, \(…\), \[…\], $$…$$ and of every AMS environment are carried across letter for letter, SimpleMathJax reading LaTeX already. Only the delimiters are house-corrected:
| LaTeX | wikitext | why |
|---|---|---|
\(x\) |
$x$ |
both work here, one is what the wiki writes |
\[x\] |
$$x$$ |
wgSmjDisplayMath is $$…$$ and nothing else, so \[…\] is not maths on this wiki at all, but four stray characters and a formula loose in the prose
|
\[x\label{eq:k}\] |
\begin{equation}x\label{eq:k}\end{equation} |
the LabelledTags class numbers an equation only when it carries a \label and is an AMS environment; a labelled $$…$$ would print no number and every \eqref pointing at it would print (???)
|
\begin{align}… |
the same, untouched | nothing to correct |
\label, \ref and \eqref are left exactly where they are, MathJax being what reads them, and the numbering stays automatic.
LaTeX wraps its paragraphs at column 72 or so and wikitext takes a paragraph on one line; a stray newline in the middle of a sentence is the most tedious thing to undo by hand in a long paste. Blank lines stay blank lines, everything else within a paragraph is joined with a space. A display equation keeps a line of its own, with no blank line around it, the text flowing on underneath it in the same paragraph—which is how the equations read on every page here.
| LaTeX | wikitext |
|---|---|
\section{X} \subsection{X} |
== X ==, === X ===
|
\paragraph{X} |
'''X''' run into the paragraph
|
\emph \textit \textsl |
''X''
|
\textbf |
'''X'''
|
\texttt \verb|X| |
<code>X</code>
|
\underline, \textsc |
<u>X</u>, a small-caps <span>
|
| itemize / enumerate / description | * / # / ; term : definition, nesting kept
|
| quote / quotation | {{quote|text=…}}, its pipes escaped as {{!}}
|
| center, verse | <center>, <poem>
|
| figure | [[File:…|300px]] and the caption in <small> with its {{figlabel}} number
|
| table, tabular | {| class="wikitable", with \multicolumn as colspan and the first row a header when a rule follows it
|
| verbatim, lstlisting | <pre>, <source lang="…">
|
\footnote{X} |
<ref>X</ref>
|
\cite{k}, \citet{k} |
{{cite}}, {{citet}} |
\ref{fig:x} |
{{figref}} |
\href{u}{t}, \url{u} |
[u t], [u]
|
~ |
|
``x'' |
“x”
|
---, -- |
— and –, the em-dash closed up on both sides |
\'e \"o \c{c} \v{s} \ss \o |
é ö ç š ß ø, and the rest of them |
\% \& \# \_ \{ \} \$ |
the character itself |
\\ |
<br />
|
% comments |
gone, the line with them when there was nothing else on it—and a line that ends in one joins the next with no space at all, LaTeX having eaten that newline |
The topmost sectioning level of the passage becomes ==, whatever it is: a single = = is the page's own title, so a document written in \chapter/\section/\subsection gets ==, === and ====, and a fragment that only ever says \subsection still starts at ==.
The notification counts what was converted—headings, formulas, list items, tables, figures, citations, footnotes, joined lines—and then, after a dash, the things worth a look: the preamble was dropped, a stray \label went with it, the File: names to check (\includegraphics{plots/spectrum} names no extension and no directory survives), and every command and environment it did not know, left standing in the text where they are easy to find. That last list is the list of things to fix by hand; a notification carrying any of it stays on screen until it is clicked away.
textSelection API, so Ctrl+Z takes the whole conversion back, and CodeMirror holding the real document is not a problem.<pre> or <source> block already in the box is protected from the line-joining, and ''italics'' already in the box is only read as a LaTeX closing quote when the passage opens quotations with ``.CONFIG.paragraph to 'heading' at the top of the gadget.mw.libs.tex2wiki.convert( latex ).text.actions=edit, so it is on the edit form and not on a reader's wire. The microblog composer builds its toolbar by hand and asks for ext.gadget.tex2wiki by name, as it does for wplink, so the button is on 𝕐's and ℤ's composing box too (from microblog 1.59): press Toolbar beside Preview and it is there.