-
Notifications
You must be signed in to change notification settings - Fork 113
/
makethesis
executable file
·176 lines (173 loc) · 6.12 KB
/
makethesis
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
# --------------------------------------------------------------------------
# Filename: makethesis
# Author: Xianling Wang <rioxwang@foxmail.com>
# Created: 2013-07-08
# Modified: 2015-01-02
# Version: 1.4
# --------------------------------------------------------------------------
# Change Log
# v1.0: Batch file created.
# 1. 'clean', 'install' and 'thesis' functions are defined.
# 2. 'xetex' engine w/o chapbib are defined.
# v1.1: File mode modified, function added.
# 1. Change the dos-style line break into unix-style line break: <CR><LF> -> <LF>.
# 2. 'wordcount' function is defined.
# v1.4: Modify output redirecting.
# --------------------------------------------------------------------------
# User Configuration
# Project name
PROJECT="buptgraduatethesis"
# File name of your top-level tex file.
TARGET="bare_thesis"
# File name list of tex files for mainmatters.
MAINMATTERS=("ch_intro" "ch_concln")
# Driver type to build PDF.
# 'xetex' for xetex engine;
DRIVER="xetex"
# Bib type to construct bibliography.
# 'chapbib' for bib per chapter; 'allbib' for bib in thesis end.
BIBTYPE="chapbib"
# --------------------------------------------------------------------------
# Function: Clearance
# TMP File Clearance
function clean()
{
echo Clearing TMP files...
echo Clearing TMP files in installation...
rm -f *.dvi *.ps > /dev/null
echo Clearing TMP files in thesis generation...
rm -f *.bbl *.blg *.aux *.log *.acn *.glo *.ist *.acr *.alg *.out *.toc *.thm *.ps *.dvi > /dev/null
echo ===========================================
echo = Mission Done!
echo = ALL TMP files are cleared!
echo ===========================================
exit
}
# --------------------------------------------------------------------------
# Function: Wordcount
# Word Count
function wordcount()
{
echo Counting word...
texcount -ch -inc -incbib -html -v -sum bare_thesis.tex > wordcount.html
echo ===========================================
echo = Counting Mission Done!
echo = Word-counting Results are recorded in 'wordcount.html'!
echo ===========================================
exit
}
# --------------------------------------------------------------------------
# Function: Making Thesis PDF
# Thesis PDF Generation
function thesis()
{
# Check the user input configuration.
echo ===========================================
echo =
echo = TARGET=${TARGET}
echo = MAINMATTERS=${MAINMATTERS[@]}
echo = DRIVER=${DRIVER}
echo = BIBTYPE=${BIBTYPE}
echo =
echo ===========================================
echo Double check above configurations! Press anykey to continue, CTRL+C to stop!
read -n1
# Check the integrity of the installation.
echo Checking Existence of Essential Files...
if [ -f "${PROJECT}.cls" -a -f "${PROJECT}.cfg" -a -f "${PROJECT}.bst" ]; then
echo Document class installed! Generating Thesis PDF...
else
echo ===========================================
echo = Mission Failed!
echo = Cannot find essential files!
echo = Please './makethesis install' to reinstall BUPTGraduateThesis!
echo ===========================================
exit
fi
# Generate the thesis PDF according to different configurations.
if [ ${DRIVER} = "xetex" ]; then
echo Building thesis PDF...
xelatex ${TARGET}
echo Processing BIB files...
if [ ${BIBTYPE} = "chapbib" ]; then
for MATTER in ${MAINMATTERS[@]}
do
bibtex ${MATTER} > /dev/null
done
else
bibtex ${TARGET} > /dev/null
fi
bibtex jrnl.aux > /dev/null
bibtex conf.aux > /dev/null
bibtex patent.aux > /dev/null
echo Processing index files...
makeindex -s ${TARGET}.ist -t ${TARGET}.alg -o ${TARGET}.acr ${TARGET}.acn > /dev/null
echo Rebuilding to generate cross-reference...
xelatex ${TARGET} > /dev/null
xelatex ${TARGET} > /dev/null
else
echo Engine Undefined!
exit
fi
echo ===========================================
echo = Mission Done!
echo = Thesis PDF is successfully generated!
echo ===========================================
exit
}
# --------------------------------------------------------------------------
# Function: Installation
# Document Class and Help PDF File Generation
function install()
{
mkdir example
echo Extracting and installing files...
xetex install/${PROJECT}.ins
echo Building user guide...
xelatex -no-pdf install/${PROJECT}.dtx
makeindex -q -s gglo.ist -o ${PROJECT}.gls ${PROJECT}.glo
echo Rebuilding to generate change-log...
xelatex -no-pdf install/${PROJECT}.dtx > /dev/null
makeindex -q -s gglo.ist -o ${PROJECT}.gls ${PROJECT}.glo > /dev/null
echo Rebuilding to generate cross-reference...
xelatex install/${PROJECT}.dtx
echo Clearing TMP files...
rm -f ${PROJECT}.aux ${PROJECT}.glo ${PROJECT}.ilg ${PROJECT}.ind
rm -f ${PROJECT}.out ${PROJECT}.toc ${PROJECT}.idx ${PROJECT}.hd ${PROJECT}.xdv ${PROJECT}.gls
echo ===========================================
echo = Mission Done!
echo = BUPTGraduateThesis is successfully installed!
echo ===========================================
exit
}
# --------------------------------------------------------------------------
# Main Function Selection
# Default Selection: thesis
if [ "$#" = 1 ]; then
if [ "$1" = "install" ]; then
install
elif [ "$1" = "thesis" ]; then
thesis
elif [ "$1" = "clean" ]; then
clean
elif [ "$1" = "wordcount" ]; then
wordcount
else
echo ===========================================
echo = Undefined Parameter!
echo ===========================================
fi
elif [ "$#" = 0 ]; then
thesis
else
echo ===========================================
echo = Input Parameter Error!
echo = You should input at most 1 parameter:
echo = install
echo = thesis
echo = clean
echo = or leave it blank for default!
echo ===========================================
fi
# EOF