Skip to content

Commit

Permalink
Merge bachelor, master and doctor thesis templates into one.
Browse files Browse the repository at this point in the history
  • Loading branch information
weijianwen committed Jan 7, 2016
1 parent 9755762 commit 64df853
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 423 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 3 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
VERSION := 0.5.3

vpath test

# Basename of thesis
THESIS = thesis
# Test file
TESTFILE = temptest
# TEX, BIB, TEST dir
TEX_DIR = tex
BIB_DIR = bib
TEST_DIR = test

# Option for latexmk
LATEXMK_OPT = -xelatex -gg -silent -f

all: $(THESIS).pdf

.PHONY : all clean version cleantest release cleanall
.PHONY : all clean version release cleanall

$(THESIS).pdf : $(THESIS).tex $(TEX_DIR)/*.tex $(BIB_DIR)/*.bib *.cls *.cfg Makefile
-latexmk $(LATEXMK_OPT) $(THESIS)
Expand All @@ -28,22 +20,12 @@ clean :
cleanall : clean
-rm -f $(THESIS).pdf

test : $(TESTFILE).pdf
test : $(THESIS).pdf
reattach-to-user-namespace open $^

$(TESTFILE).pdf : test/$(TESTFILE).tex Makefile
cd $(TEST_DIR) && latexmk $(LATEXMK_OPT) $(TESTFILE)

cleantest :
cd $(TEST_DIR) && latexmk -C

release :
@$(SED) -i "s/templateversion{v.*}/templateversion{v$(VERSION)}/g" sjtuthesis.cfg
@$(SED) -i "s/bachelor-.*zip/bachelor-$(VERSION).zip/g" $(TEX_DIR)/chapter01.tex
@$(SED) -i "s/master-.*zip/master-$(VERSION).zip/g" $(TEX_DIR)/chapter01.tex
@$(SED) -i "s/phd-.*zip/phd-$(VERSION).zip/g" $(TEX_DIR)/chapter01.tex
cp $(THESIS).pdf HOWTO.pdf
@echo "Release $(VERSION)"

git :
git push gitlab
git push github
Expand Down
111 changes: 31 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,98 +1,49 @@
SJTU XeTeX-LaTeX Thesis Template
What is SJTUThesis?
======

What's this?
-------
SJTUThesis is an *unofficial* XeLaTeX template for preparing bachelor, master, or doctor thesis in Shanghai Jiao Tong University.

This is (Xe)LaTeX template for thesis of Shanghai Jiaotong University. Currently, templates for bachelor, master, and Ph.D thesis are released in three different branches separately. You can download the zip packages from the following links.
上海交通大学学位论文模板
======

* [SJTU Bachelor Thesis Template Download](https://github.com/weijianwen/sjtu-thesis-template-latex/archive/bachelor-thesis.zip)
* [SJTU Master Thesis Template Download](https://github.com/weijianwen/sjtu-thesis-template-latex/archive/master-thesis.zip)
* [SJTU Ph.D Thesis Template Download](https://github.com/weijianwen/sjtu-thesis-template-latex/archive/phd-thesis.zip)
这是为撰写上海交通大学学士、硕士或博士论文而准备的XeLaTeX模板,非官方出品。

The original version of this template dated back about two years ago, when CJK-latex was still the most prevalent solution for TeX/LaTeX to handle CJK (Chinese, Japanese, Korean) characters. A nice guy at the school of physics, SJTU, made a LaTeX template for Ph.D thesis and posted on SJTU's [BBS](https://bbs.sjtu.edu.cn/bbsdoc?board=TeX_LaTeX). I followed his steps, added some refinement and documentations, and made the template more accessible for general people.
如何使用?
=======

In the *CJK-latex* age, one of the intimidating things for LaTeX newbie was setting up a usable Chinese LaTeX environment. It took me quite a long time to figure out how those things, such *latex, dvipdfmx, pdflatex, bibtex, dvips, et al.* worked together and shared my experiences on BBS board. However, most of my time had been spent on struggling with the CJK issues and solving wired problems, which, at most time, were caused by not following the steps exactly. That mess-up situation made me kind of frustrated, because little improvement towards the template required much much more verification and adjustment. I called it *CJK package hell*.
系统需求
-------

Therefore, I took no hesitation to switch the template to XeTeX/XeLaTeX when XeTeX seemed mature enough. It had been a really wise decision. With the help of other warm-hearted guys, SJTU thesis templates were ported to XeTeX and released during the days when lots of master candidates were fighting with their thesis. Though the SJTU XeTeX-based template had never become a hot topic of any kind, being helpful to others, I think, had been the most valuable reward for me. I really appreciated all the guys who used the template and send back their feedback.
* 支持XeTeX的TeX发行版。经过测试, 2013年以后发行的CTeX、TeXLive和MacTeX都能编译此文档。
* 系统中安装了TeX Gyre Font和四款Adobe中文字体:AdobeSongStd、AdobeKaitiStd、AdobeHeitiStd、AdobeFangsongStd。

I used this template to finish my master thesis, and decided to make the template *code-freeze*. Being XeTeX-based is the current state of the template and still works well. I made a last commit to the template one year ago, giving a stop at that time.
编译模板
-------

But, I think the template is still in a *primitive* state, far from a *generally-nice* work. As my understanding about TeX, Git, document preparing grows, I think it's time to refresh the template. GitHub is a place full of all kinds of geniuses, thus I host my project here in hope for receiving all kinds of refinement or feedback.
$ make clean all

TODO
查阅说明文档
------
* 把学士学位论文模板合并到主干。
* 用中文重写这份README。

项目自带的HOWTO.pdf提供了更详细的使用说明。

反馈问题
=======

建议以如下的顺序反馈使用问题:

* [在github项目主页开issue](https://github.com/weijianwen/sjtu-thesis-template-latex/issues)
* [在水源BBS TeX_LaTeX版发帖](https://bbs.sjtu.edu.cn/bbsdoc?board=TeX_LaTeX)

后续工作计划
=======
* 使用良好的"LaTeX代码风格"改写文档源代码
* 使用 \command{body} 形式调用命令,避免无括号、等号指定;
* 避免在模板中使用 plain TeX 代码;
* 模板和模板讲解分开——模板使用说明放在idx中,模板文件留几个空壳就可以,方便大家填入内容,也能保持模板核心内容简洁。
* Replace bibtex with biber。
* 使用```biber```模块替代```bibtex```处理参考文献。

How to use it?
------

### Prerequisites

* A usable XeTeX/XeLaTeX instance. The latest [CTeX], [TeXLive] and [MacTeX] are OK.
* [TeX Gyre Font] collection which are used as main ASCII fonts.
* Some available Chinese fonts.

### Compile the sample document

Type the following commands and a file named ```diss.pdf``` will be generated.

$ cd $YOUR_WORK_DIR
$ xelatex -no-pdf --interaction=nonstopmode diss
$ bibtex diss
$ xelatex -no-pdf --interaction=nonstopmode diss
$ xelatex --interaction=nonstopmode diss

Or, you can use the GNUMake tool.

$ make && make view

A [HOWTO.pdf] is shipped with the project, which explains the usage further.

# How to contribute?

Contributions toward this project include, but *not limited* to the following work.

* Use the template and report an [issue] when encountering problems.
* Fork and refine the documents (README, Wiki, et al.).
* Fork and refine the template according to the tasks listed in *TODO*.
* Tell other guys the ```SJTU-XeLaTeX-Template``` is hosted here on github.

# FAQs and not-so-FAQs

Q: Is this template "official"?

A: No. SJTU has not yet released its official TeX template for composing thesis. We make this template according to the officially-stated layout requirements and add some refinements because of aesthetic consideration.

Q: Is thesis in ```PDF``` formats suitable for submitting?

A: Absolutely yes. ```PDF``` is portable file format, and your PDF documents will look exactly the same as the hard-copy ones no matter what applications are used for viewing. It is totally unreasonable not accepting a PDF-formated thesis. The fact, as far as I know, is that, the SJTU library happily accepts all PDF thesis.

Q: @farseerfc hosts a project named [sjtu-thesis-xelatex] on github. Is this the same thing?

A: Hmm... Let me explain. @farseerfc's code was based on my template and adapted to bachelor-thesis format. I really appreciate his contributions and hope to merge his changes into my repo if possible (not now but in the future). However, due to strong personality, I keep in mind that the git repo for SJTU-XeTeX-template should be in 100% control of mine and progresses exactly in the pace I set. Therefore, I create this repo along with the tasks listed in TODO. These tasks should differentiate my repo from other similar projects.

# See more
[README.pdf]: https://raw.github.com/weijianwen/sjtu-thesis-template-latex/master/README.pdf
[CTeX]: http://www.ctex.org/
[TeXLive]: http://www.tug.org/texlive/
[MacTeX]: http://tug.org/mactex/
[TeX Gyre Font]: http://www.gust.org.pl/projects/e-foundry/tex-gyre/
[LATEX Notes]: http://math.nju.edu.cn/~meijq/tex/lnotes.pdf
[XeTeX/中文排版之胡言乱语]: http://goo.gl/oRNcW
[Biber: A BibTeX replacement for users of BibLaTeX]: http://biblatex-biber.sourceforge.net/

# Update History
* Last update: May 26, 2013
* Dec 27, 2012. v0.5.2 is released. Fix typos.
* Dec 5, 2012. v0.5 is released. Add Makefile; refine the manual (README.pdf); replace xltxtra pacakge with metalog; replace amsmath package with mathtools.
* May 30, 2012. v0.4 is released. Reopen this project. Add README.
* Jan 23, 2011. Finish my master thesis. Code freeze.
开源许可证
======

[MIT License](LICENSE)
100 changes: 62 additions & 38 deletions sjtuthesis.cls
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
%%==================================================

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{sjtuthesis}[2014/12/16 v0.9 Shanghai Jiao Tong University Template]
% _DEPLICATE_ \newif\ifsjtu@typeinfo \sjtu@typeinfotrue
% _DEPLICATE_ \DeclareOption{notypeinfo}{\sjtu@typeinfofalse}
\def\version{v0.5.3}
\ProvidesClass{sjtuthesis}[2014/12/16 v0.6 Shanghai Jiao Tong University Template]
\def\version{v0.6}
\newif\ifsjtu@bachelor\sjtu@bachelorfalse
\newif\ifsjtu@master\sjtu@masterfalse
\newif\ifsjtu@doctor\sjtu@doctorfalse
\DeclareOption{bachelor}{\sjtu@bachelortrue}
\DeclareOption{master}{\sjtu@mastertrue}
\DeclareOption{doctor}{\sjtu@doctortrue}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ProcessOptions
\LoadClass[a4paper,fancyhdr,fntef,UTF8,adobefonts]{ctexbook}
\ProcessOptions\relax
\LoadClass[a4paper,fancyhdr,fntef,UTF8]{ctexbook}
\ifsjtu@bachelor\relax\else
\ifsjtu@master\relax\else
\ifsjtu@doctor\relax\else
Expand All @@ -41,7 +39,6 @@
%==========

%% 导入 sjtuthesis.cfg 文件
% _DEPLICATE_ \AtEndOfPackage{\makeatletter\input{sjtuthesis.cfg}\makeatother}
\AtEndOfClass{\input{sjtuthesis.cfg}}


Expand All @@ -50,6 +47,7 @@
%==========

\RequirePackage{ifthen}
\RequirePackage{lastpage}
\RequirePackage{fontspec}
\RequirePackage{metalogo}
\RequirePackage{threeparttable}
Expand Down Expand Up @@ -95,7 +93,7 @@
\newcommand\myLongEqual[2][]{\ExtendSymbol{=}{=}{=}{#1}{#2}}

\def\cleardoublepage{\clearpage%
\if@twoside%
\if@openright%
\ifodd
\c@page%
\else%
Expand Down Expand Up @@ -128,7 +126,7 @@
\headheight 15pt
\parskip 0.5ex plus 0.25ex minus 0.25ex
\addtolength{\voffset}{-0.5cm} %% 上边距
\if@twoside
\if@openright
\evensidemargin 0 true cm
\else
\evensidemargin 1.5 true cm
Expand Down Expand Up @@ -277,11 +275,10 @@
\end{center}
\vskip \stretch{0.5}
\clearpage
\if@twoside
% _DEPLICATE_ \thispagestyle{empty}
% _DEPLICATE_ \ifsjtu@typeinfo
% _DEPLICATE_ \fi
\if@openright
\cleardoublepage
\else
\clearpage
\fi
}

Expand Down Expand Up @@ -317,7 +314,7 @@
\vskip 20pt
\end{center}
\clearpage
\if@twoside
\if@openright
\thispagestyle{empty}
\cleardoublepage
\fi
Expand All @@ -338,7 +335,7 @@
\vskip 15pt
\hspace{16em}\sjtu@label@originalDate\hspace{1em}
\clearpage
\if@twoside
\if@openright
\thispagestyle{empty}
\cleardoublepage
\fi
Expand All @@ -361,32 +358,63 @@
\vskip 15pt
\sjtu@label@originalDate\hfill\hspace{3em}\sjtu@label@originalDate
\clearpage
\if@twoside
\if@openright
\thispagestyle{empty}
\cleardoublepage
\fi
}

\pagestyle{fancy} {
\fancyhf{}
\fancyhead[LO, RE]{\small {\it \sjtu@value@school\sjtu@value@degree\sjtu@label@thesis}} % 奇数页左页眉和偶数页右页眉,即靠近书籍的页眉
\fancyhead[RO]{\small {\it \leftmark}} % 奇数页右页眉
\fancyhead[LE]{\small {\it \sjtu@value@titlemark}} % 偶数页左页眉
\fancyfoot[C]{\small ~---~{\bf\thepage}~---~} % 页脚
}
% 根据学位论文类型、单双面打印设置页眉页脚类型
\pagestyle{fancy}
\fancyhf{}

\ifsjtu@bachelor
% 本科学位论文正文页眉页脚
\fancyhead[LO, RE]{\small {\it \includegraphics[width=0.22\textwidth]{sjtubanner}}}
\fancyhead[RO, LE]{\small {\it \sjtu@value@titlemark}}
\fancyfoot[C]{\small{}第~{\bf\thepage}~页\,{}共~{\bf\pageref{LastPage}}~页}
% 本科学位论文开章页页眉页脚,双面打印时只是交换左右页眉
\fancypagestyle{plain}{% 设置开章页页眉页脚风格(只有页码作为页脚)
\fancyhf{}%
\fancyhead[L]{\small {\it \includegraphics[width=0.22\textwidth]{sjtubanner}}}
\fancyhead[R]{\small {\it \sjtu@value@titlemark}}
\fancyfoot[C]{\small{}第~{\bf\thepage}~页\,{}共~{\bf\pageref{LastPage}}~页}
}
\else
% 研究生学位论文正文页眉页脚,针对openright和openany单独设置
\if@openright
\fancyhead[LO, RE]{\small {\it\sjtu@value@school\sjtu@value@degree\sjtu@label@thesis}}
\fancyhead[RO]{\small {\it\leftmark}}
\fancyhead[LE]{\small {\it\sjtu@value@titlemark}}
\fancyfoot[C]{\small ---~{\bf\thepage}~---}
% 研究生学位论文开章页页眉页脚
\fancypagestyle{plain} {
\fancyhf{}
\fancyhead[LO,RE]{\small {\it\sjtu@value@school\sjtu@value@degree\sjtu@label@thesis}}
\fancyhead[RO]{\small {\it\leftmark}}
\fancyhead[LE]{\small {\it\sjtu@value@titlemark}}
\fancyfoot[C]{\small ---~{\bf\thepage}~---}
}
\else
\fancyhead[L]{\small {\it\sjtu@value@school\sjtu@value@degree\sjtu@label@thesis}}
\fancyhead[R]{\small {\it\leftmark}}
\fancyfoot[C]{\small ---~{\bf\thepage}~---}
% 研究生学位论文开章页页眉页脚
\fancypagestyle{plain} {
\fancyhf{}
\fancyhead[L]{\small {\it\sjtu@value@school\sjtu@value@degree\sjtu@label@thesis}}
\fancyhead[R]{\small {\it\leftmark}}
% \fancyhead[L]{\small {\it\sjtu@value@titlemark}}
\fancyfoot[C]{\small ---~{\bf\thepage}~---}
}
\fi
\fi

\fancypagestyle{plain} { % 设置开章页页眉页脚风格
\fancyhf{}
\fancyhead[LO,RE]{\small {\it \sjtu@value@school\sjtu@value@degree\sjtu@label@thesis}} % 奇数页左页眉和偶数页右页眉,即靠近书籍的页眉
\fancyhead[RO]{\small {\it \leftmark}} % 奇数页右页眉
\fancyhead[LE]{\small {\it \sjtu@value@titlemark}} % 偶数页左页眉
\fancyfoot[C]{\small ~---~{\bf\thepage}~---~} %页脚格式
}

\newenvironment{abstract}{\chapter[摘要]{\sjtu@value@title\vskip 20pt\sjtu@label@abstract}}{}
% 中英文摘要
\newenvironment{abstract}{\chapter[\sjtu@label@abstract]{\sjtu@value@title\vskip 20pt\sjtu@label@abstract}}{}
\newcommand\keywords[1]{\vspace{2ex}\noindent{\bf\large \sjtu@label@keywords} #1}

\newenvironment{englishabstract}{\chapter[ABSTRACT]{\sjtu@value@englishtitle\vskip 20pt\bfseries \sjtu@label@englishabstract}}{}
\newenvironment{englishabstract}{\chapter[\sjtu@label@englishabstract]{\sjtu@value@englishtitle\vskip 20pt\bfseries \sjtu@label@englishabstract}}{}
\newcommand\englishkeywords[1]{\vspace{2ex}\noindent{\bf\large \sjtu@label@englishkeywords} #1}

\renewcommand\tableofcontents{%
Expand Down Expand Up @@ -485,15 +513,11 @@
{\chapter{\sjtu@label@thanks}}
{}

\newenvironment{symbolnote}
{\chapter{\sjtu@label@symbolnote}}
{}

\newenvironment{symbolnote}{\chapter{\sjtu@label@symbolnote}}{}

\setcounter{secnumdepth}{4} % 章节编号深度 (part 对应 -1)
\setcounter{tocdepth}{2} % 目录深度 (part 对应 -1)


\newtheoremstyle{break}% name
{}% Space above, empty = `usual value'
{}% Space below
Expand Down
Loading

0 comments on commit 64df853

Please sign in to comment.