Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile defaults to latexmk #114

Merged
merged 11 commits into from
May 2, 2015
57 changes: 28 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Makefile for ThuThesis

# Compiling method: xelatex/pdflatex/dvipdfmx
METHOD = xelatex
# Compiling method: latexmk/xelatex/pdflatex/dvipdfmx
METHOD = latexmk
# Set opts for latexmk if you use it
LATEXMKOPTS = -xelatex
# Basename of thesis
THESISMAIN = main
# Basename of shuji
Expand Down Expand Up @@ -65,6 +67,11 @@ $(PACKAGE).pdf: $(CLSFILES)
pdflatex $(PACKAGE).dtx
pdflatex $(PACKAGE).dtx

else ifeq ($(METHOD),latexmk)

$(PACKAGE).pdf: $(CLSFILES)
latexmk $(LATEXMKOPTS) $(PACKAGE).dtx

else

$(PACKAGE).dvi: $(CLSFILES)
Expand Down Expand Up @@ -106,6 +113,11 @@ $(THESISMAIN).bbl: $(BIBFILE)
-bibtex $(THESISMAIN)
$(RM) $(THESISMAIN).pdf

else ifeq ($(METHOD),latexmk)

$(THESISMAIN).pdf: $(CLSFILES)
latexmk $(LATEXMKOPTS) $(THESISMAIN)

else

$(THESISMAIN).pdf: $(THESISMAIN).dvi
Expand Down Expand Up @@ -135,6 +147,11 @@ else ifeq ($(METHOD),pdflatex)
$(SHUJIMAIN).pdf: $(CLSFILES) $(SHUJICONTENTS)
pdflatex $(SHUJIMAIN).tex

else ifeq ($(METHOD),latexmk)

$(SHUJIMAIN).pdf: $(CLSFILES)
latexmk $(LATEXMKOPTS) $(SHUJIMAIN)

else

$(SHUJIMAIN).dvi: $(CLSFILES) $(SHUJICONTENTS)
Expand All @@ -146,34 +163,16 @@ $(SHUJIMAIN).pdf: $(SHUJIMAIN).dvi

endif

clean:
-@$(RM) \
*~ \
*.aux \
*.bak \
*.bbl \
*.blg \
*.dvi \
*.glo \
*.gls \
*.idx \
*.ilg \
*.ind \
*.ist \
*.log \
*.out \
*.ps \
*.thm \
*.toc \
*.lof \
*.lot \
*.loe \
data$(SLASH)*.aux \
dtx-style.sty

distclean: clean
clean:
latexmk -c $(PACKAGE).dtx $(THESISMAIN) $(SHUJIMAIN)
-@$(RM) $(PACKAGE).dvi $(THESISMAIN).dvi $(SHUJIMAIN).dvi
-@$(RM) *~

cleanall: clean
-@$(RM) $(PACKAGE).pdf $(THESISMAIN).pdf $(SHUJIMAIN).pdf

distclean: cleanall
-@$(RM) $(CLSFILES)
-@$(RM) $(PACKAGE).pdf $(THESISMAIN).pdf $(SHUJI).pdf
-@$(RM) -r dist

dist:
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ThuThesis为 <b>T</b>sing<b>h</b>ua <b>U</b>niversity <b>Thesis</b> LaTeX Templa
# Makefile的用法

make [{all|thesis|shuji|doc|clean|distclean}] \
[METHOD={xelatex|pdflatex|dvipdfmx}] \
[METHOD={latexmk|xelatex|pdflatex|dvipdfmx}] \
[TEXI2DVI=<tex2dvi>]

## 目标
Expand All @@ -48,10 +48,12 @@ ThuThesis为 <b>T</b>sing<b>h</b>ua <b>U</b>niversity <b>Thesis</b> LaTeX Templa
* `make shuji` 生成书脊 shuji.pdf;
* `make doc` 生成使用说明书 thuthesis.pdf;
* `make clean` 删除 pdf 外的所有中间文件和目标文件;
* `make distclean` 表示清除包括 pdf 在内的所有中间文件和目标文件。
* `make cleanall` 删除包括 pdf 在内的所有中间文件和目标文件;
* `make distclean` 表示清除包括 cls 在内的所有中间文件和目标文件。

## 参数
* **METHOD**:指定生成 pdf 的方式,缺省采用 xelatex。
* METHOD=latexmk 表示使用 latexmk 的方式生成 pdf。
* METHOD=xelatex 表示使用 xelatex 引擎编译生成 pdf;
* METHOD=pdflatex 表示使用 pdflatex 引擎编译生成 pdf;
* METHOD=dvipdfmx 表示使用 texi2dvi -> dvipdfmx 的方式生成 pdf。
Expand All @@ -60,4 +62,3 @@ ThuThesis为 <b>T</b>sing<b>h</b>ua <b>U</b>niversity <b>Thesis</b> LaTeX Templa
`texi2dvi`,譬如 CTeX 下的这个工具就叫 `texify`。遇到这种情况可以在命令
行通过 `TEXI2DVI=texify` 命令指定使用其它的 `texi2dvi` 工具。


7 changes: 7 additions & 0 deletions latexmkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# vim: set ft=perl:
$clean_ext = 'thm glo gls bbl';
$makeindex = 'makeindex -s gind.ist %O -o %D %S';
add_cus_dep('glo', 'gls', 0, 'makeglo2gls');
sub makeglo2gls {
system("makeindex -s gglo.ist -o \"$_[0].gls\" \"$_[0].glo\"");
}
23 changes: 17 additions & 6 deletions thuthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
% figures/ & 示例文档图片路径\\
% thutils.sty & 为示例文档加载其它宏包\\\hline
% Makefile & self-explanation\\
% latexmkrc & latexmk 配置文件 \\
% zhfonts.py & 生成中文字体配置文件\\
% README.md & self-explanation\\
% \textbf{thuthesis.pdf} & 用户手册(本文档)\\\hline
Expand Down Expand Up @@ -292,7 +293,6 @@
% $ xelatex thuthesis.dtx % 生成说明文档 thuthesis.pdf
% \end{shell}
%
%
% \subsubsection{xelatex}
% \label{sec:xelatex}
% 很多用户对 \LaTeX{} 命令执行的次数不太清楚,一个基本的原则是多次运行 \LaTeX{}命
Expand Down Expand Up @@ -339,12 +339,21 @@
% 成 PDF。不过 PDF\LaTeX\ 增加了对 png,jpg 等标量图形的支持,比较方便。
% TeX Live 自从 2010 版本起自动调用 epstopdf 将 EPS 图形转化为 PDF。
%
% \subsubsection{latexmk}
% \label{sec:latexmk}
% \texttt{latexmk} 命令支持全自动生成 \LaTeX{} 编写的文档,并且支持使用不同的工具
% 链来进行生成,它会自动运行多次工具直到交叉引用都被解决。下面给出了一个用
% \texttt{latexmk} 调用 \texttt{xelatex} 生成最终文档的示例:
% \begin{shell}
% # 一句话就够了!
% $ latexmk -xelatex main
% \end{shell}
%
% \subsubsection{自动化过程}
% \label{sec:automation}
% 上面的例子只是给出一般情况下的使用方法。虽然命令很简单,但是每次都输入的话还是
% 非常罗嗦的,所以 \thuthesis{} 还提供了一些自动处理的文件。
% 非常罗嗦的,所以 \thuthesis{} 还提供了一个简单的 \file{Makefile}:
%
% 我们提供了一个简单的 \file{Makefile}:
% \begin{shell}
% $ make clean
% $ make cls # 生成 thuthesis.cls 和 thuthesis.cfg
Expand All @@ -353,9 +362,11 @@
% $ make shuji # 生成书脊 shuji.pdf
% \end{shell}
%
% \file{Makefile} 默认采用 Xe\LaTeX\ 编译,可以根据自己的需要修
% 改 \file{Makefile} 开头的参数设置或通过命令行传递参数(请参看 \file{README.md})。
%
% \thuthesis{} 的 Makefile 默认用 \texttt{latexmk} 调用
% \texttt{xelatex} 编译,此外还支持采用 \texttt{xelatex}、\texttt{pdflatex} 和
% \texttt{dvipdfmx} 方式编译,如有需要可以修
% 改 \file{Makefile} 开头的参数设置或通过命令行传递参数(请参看 \file{README.md}),
% 进一步还可以修改 \file{latexmkrc} 进行定制。
%
% \subsection{升级}
% \label{sec:updgrade}
Expand Down