通过从 Git 获取更改的 tex 文件,在 Bash 中自动编译 LaTeX?
Automate LaTeX compilation in Bash by getting changed tex files from Git?
我想将更改后的 Tex 文件从 Git 变量获取到 Bash 变量,以便我可以自动执行更改后的 tex 文件的编译过程。
例子
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Article/main.tex
在从 git.
获取路径后,我想 运行 使用命令 pdflatex Article/main.tex
的脚本
如何将更改后的 Tex 文件从 Git 更改为 Bash 变量以便用 pdflatex 编译它们?
建议
对此有很多选择。我感谢 Lea Gris 在这里致力于解决方案。
备选方案
1.对于单个更改的 Tex 文件,这将完成
pdflatex `git diff --name-only | grep *.tex`
2。对于很多修改过的Tex文件的目录,它们必须有不同的名称,编译后的PDF文件会出现在当前目录下。
git diff --name-only '*.tex' | xargs -l1 pdflatex
3。对于同名的、更改的 Tex 文件,Lea 评论说(还没有让它工作,试图理解它,我选择解释 here)
git diff --name-only '*.tex' | xargs -l1 -I{} sh -c 'cd "${1%/*}"; pdflatex ""' _ {}
固解
4.试试 Latexmk,make 的一个特殊版本,为 LaTeX 做所有的重新编译和重建。而不是 bash,我发现 Python 在不同的系统上更容易使用,例如
import os
Articles =["A","B","C"]
for article in Articles:
#Compiling
os.system("latexmk -pdf -auxdir=tmp "+article)
这里我们使用latexmk进行编译。然后下面显示了如何将脚本与 Makefile 一起使用。
生成文件
all:
python runAboveScript.py
clean:
os.system("rm *.snm")
os.system("rm *.nav")
#Add here everything you want to clean.
更多信息
我想将更改后的 Tex 文件从 Git 变量获取到 Bash 变量,以便我可以自动执行更改后的 tex 文件的编译过程。
例子
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Article/main.tex
在从 git.
获取路径后,我想 运行 使用命令pdflatex Article/main.tex
的脚本
如何将更改后的 Tex 文件从 Git 更改为 Bash 变量以便用 pdflatex 编译它们?
建议
对此有很多选择。我感谢 Lea Gris 在这里致力于解决方案。
备选方案
1.对于单个更改的 Tex 文件,这将完成
pdflatex `git diff --name-only | grep *.tex`
2。对于很多修改过的Tex文件的目录,它们必须有不同的名称,编译后的PDF文件会出现在当前目录下。
git diff --name-only '*.tex' | xargs -l1 pdflatex
3。对于同名的、更改的 Tex 文件,Lea 评论说(还没有让它工作,试图理解它,我选择解释 here)
git diff --name-only '*.tex' | xargs -l1 -I{} sh -c 'cd "${1%/*}"; pdflatex ""' _ {}
固解
4.试试 Latexmk,make 的一个特殊版本,为 LaTeX 做所有的重新编译和重建。而不是 bash,我发现 Python 在不同的系统上更容易使用,例如
import os
Articles =["A","B","C"]
for article in Articles:
#Compiling
os.system("latexmk -pdf -auxdir=tmp "+article)
这里我们使用latexmk进行编译。然后下面显示了如何将脚本与 Makefile 一起使用。
生成文件
all:
python runAboveScript.py
clean:
os.system("rm *.snm")
os.system("rm *.nav")
#Add here everything you want to clean.
更多信息