I'm trying to generate a pdf file using pylatex and pdf latex. I have sections and subsection in my document and I want to create a table of contents like this:
doc.append(NewPage())
doc.append(Command('tableofcontents'))
doc.append(NoEscape(r'\clearpage'))
but after I compile it it generates a blank page with just
Contents
I do not know how can I solve this problem. And this is mt generate command:
doc.generate_pdf(filepath=filepath, compiler=pdflatex_path, clean_tex=True)
In plain $\LaTeX$, you need to run a second pass to get the table of contents. The first pass creates an intermediate file with section headers and their page numbers. Since you are passing
clean_tex=True
, probably this file is being deleted before you can run the second pass.The documentation says that you can install
latexmk
to do this automatically. PyLaTeX will detect and use this.