d0c-s4vage / lookatme

An interactive, terminal-based markdown presenter
https://lookatme.readthedocs.io/en/latest/
MIT License
2.08k stars 61 forks source link

LaTeX Math Equation Rendering. #137

Open CobSammich opened 2 years ago

CobSammich commented 2 years ago

LaTeX Math Equation Rendering

I'm curious if rendering LaTeX math equations in lookatme has been considered or looked into at all. Currently a way around this is to generate an image of a math equation and just include that, but writing the math equations within the slides themselves would be far easier.

I tried searching the lookatme contrib extensions, but saw nothing related.

Screenshot Basically suggesting something like this: math_slide

Additional notes If this hasn't been looked into, I could take a crack at implementing it and submitting a pull request or making it as it's own extension -- let me know.

StefanGreve commented 2 years ago

In case you didn't know it's possible to render LaTeX equations with sympy in the terminal: https://docs.sympy.org/latest/tutorial/printing.html

But the output doesn't look very appealing if you limit yourself to ASCII, and even with unicode support it barely looks okay (in my opinion). Something that compiles LaTeX code to transparent PNG images would be nice.

krishnakumarg1984 commented 1 year ago

The easiest way to get this functionality would be to add pre-processing support, like how slides has. See here.

Specifically, something like this:

~~~tex2mail ...
\frac{1}{2} = \sqrt{2}x
~~~

where the line ~~~tex2mail ... block indicates that the content inside the block (until the closing ~~~) shall be replaced by the text printed to stdout by executing the command written on that line (in this example tex2mail). This feature is further explained in detail with video/animations in this issue .

It would be nice if we can add generic pre-processing support in.

Then, for this particular maths rendering issue, we can use tex2mail or the modern latex-to-uncode tool utftex , which looks so much better. image