💾 Archived View for gemi.dev › gemlog › 2022-06-11-unicode-latex.gmi captured on 2023-11-04 at 11:33:38. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-07-10)

-=-=-=-=-=-=-

Math into Gemtext. LaTeX into Unicode

2022-06-11 | #Gemtext #Gemipedia | @Acidus

@dj-chase had a piece about a super clever way to display complex math formulas in plain gemtext: Using pre formatted text!

DJ Chase's post on Math in pre-formatted text

This is a great solution for people who are writing their own gemtext and wanting to include math. However it requires a fair amount of manual work to make it look right, and a good knowledge of the unicode characters you have available. Unfortunately for me, I'm dealing with arbitrary math formulas in Wikipedia content. I think it would be really difficult to write code that could do this conversion automatically.

Luckily for me, most of these math formaulas are defined using LaTeX, which is exactly made for this, and Wikipedia gets me access to PNG with beautifully rendered LaTeX

Math Formula from the "Uncertainty principle" article

Gemipedia: "Uncertainty principle"

... ... you know...

I do have the LaTeX code...

... and while some formulas are pretty complex, many of them aren't, like the area of a triangle. I wonder if someone has thought of a way to turn LaTeX into a Unicode string just using native Unicode symbols...

It turns out, people have:

Latex-to-unicode (Python)

Latex-to-unicode.js

This code is pretty similar to how I handled HTML subscripts and superscripts. It supports some fractions, superscripts, subscripts, and symbols like Δ. I should be able to adapt this code into something that tries to convert LaTeX to Unicode, and know if I was able to fully convert all parts of the formula.

So now I'm thinking: