How to create a thesis template? Take XJTU-thesis as an example

My own thought about create a thesis template.

Template

Goal

Mandatory

  1. Fulfill requirements of the administration office.
  2. Seperate contents from its format.
  3. Available on different OS.

Optional

  1. Easy to use and to modify.

Structure

Thus, a thesis template can be divided into two parts, formats and content, configurations about format should be extracted into options selected in the document, or not even shown in document, therefore, format configurations go to .cls, .bst and others.

To make project more clean, content have many types, texts, codes, figures, biblography database and others. A thesis project structure can be described as:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|= proj/
| |= Codes/
| | |- ...
| |= Figures/
| | |- ...
| |= Main_Miscellaneous/
| | |- misc.tex
| | |- ...
| |= Main_Spine/
| | |- body.tex
| | |- ...
| |= Materials/
| | |= BiblographyStyles/
| | | |- bst.bst
| | |= Fonts/
| | | |- ...
| |= References/
| | |- reference.bib
| | |- ...
| |- latexmkrc
| |- main.tex
| |- README
| |- thesis.cls
| |- ...

Content

The contet of thesis has two type: variable and invariable, invariable content like some words in cover, headings, declarations and so on, conventional or bad template cannot extract these out of format, it’s not good.

The content of mani.tex can be described as:

1
2
3
4
5
6
7
8
9
|- options of document class
|- variables
|- content
| |- cover
| |- abstract
| |- table of contents
| |- body
| |- reference
| |- ...

Each content except body should be put in an isolated file, in or not in a environment:

1
2
3
|- \begin{environment}
|- ...
|- \end{environment}

Format

All formats are written in thesis.cls, I think this file can be divided into these parts:

PARTS USAGE
BASIC for document class information, options…
UTILITIES import some basic packages
MATH & SYMBOLS -
PAGES & GEOMETRY -
FONTS -
VARIABLES title, author, date and …
ENVIRONMENTS float, algorithm, theorem, footnote, heading …
COMPONETS cover, abstract, table of contents, glossary, reference …

XJTU-thesis

Committee members

committee members can be added by sequence, and saved into a list, then display them in a page.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
\ExplSyntaxOn
% create a sequence to save members
\seq_new:N \g_defense_committee_seq
\seq_clear:N \g_defense_committee_seq
\NewDocumentCommand \addcommitteemember {m}{
\seq_set_split:Nnn \l_tmpa_seq {,} {#1}
\clist_set_from_seq:NN \l_tmpb_clist \l_tmpa_seq
\seq_gput_right:Nx \g_defense_committee_seq \l_tmpb_clist
}

\tl_set:Nn \g_dc_tabular_tl {\sanhao}

% commands to set width and height of a box
\box_new:N \l_bp_set_to_box
\cs_new_protected:Npn \bp_box_set_to:NNn #1 #2 #3
{
\hbox_set:Nn \l_bp_set_to_box {#3}
\dim_set:Nn #2 { #1 \l_bp_set_to_box }
\box_set_eq:NN \l_bp_set_to_box \c_empty_box
}
\cs_new_protected:Npn \bp_set_to_height:Nn { \bp_box_set_to:NNn \box_ht:N }
\cs_new_protected:Npn \bp_set_to_depth:Nn { \bp_box_set_to:NNn \box_dp:N }
\cs_new_protected:Npn \bp_set_to_width:Nn { \bp_box_set_to:NNn \box_wd:N }
\cs_new:Npn \WidthOfSpace { \tex_fontdimen:D 2 \tex_font:D }

% generate token list of committe list
\NewDocumentCommand \gencommitteelist {}{
\fp_new:N \l_moriambar_ratio_fp
\seq_gpop_left:NN \g_defense_committee_seq \l_dcc_tl

\dim_new:N \spaceWidth
\bp_set_to_width:Nn \spaceWidth {\clist_item:Nn \l_dcc_tl 1}

\tl_gput_right:Nn \g_dc_tabular_tl {{\clist_item:Nn \l_dcc_tl 1 \clist_item:Nn \l_dcc_tl 3}:&\sanhao\underline{\parbox[t]{10em}{\clist_item:Nn \l_dcc_tl 2}}\xiaowu(注:主席)\\}

\seq_map_variable:NNn \g_defense_committee_seq \i {
\bp_set_to_width:Nn \spaceWidth {\clist_item:Nn \i 2}
\tl_gput_right:Nn \g_dc_tabular_tl {\sanhao}
\tl_gput_right:Nx \g_dc_tabular_tl {{\clist_item:Nn \i 1 \clist_item:Nn \i 3}:&}
\tl_gput_right:Nn \g_dc_tabular_tl {\sanhao}
\tl_gput_right:Nx \g_dc_tabular_tl {\underline{\exp_not:N \parbox[t]{10em}{\clist_item:Nn \i 2} }\\}
}
}
\NewDocumentCommand \defencecommittelist {}{
\tl_use:N \g_dc_tabular_tl
}
\ExplSyntaxOff

% Page
\renewcommand{\thesiscommittes}{
\gencommitteelist
\thispagestyle{empty}
\ifthesis@english
\pdfbookmark{Defense Committee}{Defense Committee}
\else
\pdfbookmark{答辩委员会}{Defense Committee-zh}
\fi
\parbox[t][5mm][t]{\textwidth}{}
\begin{center}
\sanhao \bfseries \chinesedegreename 学位论文答辩委员会
\end{center}
\vspace{2\baselineskip}
\begin{spacing}{2.0}\begin{center}
\sanhao \bfseries \zh@thetitle
\end{center}\end{spacing}
\vfill
\begin{center}
\renewcommand{\arraystretch}{2.5}
\begin{tabular}{rl}
\multicolumn{1}{l}{\sanhao 答辩人:\zh@theauthor}&\\
\multicolumn{1}{l}{\sanhao 答辩委员会委员:}&\\
\defencecommittelist
\multicolumn{1}{l}{\sanhao 答辩时间:\zh@thedefensedate}&\\
\multicolumn{2}{l}{\sanhao 答辩地点:\zh@thedefenseloc}\\
\end{tabular}
\renewcommand{\arraystretch}{1}
\end{center}
\cleardoublepage
}