Search code examples
pythonpdfpyqtlatex

Way to convert a latex file to pdf only with python? (without having to locally install anything)


I am building a mathematical software with PyQt, and I would like to provide the users with a result in a file written in LaTex and also the compiled version of it in PDF. However, I can't find a way to do so. All solutions I've seen require me to install a compiler locally.

I cannot expect the users to install a compiler in their computers once they have executable version of the software. That is why I am looking for a solution that does not requires my system to have it.

This question is not about displaying mathematical typesetting in Qt, but about generating a document report in LaTex and also a easy way to visualize it in PDF.


Solution

  • LaTeX uses a complex typesetting engine. That's why it's used - a professional grade typesetting engine. Something needs to do that typesetting. One way is to "just" reimplement that engine in python yourself. Maybe you only need a subset of LaTeX. Maybe you can convert the LaTeX syntax into something more simple like markdown and render that to PDF.

    For math typesetting, katex as mentioned in a comment might be an option for you.

    Maybe your use case allows you to make it a client server software architecture and do the compiling on a server. LaTeX.Online has a docker container to create the API

    Others mentioned the traditional way, just package the dependency.

    I cannot expect the users to install a compiler

    That is why you should install it with the rest of your program.

    MiKTeX allows for a silent installation.

    TeX live has similar options