[英]Compile a whole Folder with tex files using python
how to compile a folder which content of latex files.如何编译一个包含latex个文件内容的文件夹。 I would try to use python to compile the whole folder.
我会尝试使用 python 来编译整个文件夹。
In the past I use the Terminal to compile the folders过去我使用终端来编译文件夹
for i in *.tex; do pdflatex $i;done
but I rather use Python但我宁愿使用 Python
I don't know of any good pdflatex bindings in python, but you could just use subprocess.我不知道 python 中有什么好的 pdflatex 绑定,但你可以只使用子进程。
import subprocess
import glob
for path in glob.iglob('*.tex'):
subprocess.run(['pdflatex', path])
If you want to be able to use this from the command line and pass any directory path to it, you can do something like for path in glob.iglob(os.path.join(sys.argv[1], '*.tex')):
instead.如果您希望能够从命令行使用它并将任何目录路径传递给它,您可以执行类似
for path in glob.iglob(os.path.join(sys.argv[1], '*.tex')):
相反。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.