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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
%%
%% This is file `bitreport.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bithesis.dtx (with options: `cls,report')
%%
%% Copyright (C) 2023
%% Association of Bit Network Pioneer and any individual authors listed in the documentation.
%% ------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%% http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2020/11/27 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Feng Kaiyu.
%% ------------------------------------------------------------------------------
%%
\RequirePackage{expl3,l3keys2e}
\ProvidesExplClass{bitreport}
{2023-03-05}{3.4.2}{BIT Thesis Templates}
\int_new:N \g__bithesis_report_type_int
\clist_const:Nn \c__bithesis_report_type_clist
{ common, undergraduate_proposal}
\seq_new:N \l__bithesis_right_seq
\seq_new:N \l__bithesis_left_seq
\PassOptionsToPackage{AutoFakeBold,AutoFakeSlant}{xeCJK}
\keys_define:nn { bitreport }
{
option .meta:nn = {bitreport / option } {#1},
cover .meta:nn = { bitreport / cover } {#1},
info .meta:nn = { bitreport / info } {#1},
misc .meta:nn = { bitreport / misc } {#1}
}
\keys_define:nn { bitreport / option }
{
type .choice:,
type .value_required:n = true,
type .choices:Vn =
\c__bithesis_report_type_clist
{
\int_set_eq:NN \g__bithesis_report_type_int \l_keys_choice_int
},
type .initial:n = common,
ctex .tl_set:N = \l__bithesis_options_to_ctex_tl,
}
\keys_define:nn { bitreport / cover }
{
imagePath .tl_set:N = \l_bit_coverimagepath_tl,
date .tl_set:N = \l__bithesis_cover_date_tl,
%% cover entry
dilimiter .tl_set:N = \l__bithesis_cover_dilimiter_tl,
labelAlign .tl_set:N = \l__bithesis_cover_label_align_tl,
labelAlign .initial:n = {r},
valueAlign .tl_set:N = \l__bithesis_cover_value_align_tl,
valueAlign .initial:n = {c},
labelMaxWidth .dim_set:N = \l__bithesis_cover_label_max_width_dim,
valueMaxWidth .dim_set:N = \l__bithesis_cover_value_max_width_dim,
autoWidthPadding .dim_set:N = \l__bithesis_cover_auto_width_padding_dim,
autoWidthPadding .initial:n = {0.25em},
autoWidth .bool_set:N = \l__bithesis_cover_auto_width_bool,
autoWidth .initial:n = {true},
underlineThickness .dim_set:N = \l__bithesis_cover_underline_thickness_dim,
underlineThickness .initial:n = {1pt},
underlineOffset .dim_set:N = \l__bithesis_cover_underline_offset_dim,
underlineOffset .initial:n = { -10pt },
}
\keys_define:nn { bitreport / info }
{
title .tl_set:N = \l__bithesis_value_title_tl,
school .tl_set:N = \l__bithesis_value_school_tl,
major .tl_set:N = \l__bithesis_value_major_tl,
class .tl_set:N = \l__bithesis_value_class_tl,
author .tl_set:N = \l__bithesis_value_author_tl,
supervisor .tl_set:N = \l__bithesis_value_supervisor_tl,
externalSupervisor .tl_set:N = \l__bithesis_value_external_supervisor_tl,
studentId .tl_set:N = \l__bithesis_value_student_id_tl,
}
\keys_define:nn { bitreport / misc }
{
reviewTable .tl_set:N = \l_bit_reviewtable_tl,
}
\DeclareOption*{
\PassOptionsToClass{\l__bithesis_options_to_ctex_tl}{ctexart}
}
\ProcessOptions\relax
\LoadClass[zihao=-4]{ctexart}
\RequirePackage[a4paper,left=3cm,right=2.4cm,top=2.6cm,bottom=2.38cm,includeheadfoot]{geometry}
\RequirePackage{fancyhdr}
\RequirePackage{setspace}
\RequirePackage{caption}
\RequirePackage{booktabs}
\RequirePackage{pdfpages}
\ProcessKeysOptions { bitreport / option }
\cs_generate_variant:Nn \tl_if_empty:nTF {x}
\cs_generate_variant:Nn \seq_set_split:Nnn {Nnx}
\cs_new:Npn \__bithesis_dunderline:nnn #1#2#3 {
{\setbox0=\hbox{#3}\ooalign{\copy0\cr\rule[\dimexpr#1-#2\relax]{\wd0}{#2}}}
}
\cs_new:Npn \__bithesis_render_cover_entry:nn #1#2 {
\makebox[\l__bithesis_cover_label_max_width_dim][\l__bithesis_cover_label_align_tl]{
\tl_if_blank:VTF #1 {} {#1\l__bithesis_cover_dilimiter_tl}
}
\hspace{1ex}
\__bithesis_dunderline:nnn{\l__bithesis_cover_underline_offset_dim}{\l__bithesis_cover_underline_thickness_dim}{
\makebox[\l__bithesis_cover_value_max_width_dim][\l__bithesis_cover_value_align_tl]{#2}
}\par
}
\cs_new:Npn \__bithesis_get_text_width:Nn #1#2
{
\hbox_set:Nn \l_tmpa_box {#2}
\dim_set:Nn #1 { \box_wd:N \l_tmpa_box }
}
\cs_generate_variant:Nn \__bithesis_get_text_width:Nn { NV }
\cs_new:Npn \__bithesis_get_max_text_width:NN #1#2
{
\group_begin:
\seq_set_eq:NN \l__bithesis_tmpa_seq #2
\dim_zero_new:N \l__bithesis_tmpa_dim
\bool_until_do:nn { \seq_if_empty_p:N \l__bithesis_tmpa_seq }
{
\seq_pop_left:NN \l__bithesis_tmpa_seq \l__bithesis_tmpa_tl
\__bithesis_get_text_width:NV \l__bithesis_tmpa_dim \l__bithesis_tmpa_tl
% 在两边加上空白,避免文本太靠边。
\dim_gset:Nn #1 { \dim_max:nn {#1} { \l__bithesis_tmpa_dim + \l__bithesis_cover_auto_width_padding_dim * 2} }
}
\group_end:
}
\cs_new:Npn \__bithesis_parse_entry #1 #2 {
\seq_set_split:Nnx \l__bithesis_tmp_right_seq {\\} {#2}
\seq_clear:N \l__bithesis_tmp_left_seq
\seq_map_inline:Nn \l__bithesis_tmp_right_seq {
\seq_put_right:Nn \l__bithesis_tmp_left_seq {}
}
\seq_put_left:Nn \l__bithesis_tmp_left_seq {#1}
\seq_pop_right:NN \l__bithesis_tmp_left_seq \g__bithesis_trashcan_tl
}
\cs_new:Npn \__bithesis_render_cover_entry:n #1 {
% 左边是标签,右边是值。
% 形如:
% { {label_1} {value_1}, {label_2} {value 2} }
% 首先转换成 seq 类型。
\seq_set_from_clist:NN \l__bithesis_input_seq #1
\seq_map_inline:Nn \l__bithesis_input_seq {
% 然后对于每一对 label 和 value,首先查找
% value 中是否含有 \\ 字符,如果有,则将其分割成多个
% label - value 对。
% 比如 {label_1} {value \\ 1} 会被转换成
% { {label_1} {value}, {} {1} }
\__bithesis_parse_entry ##1
% 然后将这些 label - value 对添加到 \l__bithesis_right_seq
% 或者 \l__bithesis_left_sql 中。
% left 就是 label,right 就是 value。
\seq_concat:NNN \l__bithesis_right_seq \l__bithesis_right_seq \l__bithesis_tmp_right_seq
\seq_concat:NNN \l__bithesis_left_seq \l__bithesis_left_seq \l__bithesis_tmp_left_seq
}
% 如果用户选择自动计算最大宽度,则计算最大宽度。
\bool_if:NT \l__bithesis_cover_auto_width_bool {
\__bithesis_get_max_text_width:NN \l__bithesis_cover_label_max_width_dim \l__bithesis_left_seq
\__bithesis_get_max_text_width:NN \l__bithesis_cover_value_max_width_dim \l__bithesis_right_seq
}
% 最后,根据宽度渲染 label 和 value 对。
\group_begin:
\bool_until_do:nn { \seq_if_empty_p:N \l__bithesis_left_seq }
{
\seq_pop_left:NN \l__bithesis_left_seq \l__bithesis_tmpa_tl
\seq_pop_left:NN \l__bithesis_right_seq \l__bithesis_tmpb_tl
\tl_if_empty:xTF \l__bithesis_tmpb_tl {} {
\__bithesis_render_cover_entry:nn {\l__bithesis_tmpa_tl} {\l__bithesis_tmpb_tl}
}
}
\group_end:
}
\DeclareDocumentCommand \BITSetup { m }
{ \keys_set:nn { bitreport } { #1 }}
\DeclareDocumentCommand \MakeCover {}
{
\group_begin:
\int_case:nn {\g__bithesis_report_type_int} {
{1} {
\begin{titlepage}
\centering
\vspace{23mm}
\tl_if_empty:NF \l_bit_coverimagepath_tl {
\includegraphics[width=.5\textwidth]{\l_bit_coverimagepath_tl}\\
}
\vspace{10mm}
\heiti\fontsize{24pt}{24pt}\selectfont{\l__bithesis_value_title_tl}\\
\vspace{67mm}
\begin{spacing}{2.2}
\songti\zihao{3}
\clist_set:Nn \l__bithesis_input_clist {
{\textbf{学\qquad 院:}} {\l__bithesis_value_school_tl},
{\textbf{专\qquad 业:}} {\l__bithesis_value_major_tl},
{\textbf{班\qquad 级:}} {\l__bithesis_value_class_tl},
{\textbf{学\qquad 号:}} {\l__bithesis_value_student_id_tl},
{\textbf{姓\qquad 名:}} {\l__bithesis_value_author_tl},
{\textbf{任课教师:}} {\l__bithesis_value_supervisor_tl},
}
\__bithesis_render_cover_entry:n \l__bithesis_input_clist
\end{spacing}
\vspace*{\fill}
\centering
\songti\fontsize{12pt}{12pt}\selectfont{
\tl_if_empty:NTF \l__bithesis_cover_date_tl {
\today
} {
\l__bithesis_cover_date_tl
}
}
\end{titlepage}
}
{2} {
% Main code for \MakeCover
\begin{titlepage}
\topskip=0pt
\vspace*{-16mm}
\centering
\hspace{-6mm}
\songti\fontsize{22pt}{22pt}
\selectfont{北京理工大学}\par
\vspace{13mm}
\hspace{-6mm}
\heiti\fontsize{24pt}{24pt}
\selectfont{本科生毕业设计(论文)开题报告}\par
\vspace{53mm}
\begin{spacing}{2.2}
\songti\zihao{3}
\clist_set:Nn \l__bithesis_input_clist {
{\textbf{学\qquad 院:}} {\l__bithesis_value_school_tl},
{\textbf{专\qquad 业:}} {\l__bithesis_value_major_tl},
{\textbf{班\qquad 级:}} {\l__bithesis_value_class_tl},
{\textbf{姓\qquad 名:}} {\l__bithesis_value_author_tl},
{\textbf{指导教师:}} {\l__bithesis_value_supervisor_tl},
{\textbf{校外指导教师:}} {\l__bithesis_value_external_supervisor_tl},
}
\__bithesis_render_cover_entry:n \l__bithesis_input_clist
\end{spacing}
\vspace*{\fill}
\centering
\hspace{-6mm}\songti\fontsize{12pt}{12pt}\selectfont{\today}
\end{titlepage}
}
}
\group_end:
}
\DeclareDocumentCommand \MakeReviewTable {}
{
\group_begin:
\begin{titlepage}
\includepdf[pages=-]{\l_bit_reviewtable_tl}
\end{titlepage}
\group_end:
}
\DeclareCaptionFont{kaiticaption}{\kaishu \normalsize}
\renewcommand{\thefigure}{\thesection-\arabic{figure}}
\captionsetup[figure]{font=small,labelsep=space,skip=10bp,labelfont=bf,font=kaiticaption}
\renewcommand{\thetable}{\thesection-\arabic{table}}
\captionsetup[table]{font=small,labelsep=space,skip=10bp,labelfont=bf,font=kaiticaption}
\ctexset{today=big}
\setromanfont{Times~New~Roman}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\ctexset{section={
format={
\raggedright \bfseries \songti \zihao{-3}
},
beforeskip = 24bp plus 1ex minus .2ex,
afterskip = 24bp plus .2ex,
fixskip = true,
name = {,.\quad}
}
}
\ctexset{subsection={
format = {
\bfseries \songti \raggedright \zihao{4}
},
beforeskip = 24bp plus 1ex minus .2ex,
afterskip = 24bp plus .2ex,
fixskip = true,
}
}
\fancyhf{}
\int_case:nn {\g__bithesis_report_type_int} {
{1} {
\fancyhead[R]{
\fontsize{10.5pt}{10.5pt}
\selectfont{\l__bithesis_value_title_tl}
}
}
{2} {
\fancyhead[R]{
\fontsize{10.5pt}{10.5pt}
\selectfont{北京理工大学本科生毕业设计(论文)开题报告}
}
}
}
\fancyfoot[R]{\fontsize{9pt}{9pt}\selectfont{\thepage}}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{0pt}
\pagestyle{fancy}
\setcounter{page}{1}
\cs_set:Npn \baselinestretch {1.53}
\endinput
%%
%% End of file `bitreport.cls'.
|