# LaTeX to Gutenberg conversion

- Link: https://cagrimmett.com/2026/02/13/latex-to-gutenberg-conversion/
- Published: 2026-02-13T22:47:38-05:00
- Author: Chuck Grimmett

Do any mathematicians read my blog? Perhaps one or two of my former math professors
or classmates?

At work, I forked an old package that converts .tex files to WordPress-compatible
HTML and updated it to generate modern Gutenberg markup for the WordPress block 
editor.

I’d love help testing it out and identifying the rough edges.

Here it is:

![](https://opengraph.githubassets.com/d284c677735787813be3f65e3afcd7cb7f14c05f0cc652c0c181d93f41a8ee1d/
a8cteam51/LaTeX2Gutenberg)

GitHub – a8cteam51/LaTeX2Gutenberg: A port of LaTeX2WP to work with Gutenberg

A port of LaTeX2WP to work with Gutenberg. Contribute to a8cteam51/LaTeX2Gutenberg
development by creating an account on GitHub.

github.com

Here a PDF of the example.tex file in the repo generated from the popular `pdflatex`
package, along with the generated Gutenberg output for comparison.

[example](https://cagrimmett.com/wp-content/uploads/2026/02/example.pdf)[Download](https://cagrimmett.com/wp-content/uploads/2026/02/example.pdf)

---

Look at the document source to see how to ~strike out~ text, how to use different
colors, and how to [link to URLs with snapshot preview](http://www.google.com) and
how to [link to URLs without snapshot preview](http://www.google.com).

There is a command which is ignored by pdflatex and which defines where to cut the
post in the version displayed on the main page

Anything between the conditional declarations _ifblog . . . fi_ is ignored by LaTeX
and processed by latex2wp. Anything between _iftex . . . fi_ is processed by LaTex
and ignored by latex2wp.

This green sentence appears only in WordPress

This is useful if one, in desperation, wants to put pure HTML commands in the _ifblog...
fi_ scope.

> **Lemma 1 (Main).** _  Let ⌊{\cal F}⌉ be a total ramification of a compactifier,
> then _
> ∀g∈ℱ.g2=η     (1)\forall g \in {\cal F}. g^2 = \eta \ \ \ \ \ (1)

The (modifiable) numbering scheme is that lemmas, theorems, propositions, remarks
and corollaries share the same counters, while exercises and examples have each 
their own counter.

> **Theorem 2.** _  The adèle of a number field is never hyperbolically transfinite._

_Proof:_ Left as an exercise. ⌊\Box⌉

> **Exercise 1.** _ Find a counterexample to Theorem [2](https://cagrimmett.com/2026/02/13/latex-to-gutenberg-conversion/#thad)._

> **Exercise 2 (Advanced).** _ Prove Lemma [1](https://cagrimmett.com/2026/02/13/latex-to-gutenberg-conversion/#lmmain)._

Note that accented characters are allowed. Unfortunately, Erd\H{o}s’s name cannot
be properly typeset in HTML.

It is possible to have numbered equations

1x2≥0     (2)\frac 1 {x^2} \ge 0 \ \ \ \ \ (2)

and unnumbered equations

t(x)−12≥x13t(x) – \frac 12 \geq x^{\frac 13}

Unnumbered equations can be created with the double-dollar sign command or with 
the backslash-square bracket command.

f(x)=∫−∞x1t2dtf(x) = \int_{-\infty}^{x} \frac 1 {t^2} dt

It is possible to refer to equations and theorems via the _ref_, _eqref_ and _label_
LaTeX commands, for example to Equation ([2](https://cagrimmett.com/2026/02/13/latex-to-gutenberg-conversion/#eqtest)),
to Equation [(1)](https://cagrimmett.com/2026/02/13/latex-to-gutenberg-conversion/#eqlemma),
and to Lemma [1](https://cagrimmett.com/2026/02/13/latex-to-gutenberg-conversion/#lmmain)
above.

_do not nest a {\bf bold_ text inside an emphasized text or viceversa.}

The theorem-like environments _theorem_, _lemma_, _proposition_, _remark_, _corollary_,
_example_ and _exercise_ are defined, as is the _proof_ environment.

The LaTex commands to type $, %, and & are supported.

It it is possible to have tabular environments, both with borders (the border will
not be displayed in the LaTeX preview), as in

|  blog  |  quality | 
|  what’s new  |  excellent | 
|  in theory  |  poor  |

and without borders as in

|  ⌊{a}⌉  |  ⌊{\rightarrow}⌉  |  ⌊{b}⌉ | 
|  ⌊{\downarrow}⌉  |  |  ⌊{\uparrow}⌉ | 
|  ⌊{c}⌉  |  ⌊{\rightarrow}⌉  |  ⌊{d}⌉  |

(The tabular environments will be centered in WordPress, but not in the LaTeX preview.)

And it is possible to include a picture so that the pdf file produced with pdflatex
imports it from a local image file (which has to be pdf, gif, jpeg, or png) and 
the WordPress post imports it from a URL.

![](https://i0.wp.com/imgs.xkcd.com/comics/donald_knuth.png)

The _image_ command used to generate the above image has three parameter: a size
parameter for either the width or the height, expressed in pixels (if different 
from the original resolution, the picture will be scaled), a URL for the location
of the image (this will be used by WordPress) and a local file name (which will 
used by pdflatex).

It is possible to have numbered and unnumbered sections and subsections. References
to _label_ commands which are not in the scope of a numbered equation or a numbered
theorem-like environment will refer to the section number, such as a reference to
Section [1](https://cagrimmett.com/2026/02/13/latex-to-gutenberg-conversion/#sec)
below.

## Examples of Sections

### And Subsections

## 1. A section

### 1.1. And a subsection

## 2. Changing the style

The file latex2wpstyle.py contains several definitions that determine the appearance
of the WordPress translation. It should be self-explanatory to change the way sections,
subsections, proofs and theorem-like environments are typeset, and to change the
numbering scheme for theorem-like environments.

The variable ⌊{M}⌉ in latex2wpstyle.py contains a list of pairs of strings. For 
every pair, every occurrence of the first string in the document is replaced by 
an occurrence of the second before proceeding to the conversion from LaTeX to WordPress.
If you want to use simple macros (which do not involve parameter-passing) then edit⌊{
M}⌉ to add support for your own LaTeX macros. (You will have to define the macros
in macrosblog.tex as well, otherwise you will not be able to compile your LaTeX 
file and preview it.)

Some macros are already defined. For example, backslash-E produces an expectation
symbol:

𝔼x∈X⁡f(x):=∑x∈Xℙ[x]⋅f(x)\mathop{\mathbb E}_{x \in X} f(x) := \sum_{x\in X} \mathop{\
mathbb P} [x] \cdot f(x)

## Comments

### By: Robert Felty

- Link: https://cagrimmett.com/2026/02/13/latex-to-gutenberg-conversion/#comment-43584
- Published: 2026-02-16T17:52:28-05:00

I have been an avid LaTeX user for over 20 years. I have been using PlasTeX for 
the last 10 years or so to convert to html so I can post to my blog. I will try 
to find some time to give this a try.

Loading...
