使用python多次编译latex

2024-06-16 19:04:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用python使用以下代码编译一个latex文档:

    from pdflatex import PDFLaTeX
    with open(f'{reportFile}', 'w') as f:
        f.write(template.render()
    pdfl = PDFLaTeX.from_texfile(reportFile)
    pdfl.add_args({'-output-directory': "/Users/username/Desktop/"})
    pdfl.create_pdf(keep_pdf_file = True, keep_log_file = False)

代码工作得很好,但问题是为了将我的目录包含在latex文档中,我需要编译latex文件两次。如何使用python编译latex文件两次(或多次)?我曾经读过两篇关于编译latex和在python中使用pdflatex的文章,但是我想不出来。谢谢


Tags: 文件代码from文档importpdfwithopen