Skip to content

Commit a9fb4d3

Browse files
committed
fix twoside mod
1 parent d4509f7 commit a9fb4d3

File tree

1 file changed

+84
-50
lines changed

1 file changed

+84
-50
lines changed

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

+84-50
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
% Define Global Variables
77
\int_new:N \g_@@_thesis_type_int
8+
% TODO: refactor this var
89
\tl_new:N \g_@@_toc_title_tl
910
\int_new:N \g_@@_head_zihao_int
1011
\bool_new:N \g_@@_twoside_bool
@@ -141,6 +142,11 @@
141142

142143
% helper functions
143144

145+
\cs_new:Npn \@@_same_page: {
146+
\let\clearpage\relax
147+
\let\cleardoublepage\relax
148+
}
149+
144150
% 是否为研究生学位论文
145151
\cs_new:Npn \@@_if_graduate:TF #1#2 {
146152
\int_compare:nNnTF {3} < {\g_@@_thesis_type_int}
@@ -156,6 +162,10 @@
156162
\cs_new:Npn \@@_if_thesis_english:TF #1#2 {\bool_if:nTF {\g_@@_thesis_type_english_bool} {#1} {#2}}
157163
\cs_new:Npn \@@_if_thesis_english:T #1 {\@@_if_thesis_english:TF {#1}{}}
158164

165+
\cs_new:Npn \@@_if_bachelor_thesis:TF #1#2 {\int_compare:nNnTF {\g_@@_thesis_type_int} < {4} {#1} {#2}}
166+
\cs_new:Npn \@@_if_bachelor_thesis:T #1 {\@@_if_bachelor_thesis:TF {#1} {}}
167+
\cs_new:Npn \@@_if_master_thesis:TF #1#2 {\int_compare:nNnTF {\g_@@_thesis_type_int} = {4} {#1} {#2}}
168+
\cs_new:Npn \@@_if_doctor_thesis:TF #1#2 {\int_compare:nNnTF {\g_@@_thesis_type_int} = {5} {#1} {#2}}
159169

160170

161171

@@ -183,6 +193,7 @@
183193
}
184194
},
185195
type .initial:n = bachelor,
196+
twoside .bool_gset:N = \g_@@_twoside_bool,
186197
}
187198

188199
\keys_define:nn { bitundergrad / cover }
@@ -258,14 +269,18 @@
258269
\PassOptionsToClass{scheme=plain}{ctexbook}
259270
}
260271

272+
\bool_if:NTF \g_@@_twoside_bool {} {
273+
\PassOptionsToClass{oneside,openany}{ctexbook}
274+
}
275+
261276
% Any extra option passed by user will be passed to ctexbook.
262277
\DeclareOption*{
263278
\PassOptionsToClass{\CurrentOption}{ctexbook}
264279
}
265280
% Executes the code for each option.
266281
\ProcessOptions\relax
267282
% Load
268-
\LoadClass[zihao=-4,oneside,openany]{ctexbook}
283+
\LoadClass[zihao=-4,]{ctexbook}
269284

270285
\RequirePackage{geometry}
271286
\RequirePackage{xeCJK}
@@ -925,8 +940,7 @@
925940

926941
% 原创性声明部分
927942
\begin{center}
928-
\let\clearpage\relax
929-
% TODO: 这里
943+
\@@_same_page:
930944
\chapter*{\heiti\zihao{3}\c_@@_graduate_name_originality_tl}
931945
\end{center}~\par
932946

@@ -944,7 +958,7 @@
944958

945959
% 使用授权声明部分
946960
\begin{center}
947-
\let\clearpage\relax
961+
\@@_same_page:
948962
\chapter*{\heiti\zihao{3}\c_@@_graduate_name_authorization_tl}
949963
\end{center}~\par
950964

@@ -961,6 +975,7 @@
961975
\end{spacing}
962976
\end{flushright}
963977
\end{titlepage}
978+
\cleardoublepage
964979
}
965980

966981
\NewDocumentCommand \MakeOriginality {}
@@ -976,7 +991,7 @@
976991
% 原创性声明部分
977992
\begin{center}
978993
\vspace*{-2bp}
979-
\let\clearpage\relax
994+
\@@_same_page:
980995
\chapter*{\heiti\zihao{2}\c_@@_bachelor_name_originality_tl}
981996
\end{center}~\par
982997

@@ -994,7 +1009,7 @@
9941009

9951010
% 使用授权声明部分
9961011
\begin{center}
997-
\let\clearpage\relax
1012+
\@@_same_page:
9981013
\chapter*{\heiti\zihao{2}\c_@@_bachelor_name_authorization_tl}
9991014
\end{center}~\par
10001015

@@ -1018,7 +1033,7 @@
10181033
% 原创性声明部分
10191034
\begin{center}
10201035
\vspace*{-2bp}
1021-
\let\clearpage\relax
1036+
\@@_same_page:
10221037
\chapter*{\heiti\zihao{-2}\c_@@_bachelor_english_name_originality_tl}
10231038
\end{center}~\par
10241039

@@ -1034,7 +1049,7 @@
10341049

10351050
% 使用授权声明部分
10361051
\begin{center}
1037-
\let\clearpage\relax
1052+
\@@_same_page:
10381053
\chapter*{\heiti\zihao{-2}\c_@@_bachelor_english_name_authorization_tl}
10391054
\end{center}~\par
10401055

@@ -1043,9 +1058,6 @@
10431058
\bigbreak
10441059
Student~(Signature):~\dunderline[-1pt]{1pt}{\makebox[18mm + 16bp]{}}~\hspace{2mm}Date:\par
10451060
Supervisor~(Signature):~\dunderline[-1pt]{1pt}{\makebox[18mm]{}}~\hspace{2mm}Date:\par
1046-
1047-
1048-
\newpage
10491061
}
10501062
{4} {\@@_graduate_originality:}
10511063
{5} {\@@_graduate_originality:}
@@ -1075,32 +1087,45 @@
10751087
\@@_if_thesis_int_type:nT {3} {
10761088
\addcontentsline{toc}{chapter}{\c_@@_name_toc_en_tl}
10771089
}
1078-
1079-
\newpage
10801090
}
10811091
}
10821092

10831093
% TODO:
10841094
\NewDocumentEnvironment {abstract} {}
10851095
{
1096+
\cleardoublepage
10861097
\setstretch{1.53}
10871098

1088-
\begin{center}
1089-
\vspace*{-17bp}
1090-
\heiti\zihao{-2}\textbf{
1091-
\int_case:nn {\g_@@_thesis_type_int}
1092-
{
1093-
{1} {\l_bit_title_tl}
1094-
{2} {\l_@@_info_trans_title_tl}
1095-
{3} {\l_bit_title_tl}
1099+
\@@_if_bachelor_thesis:T {
1100+
\begin{center}
1101+
\vspace*{-17bp}
1102+
\heiti\zihao{-2}\textbf{
1103+
\int_case:nn {\g_@@_thesis_type_int}
1104+
{
1105+
{1} {\l_bit_title_tl}
1106+
{2} {\l_@@_info_trans_title_tl}
1107+
{3} {\l_bit_title_tl}
1108+
}
10961109
}
1097-
}
1098-
\end{center}
1110+
\end{center}
10991111

1100-
\vspace*{2mm}
1112+
\vspace*{2mm}
1113+
}
1114+
1115+
\ctexset{
1116+
chapter/numbering = false,
1117+
}
1118+
1119+
\@@_if_bachelor_thesis:TF {
1120+
\ctexset{
1121+
chapter/titleformat = {\textmd}
1122+
}
1123+
} {}
11011124

1102-
{\let\clearpage\relax \chapter*{\textmd{\c_@@_name_abstract_tl}}}
1103-
\addcontentsline{toc}{chapter}{\c_@@_name_abstract_tl}
1125+
{
1126+
\@@_same_page:
1127+
\chapter{\c_@@_name_abstract_tl}
1128+
}
11041129

11051130
\vspace*{1mm}
11061131
\par
@@ -1113,40 +1138,50 @@
11131138

11141139
\NewDocumentEnvironment {abstract*} {}
11151140
{
1141+
\cleardoublepage
11161142
\setstretch{1.53}
1117-
\begin{spacing}{0.95}
1118-
\centering
1119-
\vspace*{-2bp}
11201143

1144+
\@@_if_bachelor_thesis:T {
1145+
\begin{spacing}{0.95}
1146+
\centering
1147+
\vspace*{-2bp}
1148+
1149+
\@@_if_thesis_int_type {3} {
1150+
\arialfamily\zihao{-2}\textbf\l_bit_titleen_tl\\
1151+
} {
1152+
\heiti\zihao{3}\textbf\l_bit_titleen_tl\\
1153+
}
1154+
\end{spacing}
1155+
\vspace*{10mm}
1156+
}
1157+
1158+
\ctexset{
1159+
chapter/numbering = false,
1160+
}
1161+
1162+
\@@_if_bachelor_thesis:TF {
11211163
\int_compare:nNnTF {\g_@@_thesis_type_int} = {3}
11221164
{
1123-
\arialfamily\zihao{-2}\textbf\l_bit_titleen_tl\\
1165+
\ctexset{
1166+
chapter = {
1167+
titleformat = {\heiti\zihao{3}\centering\textbf},
1168+
}
1169+
}
11241170
} {
1125-
\heiti\zihao{3}\textbf\l_bit_titleen_tl\\
1126-
}
1127-
\end{spacing}
1128-
1129-
\int_compare:nNnTF {\g_@@_thesis_type_int} = {3}
1130-
{
1131-
\ctexset{
1132-
chapter = {
1133-
numbering = false,
1134-
titleformat = {\heiti\zihao{3}\centering\textbf},
1171+
\ctexset{
1172+
chapter = {
1173+
titleformat = {\heiti\zihao{-3}\centering\textmd},
1174+
}
11351175
}
11361176
}
11371177
} {
1138-
\ctexset{
1139-
chapter = {
1140-
numbering = false,
1141-
titleformat = {\heiti\zihao{-3}\centering\textmd},
1142-
}
1178+
\ctexset {
1179+
chapter/titleformat = {\heiti\zihao{3}\centering\textbf}
11431180
}
11441181
}
11451182

1146-
\vspace*{10mm}
1147-
11481183
{
1149-
\let\clearpage\relax
1184+
\@@_same_page:
11501185
\chapter{\c_@@_name_abstract_en_tl}
11511186
}
11521187
}
@@ -1244,8 +1279,7 @@
12441279
subsection/number = \arabic{section}. \arabic{subsection},
12451280
}
12461281

1247-
\int_compare:nNnTF {\g_@@_thesis_type_int} = {3}
1248-
{
1282+
\@@_if_thesis_english:TF {
12491283
\chapter{\c_@@_name_ack_en_tl}
12501284
} {
12511285
\chapter{\c_@@_name_ack_tl}

0 commit comments

Comments
 (0)