tex编译成pdf通常要经过以下步骤:tex-->dvi-->ps-->pdf。如果修改了tex文件想看一下效果,就要把命令重新敲一遍。虽然就几行命令,反复敲还是很烦人的。最直接的办法就是把命令写成shell脚本,但是与其写shell就不如写个Makefile。
假设正在编辑的tex文件名为annualplan.tex,Makefile就可以写成下面的样子。其中,VIEWER变量可以改为本地的pdf查看软件。make成功后,可以运行make view查看生成的pdf文件。
BASE = annualplan
TEX = ${BASE}.tex
DVI = ${BASE}.dvi
PS = ${BASE}.ps
PDF = ${BASE}.pdf LOG = ${BASE}.log
AUX = ${BASE}.aux VIEWER = /usr/lib/foxitreader/FoxitReader .PHONY: all clean view all: ${PDF} ${PDF}: ${PS}
ps2pdf $< ${PS}: ${DVI}
dvips $< ${DVI}: ${TEX}
latex $< view:
${VIEWER} ${PDF} clean:
@rm -f ${DVI} ${PS} ${PDF} ${LOG} ${AUX}