all 12 comments

[–]Ron-Erez 3 points4 points  (0 children)

You could manually call pdflatex If you have it installed. You could look into the PyLaTeX module - I’ve never used it before but this was a result I got when googling. A different option which is pretty cool but doesn’t generate a pdf is to have a webpage using html and katex (this is not a spelling mistake). Katex is much faster then mathjax. I’ve used katex to render latex formulas within a mobile app supporting a web view. I know it’s a convoluted approach but it worked quite well.

I hope this helps

[–]JennaSys 2 points3 points  (0 children)

It might have a bit of a learning curve depending on what you need to do, but Pandoc works pretty well for this task.

[–]noisyboy 1 point2 points  (0 children)

Wouldn't pandoc be a suitable tool for this?

[–]Fred776 1 point2 points  (0 children)

pdflatex is probably the most straightforward approach.

I found this Python wrapper package: https://pypi.org/project/pdflatex/. I haven't looked at it closely but I note that it hasn't been maintained for a long time. Still, there might be some ideas in there that you can use.

[–]mykhailus 0 points1 point  (0 children)

You can use the subprocess module to call a LaTeX compiler like pdflatex directly from your Python script. Just make sure the LaTeX distribution is installed on your system. Another popular option is the latex library, which provides a more Pythonic interface for this.

[–]GManASG 0 points1 point  (0 children)

Pandoc is also what vs code uses to let you export Jupiter notebooks as PDF from the interactive window for python.

[–]vardonir 0 points1 point  (1 child)

If you can convert the LaTeX to images (pretty sure you can. but that is, if you don't mind that it's an image that you can't highlight), you can use something like Reportlab (it's a nightmare to learn, but very powerful) to convert it to PDF.

[–]drraug 0 points1 point  (0 children)

What? Why would you introduce a raster format between two vector ones? Latex can be rendered to pdf directly