top | item 41984073

Show HN: Latex.to – LaTeX to image converter running in the browser

85 points| Wdorf | 1 year ago |latex.to

I've made a website to easily share a LaTeX math formula.

- The image is created in the browser (i.e. the LaTeX is not send to a server for rendering)

- Native share dialog (share via WhatsApp etc.)

- Extra keyboard buttons for symbols like "$" or "\" on mobile

- Share via png or unicode

Demo video: https://www.youtube.com/shorts/fGuTns5Nt9Q

Please let me know any feedback on how to improve the website.

38 comments

order

einpoklum|1 year ago

> Please let me know any feedback on how to improve the website.

1. You can give credit where it is due - on the website, to katex and the HTML-to-image renderer library/engine. 2. You could offer any of the three possible outputs: Raster image, HTML, MathML - for exporting/sharing/downloading.

Wdorf|1 year ago

Thank you for your feedback.

I've just added the links to both projects in the info modal.

I will look into adding HTML and MathML exports in the next version.

mcraiha|1 year ago

1. Add tooltips to the top icons 2. Support SVG output

Wdorf|1 year ago

Thank you, those are both very good suggestions I will look into!

Cieric|1 year ago

Shorts link didn't work for me, here is the normal player link

https://www.youtube.com/watch?v=fGuTns5Nt9Q

I'm not to familiar with LaTeX so I much prefer a WYSIWYG editor. I mainly use things like wolframalpha's editor to really get a good representation of what I need.

I know something like that might be out of scope for something like this, but you could potentially do preprogrammed buttons like having a sqrt button insert "\sqrt{}" to the cursor position.

Wdorf|1 year ago

Thank you very much for your feedback, I will look into adding more keyboard buttons like "\sqrt{}"

mindv0rtex|1 year ago

I was recently trying to solve a similar problem but on desktop platforms. I don't want to depend on LaTeX, but I'd like to be able to generate equation images inside a C++ desktop application. I tried to make MathJax run via QuickJS and extract the SVG for rasterization. But I couldn't make MathJax run with QuickJS.

sitkack|1 year ago

Have you tried embedding V8 to see how your idea works? Sounds good to me.

mgt19937|1 year ago

Cool project! I like the idea of easily sharing LaTeX formulas. It's impressive how smooth it works right in the browser.

I've always thought compiling LaTeX in WebAssembly would be a tough nut to crack, so I was curious if that's what you'd done here. Turns out you're using KaTeX.

Have you considered any WebAssembly approaches?

Wdorf|1 year ago

Thank you for your positive feedback.

KaTeX does not support all LaTeX features but initializes very quickly.

LaTeX via WebAssembly supports more features but might need longer to initialize.

There's an existing WebAssembly project: https://www.swiftlatex.com

red_trumpet|1 year ago

There is TikZJax[1], which apparently compiles TeX to WebAssembly, to run TikZ in the browser.

[1] https://tikzjax.com/

jszymborski|1 year ago

Not OP, but do you mind me asking what advantages you hope to achieve by using WebAssembly rather than KaTeX?

ComputerGuru|1 year ago

I’d be very interested in the opposite! Lots of scanned or legacy images that would be nice to convert to LaTeX, or to create a robust PDF ingestion pipeline.

hextex|1 year ago

Facebook's Nougat [1] should work with this, but not sure how much preprocessing is needed to yield good results with scanned copies of physical documents. Note that it outputs .mmd files (MultiMarkDown), but the equations and tables should (iirc) output plain LaTeX.

1: https://github.com/facebookresearch/nougat

Wdorf|1 year ago

I could add a GPT based pdf to latex functionality in the future.

vzaliva|1 year ago

Have you considered translating formulae to MathML for rendering?

einpoklum|1 year ago

It looks like OP is already doing that. Or rather, OP calls katex (https://katex.org/) to get MathML and HTML; then renders the HTML to a raster image. But he's throwing the MathML away.

Wdorf|1 year ago

KaTeX has a build in MathML feature, but I haven't yet looked into it for rendering.

The "Share text" functionality of the website uses KaTeX's MathML feature as an intermediate step.

Ennea|1 year ago

It feels like I am seeing more and more websites lately that have a favicon that is deliberately broken, and I'm not sure why this appears to be a thing that is somehow gaining traction.