Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate TeX/LaTeX file and compile both in Python

I am preparing a data processing code and the results from these are to be fed to a TeX/LaTeX file and the file is to be compiled by Python (i.e. Python should send the command to compile the TeX/LaTeX file)

At present I plan to generate a text file (with .tex extension) with the necessary syntax for TeX/LaTeX and then call external system command using os.system. Is there any easier way or modules that can do this?


2 Answers

No such Python modules exist but you could try generating text files with the required syntax of the text file with .tex extension and compile it by running system commands with Python:

import os
os.system("pdflatex filename")
like image 113
Tom Kurushingal Avatar answered Oct 30 '25 22:10

Tom Kurushingal


You could use PyLaTeX for this. This is exactly one of the things that it is meant to be used for. https://github.com/JelteF/PyLaTeX

like image 27
JelteF Avatar answered Oct 30 '25 21:10

JelteF



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!