-
Notifications
You must be signed in to change notification settings - Fork 113
/
makethesis.bat
executable file
·167 lines (161 loc) · 6.09 KB
/
makethesis.bat
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
@echo off
REM --------------------------------------------------------------------------
REM Filename: makethesis.bat
REM Author: Xianling Wang <[email protected]>
REM Created: 2013-07-08
REM Modified: 2015-01-02
REM Version: 1.4
REM --------------------------------------------------------------------------
REM Change Log
REM v1.0: Batch file created.
REM 1. 'clean', 'install' and 'thesis' functions are defined.
REM 2. 'xetex' engine w/o chapbib are defined.
REM v1.1: Function added.
REM 1. 'wordcount' function is defined.
REM v1.2: Batch file BUG fixed.
REM 1. 'example' folder should be existed in TeXLive release.
REM 2. '\' in the path are changed into '//' for TeXLive Compatibility.
REM v1.3: Batch file BUG fixed.
REM 1. Missuse of 'if...else...' is fixed.
REM 2. Missuse of 'for loop' is fixed.
REM v1.4: Modify output redirecting.
REM --------------------------------------------------------------------------
REM User Configuration
REM Project name
set PROJECT=buptgraduatethesis
REM File name of your top-level tex file.
set TARGET=bare_thesis
REM File name list of tex files for mainmatters.
set MAINMATTERS=(ch_intro ch_concln)
REM Driver type to build PDF.
REM 'xetex' for xetex engine;
set DRIVER=xetex
REM Bib type to construct bibliography.
REM 'chapbib' for bib per chapter; 'allbib' for bib in thesis end.
set BIBTYPE=chapbib
REM --------------------------------------------------------------------------
REM Main Function Selection
if /I {%1}=={clean} goto clean
if /I {%1}=={install} goto install
if /I {%1}=={thesis} goto thesis
if /I {%1}=={wordcount} goto wordcount
REM Default Selection: thesis
goto thesis
REM --------------------------------------------------------------------------
REM TMP Files Clearance
:clean
echo Clearing TMP files...
echo Clearing TMP files in installation...
del *.dvi *.ps >nul
echo Clearing TMP files in thesis generation...
del *.bbl *.blg *.aux *.log *.acn *.glo *.ist *.acr *.alg *.out *.toc *.thm *.ps *.dvi >nul
echo ===========================================
echo = Mission Done!
echo = ALL TMP files are cleared!
echo ===========================================
goto end
REM --------------------------------------------------------------------------
REM Word Count
: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 ===========================================
goto end
REM --------------------------------------------------------------------------
REM Document Class and Help PDF File Generation
: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 >nul
makeindex -q -s gglo.ist -o %PROJECT%.gls %PROJECT%.glo >nul
echo Rebuilding to generate cross-reference...
xelatex install//%PROJECT%.dtx
echo Clearing TMP files...
del /f /q %PROJECT%.aux %PROJECT%.glo %PROJECT%.ilg %PROJECT%.ind
del /f /q %PROJECT%.out %PROJECT%.toc %PROJECT%.idx %PROJECT%.hd %PROJECT%.xdv %PROJECT%.gls
echo ===========================================
echo = Mission Done!
echo = BUPTGraduateThesis is successfully installed!
echo ===========================================
goto end
REM --------------------------------------------------------------------------
REM Thesis PDF Generation
:thesis
REM 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!
pause
REM Check the integrity of the installation.
echo Checking Existence of Essential Files...
if not exist %PROJECT%.cls (
echo ===========================================
echo = Mission Failed!
echo = Cannot find essential files!
echo = Please 'makethesis.bat install' to reinstall BUPTGraduateThesis!
echo ===========================================
goto end
)
if not exist %PROJECT%.cfg (
echo ===========================================
echo = Mission Failed!
echo = Cannot find essential files!
echo = Please 'makethesis.bat install' to reinstall BUPTGraduateThesis!
echo ===========================================
goto end
)
if not exist %PROJECT%.bst (
echo ===========================================
echo = Mission Failed!
echo = Cannot find essential files!
echo = Please 'makethesis.bat install' to reinstall BUPTGraduateThesis!
echo ===========================================
goto end
)
echo Document class installed! Generating Thesis PDF...
REM Generate the thesis PDF according to different configurations.
echo Generating Thesis PDF...
if %DRIVER%==xetex (
echo Building thesis PDF...
xelatex --interaction=errorstopmode --synctex=-1 %TARGET%
echo Processing BIB files...
if %BIBTYPE%==chapbib (
for %%M in %MAINMATTERS% do ( bibtex %%M >nul )
) else (
bibtex %TARGET% >nul
)
bibtex jrnl.aux >nul
bibtex conf.aux >nul
bibtex patent.aux >nul
echo Processing index files...
makeindex -s %TARGET%.ist -t %TARGET%.alg -o %TARGET%.acr %TARGET%.acn >nul 2>nul
echo Rebuilding 1 to generate cross-reference...
xelatex --interaction=nonstopmode --synctex=-1 %TARGET% >nul
echo Rebuilding 2 to generate cross-reference...
xelatex --interaction=nonstopmode --synctex=1 %TARGET% >nul
) else (
echo Engine Undefined!
)
echo ===========================================
echo = Mission Done!
echo = Thesis PDF is successfully generated!
echo ===========================================
goto end
REM --------------------------------------------------------------------------
REM Execution Finish
:end
REM EOF