I am able to use python script to create a LaTeX file, but I want to take that file and compile it, so it creates a pdf by using a python script. I have seen some things using os and subprocess but I really don't understand it.
PyLaTeX is a Python library for creating and compiling LaTeX files. The goal of this library is to be an easy, but extensible interface between Python and LaTeX.
In order to compile a LaTeX file, simply press \ll while editing the file. This runs latex on the current file and displays the errors in a |quickfix-window| below the file being edited.
Select the "Editor" tab and check the "Line numbers" box. Click OK. Now at the top of TeXworks you will see a green button. This is the "Compile" button.
In TeXShop, go to the Typeset menu bar, make sure the LaTeX option is checked, and select Typeset, or simply press Command+T. TeXShop will now try to compile your document. If everything is installed correctly, a compiled PDF document will pop up which says, “Congratulations!
Try this out.
import os
os.system("pdflatex mylatex.tex")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With