The communicate method of the subprocess module pipes the stdout of pdflatex to the terminal - i.e. you can see what's going wrong with your. A Python library for creating LaTeX files. pdflatex (only if you want to compile the tex file); NumPy (only if you want to convert it's matrixes). You can start by defining the template tex file as a string: content = r'''\documentclass{article} \begin{document} \textbf{\huge %(school)s  Generating a table of contents in a pdf-latex with python.


Author: Emil Auer
Country: Tokelau
Language: English
Genre: Education
Published: 13 March 2015
Pages: 635
PDF File Size: 8.95 Mb
ePub File Size: 4.69 Mb
ISBN: 940-3-78179-239-5
Downloads: 95140
Price: Free
Uploader: Emil Auer


If there is an error processing the LaTeX, those error messages will show you that the pdf python latex pdflatex not successfully generated. I actually want to run this on an remote server, so I won't be able to view the output.

What I'm doing now is just checking if the pdf was generated.

I tested that TeXLive fully updated and test document showing the https: I tried not enough and fail to test locally with a texlive-xetex from I should try with a VM maybe, Debian won't let python latex pdflatex install packages from on my sid TeXLive whereas with polyglossia-french the earliest xetex python latex pdflatex I could test with success is 0.

But starting with TL, polyglossia-french as the issue https: I don't know how this maps to Debian packaging.


The following python lines produce Latex code which creates Latex variables out of our key-value pairs.

The only thing left is the compiling python latex pdflatex our Tex-code.

Generating pdf-latex with python script - Stack Overflow

We gonna use a system call to run pdflatex. Only the produced pdf is copied back in to the main folder. We are done on the python side.

  • A very simple introduction to using Python in Latex
  • Writing LaTeX with Python
  • LaTeX Expression project
  • Your Answer

The Tex Template A template in Latex is called a class. To start of a class you have to specify your TEX version and your class-name: Furthermore, we load some required package like you would in a usual Latex python latex pdflatex.

See Environment Variables and Setting environment variables in windows for details. A limitation on Windows causes the backend to keep file handles that have been opened by your application open.


As a result, it may not be possible to delete the corresponding python latex pdflatex until the application closes see Sometimes the font rendering in figures that are saved to png images is very bad. This happens when the pdftocairo tool is not available and ghostscript is used for the pdf to png conversion.

Make sure what you are trying to do is possible in a LaTeX document, that your LaTeX python latex pdflatex is valid and that you are using raw strings if necessary to avoid unintended escape sequences.

Other Posts: