Skip to content

Commit d3b61d1

Browse files
committed
WIP(UT): pack to latex3
1 parent d515600 commit d3b61d1

File tree

2 files changed

+232
-1
lines changed

2 files changed

+232
-1
lines changed

Diff for: templates/undergraduate-thesis/bitundergrad.cls

+219
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
\RequirePackage{expl3, l3keys2e}
2+
\ProvidesExplClass{bitundergrad}{
3+
2022-06-10
4+
}{0.0.1}{BIThesis Undergraduate Thesis class}
5+
6+
\PassOptionsToPackage{AutoFakeBold,AutoFakeSlant}{xeCJK}
7+
8+
% Pass every option not explicitly defined to `ctexbeamer`.
9+
\DeclareOption*{
10+
\PassOptionsToClass{\CurrentOption}{ctexbook}
11+
}
12+
% Executes the code for each option.
13+
\ProcessOptions\relax
14+
% Load
15+
\LoadClass[zihao=-4,oneside,openany]{ctexbook}
16+
17+
\RequirePackage[a4paper,left=3cm,right=2.6cm,top=3.5cm,bottom=2.9cm]{geometry}
18+
\RequirePackage{xeCJK}
19+
\RequirePackage{titletoc}
20+
\RequirePackage{setspace}
21+
\RequirePackage{graphicx}
22+
\RequirePackage{fancyhdr}
23+
\RequirePackage{pdfpages}
24+
\RequirePackage{setspace}
25+
\RequirePackage{booktabs}
26+
\RequirePackage{multirow}
27+
\RequirePackage{tikz}
28+
\RequirePackage{etoolbox}
29+
\RequirePackage{hyperref}
30+
\RequirePackage{xcolor}
31+
\RequirePackage{caption}
32+
\RequirePackage{array}
33+
\RequirePackage{amsmath}
34+
\RequirePackage{amssymb}
35+
\RequirePackage{pdfpages}
36+
\RequirePackage{listings}
37+
38+
% key-value interface definition.
39+
% \keys_define:nn { bitundergrad }
40+
% {
41+
% cover .meta:nn = { bitundergrad / cover } {#1},
42+
% info .meta:nn = { bitundergrad / info } {#1},
43+
% misc .meta:nn = { bitundergrad / misc } {#1}
44+
% }
45+
%
46+
% \keys_define:nn { bitundergrad / cover }
47+
% {
48+
% date .tl_set:N = \l_bit_coverdate_tl,
49+
% }
50+
%
51+
% \keys_define:nn { bitundergrad / info }
52+
% {
53+
% dept .tl_set:N = \l_bit_dept_tl,
54+
% major .tl_set:N = \l_bit_major_tl,
55+
% class .tl_set:N = \l_bit_class_tl,
56+
% name .tl_set:N = \l_bit_name_tl,
57+
% mentor .tl_set:N = \l_bit_mentor_tl,
58+
% offCampusMentor .tl_set:N = \l_bit_offcampusmentor_tl,
59+
% }
60+
%
61+
% \keys_define:nn { bitundergrad / misc }
62+
% {
63+
% reviewTable .tl_set:N = \l_bit_reviewtable_tl,
64+
% }
65+
66+
\setromanfont{Times~New~Roman}
67+
% TODO: set optional or remove this
68+
\setCJKfamilyfont{xihei}[AutoFakeBold,AutoFakeSlant]{[STXIHEI.TTF]} % 若希望使用本机字体,也可以用 {STXihei} 来调用
69+
\newcommand{\xihei}{\CJKfamily{xihei}}
70+
71+
\newcommand{\arabicHeiti}[1]{#1}
72+
73+
% TODO: custom title
74+
\fancypagestyle{BIThesis}{
75+
% 页眉高度
76+
\setlength{\headheight}{20pt}
77+
% 页码高度(不完美,比规定稍微靠下 2mm)
78+
\setlength{\footskip}{24pt}
79+
80+
\fancyhf{}
81+
% 定义页眉、页码
82+
\fancyhead[C]{\zihao{4}\ziju{0.08}\songti{北京理工大学本科生毕业设计(论文)}}
83+
\fancyfoot[C]{\songti\zihao{5} \thepage}
84+
% 页眉分割线稍微粗一些
85+
\renewcommand{\headrulewidth}{0.6pt}
86+
}
87+
88+
\ctexset{chapter={
89+
name = {第,章},
90+
number = {\arabicHeiti{ \arabic{chapter} }},
91+
format = {\heiti \bfseries \centering \zihao{3}},
92+
aftername = \hspace{9bp},
93+
pagestyle = BIThesis,
94+
beforeskip = 8bp,
95+
afterskip = 32bp,
96+
fixskip = true,
97+
}
98+
}
99+
100+
\ctexset{section={
101+
number = {\arabicHeiti{\thechapter.\hspace{1bp}\arabic{section}}},
102+
format = {\heiti \raggedright \bfseries \zihao{4}},
103+
aftername = \hspace{8bp},
104+
beforeskip = 20bp plus 1ex minus .2ex,
105+
afterskip = 18bp plus .2ex,
106+
fixskip = true,
107+
}
108+
}
109+
110+
\ctexset{subsection={
111+
number = {\arabicHeiti{\thechapter.\hspace{1bp}\arabic{section}.\hspace{1bp}\arabic{subsection}}},
112+
format = {\heiti \bfseries \raggedright \zihao{-4}},
113+
aftername = \hspace{7bp},
114+
beforeskip = 17bp plus 1ex minus .2ex,
115+
afterskip = 14bp plus .2ex,
116+
fixskip = true,
117+
}
118+
}
119+
120+
\addtocontents{toc}{\protect\hypersetup{hidelinks}}
121+
122+
\renewcommand{\contentsname}{
123+
\fontsize{16pt}{\baselineskip}
124+
\normalfont\heiti{目\hspace{1em}录}
125+
\vspace{-8pt}
126+
}
127+
\titlecontents{chapter}[0pt]{\songti \zihao{-4}}
128+
{\thecontentslabel\hspace{\ccwd}}{}
129+
{\hspace{.5em}\titlerule*{.}\contentspage}
130+
\titlecontents{section}[1\ccwd]{\songti \zihao{-4}}
131+
{\thecontentslabel\hspace{\ccwd}}{}
132+
{\hspace{.5em}\titlerule*{.}\contentspage}
133+
\titlecontents{subsection}[2\ccwd]{\songti \zihao{-4}}
134+
{\thecontentslabel\hspace{\ccwd}}{}
135+
{\hspace{.5em}\titlerule*{.}\contentspage}
136+
137+
\renewcommand{\frontmatter}{
138+
\pagenumbering{Roman}
139+
\pagestyle{BIThesis}
140+
}
141+
142+
\renewcommand{\mainmatter}{
143+
\pagenumbering{arabic}
144+
\pagestyle{BIThesis}
145+
}
146+
147+
\setlength{\abovecaptionskip}{11pt}
148+
\setlength{\belowcaptionskip}{9pt}
149+
150+
\AtBeginDocument{
151+
\renewcommand{\lstlistingname}{代码}
152+
\renewcommand{\thelstlisting}{\arabic{chapter}-\arabic{lstlisting}}
153+
}
154+
155+
\definecolor{codegreen}{rgb}{0,0.6,0}
156+
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
157+
\definecolor{codepurple}{rgb}{0.58,0,0.82}
158+
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
159+
\lstdefinestyle{examplestyle}{
160+
backgroundcolor=\color{backcolour},
161+
commentstyle=\color{codegreen},
162+
keywordstyle=\color{magenta},
163+
numberstyle=\tiny\color{codegray},
164+
stringstyle=\color{codepurple},
165+
basicstyle=\ttfamily\footnotesize,
166+
breakatwhitespace=false,
167+
breaklines=true,
168+
captionpos=b,
169+
keepspaces=true,
170+
numbers=left,
171+
numbersep=5pt,
172+
showspaces=false,
173+
showstringspaces=false,
174+
showtabs=false,
175+
tabsize=2
176+
}
177+
\lstset{style=examplestyle}
178+
179+
% figure
180+
181+
\renewcommand{\thefigure}{\thechapter-\arabic{figure}}
182+
\captionsetup[figure]{font=small,labelsep=space}
183+
184+
185+
% table
186+
\renewcommand{\thetable}{\thechapter-\arabic{table}}
187+
\captionsetup[table]{font=small,labelsep=space,skip=2pt}
188+
189+
% equation
190+
\renewcommand{\theequation}{\arabic{chapter}-\arabic{equation}}
191+
192+
\tolerance=1
193+
\emergencystretch=\maxdimen
194+
\hyphenpenalty=10000
195+
\hbadness=10000
196+
197+
198+
\newcommand{\unnumchapter}[1]{
199+
\chapter*{\vskip 10bp\textmd{#1} \vskip -6bp}
200+
\addcontentsline{toc}{chapter}{#1}
201+
\stepcounter{chapter}
202+
}
203+
204+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205+
206+
% user interface.
207+
\DeclareDocumentCommand \BITProposalSetup { m }
208+
{ \keys_set:nn { bitundergrad } { #1 }}
209+
\DeclareDocumentCommand \MakeCover {}
210+
{
211+
\group_begin:
212+
\group_end:
213+
}
214+
215+
\DeclareDocumentCommand \MakeReviewTable {}
216+
{
217+
\group_begin:
218+
\group_end:
219+
}

Diff for: templates/undergraduate-thesis/main.tex

+13-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
% Compile with: xelatex -> biber -> xelatex -> xelatex
2121

2222
% 章节支持、单面打印:ctexbook
23-
\documentclass[bachelor,footskip=24pt]{bitbook}
23+
\documentclass[]{bitundergrad}
2424
% 如果想要修改样式,但无法找到样式在哪里定义:请参考 https://bithesis.bitnp.net/Guide/4-Others/Troubleshooting.html#%E6%83%B3%E8%A6%81%E4%BF%AE%E6%94%B9%E9%83%A8%E5%88%86%E6%A0%B7%E5%BC%8F-%E4%BD%86%E6%98%AF%E6%89%BE%E4%B8%8D%E5%88%B0%E6%A0%B7%E5%BC%8F%E5%9C%A8%E5%93%AA%E9%87%8C%E5%AE%9A%E4%B9%89
2525

2626
% 另一个临时的“修改页眉文字”的解决方法(非常不优雅,只作为临时措施)。
@@ -53,6 +53,18 @@
5353
% 但是,我们仍旧非常建议你使用 minted。
5454
\usepackage{listings}
5555

56+
\usepackage[
57+
backend=biber,
58+
style=gb7714-2015,
59+
gbalign=gb7714-2015,
60+
gbnamefmt=lowercase,
61+
gbpub=false,
62+
doi=false,
63+
url=false,
64+
eprint=false,
65+
isbn=false,
66+
]{biblatex}
67+
5668
% 参考文献引用文件位于 misc/ref.bib
5769
\addbibresource{misc/ref.bib}
5870

0 commit comments

Comments
 (0)