10 ms·
Show HN: Latex.to – LaTeX to image converter running in the browser
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 https://www.youtube.com/shorts/fGuTns5Nt9Q
Please let me know any feedback on how to improve the website.
- Cieric 2y agoShorts link didn't work for me, here is the normal player link https://www.youtube.com/watch?v=fGuTns5Nt9Q 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 2y agoThank you very much for your feedback, I will look into adding more keyboard buttons like "\sqrt{}"
- programjames 2y agoThere's a similar feature on AoPS: https://aops.com/texer https://aops.com/texer
- mgt19937 2y agoCool 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?
- jszymborski 2y agoNot OP, but do you mind me asking what advantages you hope to achieve by using WebAssembly rather than KaTeX?
- trurl42 2y agoWell, for one, KaTeX doesn't do "LaTeX" but a limited subset of the TeX equation syntax. As such, it can't handle more complicated macros or typesetting anything apart from equations.
- Wdorf 2y agoThank 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 https://www.swiftlatex.com
- red_trumpet 2y agoThere is TikZJax[1], which apparently compiles TeX to WebAssembly, to run TikZ in the browser. [1] https://tikzjax.com/ https://tikzjax.com/
- dunham 2y agoI played with web2js a couple of years ago. TeX ends up being a 500kb WASM file (88kb gzipped). The LaTeX format file or the memory image after LaTeX is loaded are a bit bigger though (2.3 MB and 6.3MB gzipped, respectively).
- KeplerBoy 2y agoHow does it work? Are you shipping a wasm latex distribution?
- Wdorf 2y agoLaTeX: https://katex.org https://katex.org Image generation: https://github.com/bubkoo/html-to-image https://github.com/bubkoo/html-to-image
- KeplerBoy 2y agoOkay, so it's not LaTeX, just math typesetting that looks like LaTeX and takes LaTeX input. I'm more interested in solutions that work with the broader LaTeX ecosystem (like SiUnitX or amsmath).
- abdullahkhalids 2y agoMathjax does support a whole bunch of common latex math related packages [1]. SiUnitX is notably missing from the inbuilt extensions, but a port to version 2 is available [2]. Should be updated to version 3. [1] https://docs.mathjax.org/en/latest/input/tex/extensions/index.html https://docs.mathjax.org/en/latest/input/tex/extensions/inde... [2] https://github.com/mathjax/MathJax-third-party-extensions https://github.com/mathjax/MathJax-third-party-extensions
- Wdorf 2y agoThank you, I wasn't aware of these extensions.
- fweimer 2y agoAhh. I was confused for a moment why \def wasn't working.
- vzaliva 2y agoHave you considered translating formulae to MathML for rendering?
- Wdorf 2y agoKaTeX 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.
- einpoklum 2y agoIt looks like OP is already doing that. Or rather, OP calls katex (https://katex.org/ https://katex.org/) to get MathML and HTML; then renders the HTML to a raster image. But he's throwing the MathML away.
- einpoklum 2y 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 2y agoThank 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.
- ComputerGuru 2y agoI’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.
- Wdorf 2y agoI could add a GPT based pdf to latex functionality in the future.
- sorenjan 2y agoLike Mathpix? https://mathpix.com/ https://mathpix.com/
- BeetleB 2y agoMathpix is awesome. So far it has never gotten the output wrong. I even have it integrated into Emacs/org-mode.
- hextex 2y agoFacebook'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 https://github.com/facebookresearch/nougat
- Wdorf 2y agoThis looks really interesting! I will definitely have a look.
- Vetch 2y agoIn addition to the already mentioned https://huggingface.co/facebook/nougat-base https://huggingface.co/facebook/nougat-base, I also highly recommend https://huggingface.co/stepfun-ai/GOT-OCR2_0 https://huggingface.co/stepfun-ai/GOT-OCR2_0. It might even be better.
- mcraiha 2y ago1. Add tooltips to the top icons 2. Support SVG output
- Wdorf 2y agoThank you, those are both very good suggestions I will look into!
- mindv0rtex 2y agoI 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 2y agoHave you tried embedding V8 to see how your idea works? Sounds good to me.
- rfdonnelly 2y agoKroki [1] supports TikZ and by extension: PGF [2] and LaTeX. It supports SVG, PDF, JPEG, and PNG outputs. Rendering is done on the server. URLs can be quite long since the source is embedded in the URL but you can use a URL shortener [3]. [1]: https://kroki.io/ https://kroki.io/ [2]: https://tikz.dev/ https://tikz.dev/ [3]: https://tinyurl.com/kroki-svg-example https://tinyurl.com/kroki-svg-example
- kreyenborgi 2y agoFor the other direction, there is https://detexify.kirelabs.org/classify.html https://detexify.kirelabs.org/classify.html :)
- coffeeri 2y agoEven better is https://simpletex.cn/ https://simpletex.cn/
- deleted 2y ago[deleted]
- Bimos 2y agoI'm a native Chinese speaker. I knew Detexify and used it a lot. This is the first time I see this software. I tried with hand written \succeq, and until its anti-crawler mechanism is triggered, it fails to give the answer. You can argue it is a software with a different purpose (e.g. to convert a piece of content rather than a single symbol), but to me it is not "even better" than detexify.
- Ennea 2y agoIt 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.
- Wdorf 2y agoI will design a proper favicon! I think I implemented the current placeholder according to https://stackoverflow.com/a/13416784 https://stackoverflow.com/a/13416784
- Ennea 2y agoThe data URI you're using has no MIME type, and even then the data is still an invalid PNG image. Not sure why the Stack Overflow answer is suggesting that.