当前位置:  开发笔记 > 编程语言 > 正文

Makefile用于多文件LaTeX文档

如何解决《Makefile用于多文件LaTeX文档》经验,为你挑选了1个好方法。

我正在尝试简化/改进Makefile以编译我的论文.Makefile可以很好地编译整个文件; 我有这样的事情:

show: thesis.pdf
    open thesis.pdf

thesis.pdf: *.tex
    pdflatex --shell-escape thesis

这允许我键入make并检测任何更改(如果有)并在显示之前重新编译.

现在我想将它扩展为有条件地编译单个章节.例如,这允许我编写make xpmt以只有一种方式获得一个章节:

xpmt: ch-xpmt.pdf
    open ch-xpmt.pdf

ch-xpmt.pdf: xpmt.tex
    pdflatex --shell-escape --jobname=ch-xpmt \
      "\includeonly{xpmt}\input{thesis}"

但是我不想为每个章节写下相同的内容.如何以足够的方式编写上述规则以避免重复?

(更多的练习是学习如何编写Makefile而不是解决任何真正的问题;显然在这种情况下复制和粘贴上面的代码实际上很简单!)



1> David Z..:

如果你有一个名为章xpmt(猜测这是"实验"?),并说,thry,anls,conc,或什么:

xmpt thry anls conc: %: ch-%.pdf
    open $<

ch-%.pdf: %.tex
    pdflatex --shell-escape --jobname=ch-$* "\includeonly{$*}\input{thesis}"

或者用make变量做"正确"的方式,我认为它是这样的:

chapters = xmpt thry anls conc
main = thesis
.PHONY: $(chapters) show

show: $(main).pdf
    open $<

$(main).pdf: $(main).tex $(addsuffix .tex,$(chapters))
    pdflatex --shell-escape $(main)

$(chapters): %: ch-%.pdf
    open $<

ch-%.pdf: %.tex
    pdflatex --shell-escape --jobname=ch-$* "\includeonly{$*}\input{$(main)}"

推荐阅读
地之南_816
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有