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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
% --------------------------
% qyxf-book 钱院学辅书籍模板
% 如不清楚含义,请勿随意更改
% --------------------------
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\newcommand{\styversion}{3.1.0}
\newcommand{\styname}{qyxf-book}
\ProvidesClass{qyxf-book}
[2020/09/11 v3.1.0 Qian Yuan Xue Fu book template]
\typeout{The book template provided by Qian Yuan Xue Fu}
% 设定 key-val 选项
\RequirePackage{kvoptions}
\SetupKeyvalOptions{family = QYXF, prefix = QYXF@}
% 选项定制与处理
\DeclareStringOption[basic]{colorscheme}[basic]
\DeclareStringOption{primary}
\DeclareStringOption{secondary}
\DeclareBoolOption[true]{xits}
\DeclareVoidOption{noCJKfont}{\PassOptionsToClass{fontset=none}{ctexbook}}
% 已废弃选项提示
\DeclareVoidOption{color}{\ClassWarning{\styname}{The option `color' is deprecated. Use `colorscheme' instead}}
\DeclareVoidOption{parskip}{\ClassWarning{\styname}{The option `parskip' is deprecated}}
\DeclareVoidOption{decoration}{\ClassWarning{\styname}{The option `decoration' is deprecated, due to the lack of `pgfornament' package in TeX Live 2020}}
\DeclareVoidOption{sourcefont}{\ClassWarning{\styname}{The option `sourcefont' is deprecated. Please customize your fonts by commands of `fontspec' and `xeCJK' package}}
\DeclareVoidOption{plain}{\ClassWarning{\styname}{The option `sourcefont' is deprecated}}
\DeclareVoidOption{opensource}{\ClassWarning{\styname}{The option `opensource' is deprecated}}
% 处理选项
\DeclareDefaultOption{\PassOptionsToClass{\CurrentOption}{ctexbook}}
\ProcessKeyvalOptions*
% 载入文类
\PassOptionsToPackage{no-math}{fontspec}
\PassOptionsToPackage{CJKmath = true}{xeCJK}
\LoadClass{ctexbook}
% 西文字体处理
\RequirePackage{amsmath}
\ifQYXF@xits
\setmainfont{XITS}
\setsansfont{TeX Gyre Heros}[Scale=0.93]
\RequirePackage{unicode-math}
\setmathfont{XITS Math}
\fi
\RequirePackage{hologo}
% 正文样式设置
\RequirePackage[normalem]{ulem}
% 脚注样式调整
\renewcommand{\thefootnote}{\textbf{(\arabic{footnote})}}
% 浮动体(图表)处理
\RequirePackage{graphicx}
\graphicspath{{./figure/}{./pic/}{./image}}
\setlength{\textfloatsep}{6pt plus 2pt minus 4pt}
\setlength{\intextsep}{6pt plus 2pt minus 2pt}
\RequirePackage{longtable,booktabs}
\RequirePackage{tikz}
\usetikzlibrary{calc,backgrounds,shadows}
\RequirePackage[many]{tcolorbox}
% caption 样式设定
\RequirePackage{caption}
\DeclareCaptionFormat{colored}{\small{\bfseries\color{\CaptionColor}#1} #3}
\captionsetup{
format = colored,
skip = 1ex
}
% 处理配色方案
\RequirePackage{etoolbox}
\ifdefempty{\QYXF@primary}{\relax}{\newcommand{\PrimaryColor}{\QYXF@primary}}
\ifdefempty{\QYXF@secondary}{\relax}{\newcommand{\SecondaryColor}{\QYXF@secondary}}
% color scheme 默认值
% for titles amd text
\newcommand{\TitleColor}{black}
\newcommand{\ListColor}{black}
\newcommand{\CaptionColor}{black}
\newcommand{\LinkColor}{black}
\newcommand{\MiscColor}{black}
% for boxes
\newcommand{\BoxBackground}{white}
\newcommand{\BoxFrame}{black!75}
\newcommand{\BoxTitleColor}{white}
\newcommand{\BoxTitleBackground}{black!50}
\newcommand{\BoxColor}{black}
\newcommand{\AlertBackground}{white}
\newcommand{\AlertColor}{black}
\newcommand{\AlertFrame}{black}
\newcommand{\AlertTitleBackground}{black}
\newcommand{\AlertTitleColor}{white}
% for theorems
\newcommand{\DefineBackground}{white}
\newcommand{\DefineFrame}{black!40}
\newcommand{\DefineColor}{black}
\newcommand{\TheoremBackground}{black!10}
\newcommand{\TheoremFrame}{black!80}
\newcommand{\TheoremColor}{black}
% 读取 color scheme
\RequirePackage{xstring}
\IfEqCase{\QYXF@colorscheme}{%
{basic}{\relax}% Basic theme
{black}{% BLack theme (bicolor)
% main colors
\providecommand\PrimaryColor{black}
% for titles amd text
\renewcommand\TitleColor{\PrimaryColor}
\renewcommand\ListColor{\PrimaryColor}
\renewcommand\CaptionColor{\PrimaryColor}
\renewcommand\LinkColor{\PrimaryColor}
\renewcommand\MiscColor{\PrimaryColor}
% for boxes
\renewcommand\BoxBackground{white}
\renewcommand\BoxTitleColor{\PrimaryColor}
\renewcommand\BoxTitleBackground{white}
\renewcommand\BoxFrame{\PrimaryColor}
\renewcommand\AlertTitleColor{white}
\renewcommand\AlertTitleBackground{\PrimaryColor}
% for theorems
\renewcommand\DefineFrame{\PrimaryColor}
\renewcommand\TheoremBackground{white}
\renewcommand\TheoremFrame{\PrimaryColor}
}%
{rbb}{% Red-Blue-Black theme (tricolor)
% main colors
\providecommand\PrimaryColor{blue}
\providecommand\SecondaryColor{red}
% for titles amd text
\renewcommand\TitleColor{\PrimaryColor}
\renewcommand\ListColor{\PrimaryColor}
\renewcommand\CaptionColor{\PrimaryColor}
\renewcommand\LinkColor{\SecondaryColor}
\renewcommand\MiscColor{\PrimaryColor}
% for boxes
\renewcommand\BoxBackground{white}
\renewcommand\BoxFrame{\PrimaryColor}
\renewcommand\BoxTitleBackground{\PrimaryColor}
\renewcommand\AlertColor{\SecondaryColor}
\renewcommand\AlertFrame{\SecondaryColor}
\renewcommand\AlertTitleBackground{\SecondaryColor}
% for theorems
\renewcommand\DefineFrame{black}
\renewcommand\TheoremBackground{white}
\renewcommand\TheoremFrame{\PrimaryColor}
}%
{bootstrap-v4}{% Bootstrap V4 theme
% for titles amd text
\renewcommand\TitleColor{black!85}
\renewcommand\ListColor{blue!50!cyan}
\renewcommand\CaptionColor{cyan!80!olive}
\renewcommand\LinkColor{blue!67!green!}
\renewcommand\MiscColor{blue!50!cyan}
% for boxes
\renewcommand\BoxBackground{cyan!20!white}
\renewcommand\BoxFrame{blue!30!teal}
\renewcommand\BoxTitleBackground{blue!55!cyan}
\renewcommand\BoxColor{blue!45!teal!80!black}
\renewcommand\AlertBackground{red!10!white}
\renewcommand\AlertColor{red!40!black!90!white}
\renewcommand\AlertFrame{red!75!teal}
\renewcommand\AlertTitleBackground{red!80!cyan}
% for theorems
\renewcommand\DefineBackground{green!8!white!94!black}
\renewcommand\DefineFrame{green!10!white!90!black}
\renewcommand\DefineColor{green!40!black!90!white}
\renewcommand\TheoremBackground{-blue!20!black!96!green}
\renewcommand\TheoremFrame{-blue!30!black!90!green}
\renewcommand\TheoremColor{red!57!green!90!black}
}%
}[\ClassWarning{\styname}{Color scheme `\QYXF@colorscheme' not found, `basic' theme is used then.}]
% tcolorbox 样式设定
\tcbset{
enhanced,
noparskip,
after = \noindent,
colback = \BoxBackground,
title filled,
colbacktitle = \BoxTitleBackground,
colframe = \BoxFrame,
coltitle = \BoxTitleColor,
coltext = \BoxColor,
fonttitle = \bfseries,
arc = 0.25em,
boxrule = 0.5pt,
toptitle = 0.75em,
bottomtitle = 0.75em,
boxsep = 0pt,
left = 1.25em,
right = 1.25em,
top = 1.25em,
bottom = 1.25em,
drop fuzzy shadow,
breakable
}
% 引导命令
\newcommand{\exercise}[1]{\noindent\textbf{\color{\MiscColor}练习 #1}\ }
\newcommand{\solve}[1][解]{\noindent\textbf{\color{\MiscColor}#1}\ }
\newcommand{\analysis}[1][分析]{\noindent\emph{\color{\MiscColor}#1}\ }
% 定理环境及样式设定
\newtheorem{theorem}{定理}
\newtheorem{lemma}[theorem]{引理}
\newtheorem{define}{定义}
\BeforeBeginEnvironment{theorem}{\begin{tcolorbox}[colback=\TheoremBackground,colframe=\TheoremFrame,coltext=\TheoremColor]}
\AfterEndEnvironment{theorem}{\end{tcolorbox}}
\BeforeBeginEnvironment{lemma}{\begin{tcolorbox}[colback=\TheoremBackground,colframe=\TheoremFrame,coltext=\TheoremColor]}
\AfterEndEnvironment{lemma}{\end{tcolorbox}}
\BeforeBeginEnvironment{define}{\begin{tcolorbox}[colback=\DefineBackground,colframe=\DefineFrame,coltext=\DefineColor]}
\AfterEndEnvironment{define}{\end{tcolorbox}}
\newtcolorbox{note}{title={注记}}
\newtcolorbox{alert}{
title = {警告},
colback = \AlertBackground,
colframe = \AlertFrame,
colbacktitle = \AlertTitleBackground,
coltitle = \AlertTitleColor,
coltext = \AlertColor
}
% 页面设置
\RequirePackage{geometry}
\geometry{margin = 1in}
\setlength{\footskip}{30pt}
\setlength{\headheight}{15pt}
% 链接设置
\RequirePackage[unicode]{hyperref}
\hypersetup{
breaklinks,
unicode,
linktoc = all,
bookmarksnumbered = true,
bookmarksopen = true,
pdfborder = {0 0 0},
linktocpage,
pageanchor = true
}
\hypersetup{
colorlinks = true,
linkcolor = \LinkColor,
anchorcolor = \MiscColor,
urlcolor = \LinkColor,
citecolor = \MiscColor
}
% 章节标题与目录样式
\RequirePackage{titlesec,titletoc}
\ctexset{section={name={\S,}}}
\titleformat{\chapter}[block]{\color{\TitleColor}\centering\bfseries\fontsize{2.25em}{1.2ex}}{\CTEXthechapter}{1em}{}
\titleformat*{\section}{\color{\TitleColor}\fontsize{1.75em}{1.225ex}\bfseries\centering}
\titleformat*{\subsection}{\color{\TitleColor}\fontsize{1.5em}{1.43ex}\bfseries}
\titleformat*{\subsubsection}{\color{\TitleColor}\fontsize{1.25em}{1.4ex}\bfseries}
\titleformat*{\paragraph}{\color{\TitleColor}\bfseries}
\titleformat*{\subparagraph}{\color{\TitleColor}}
\titlespacing{\chapter}{0pt}{*1}{*4}
\titlecontents{chapter}[24pt]{\hspace{-2pc}\filright}
{\normalsize\bfseries\contentspush{\thecontentslabel\ }}
{}{\bfseries\titlerule*[8pt]{.}\contentspage}
\titlecontents{section}[20pt]{\filright}
{\contentspush{\thecontentslabel\ }}
{}{\titlerule*[8pt]{.}\contentspage}
\titlecontents{subsection}[18pt]{\hspace{2pc}\filright}
{\contentspush{\thecontentslabel\ }\itshape}
{}{\titlerule*[8pt]{}\contentspage}
\setcounter{tocdepth}{2}
% 页眉页脚设置
\newcommand{\footerbox}{%
{\color{\MiscColor}\bfseries\thepage}\\[-\baselineskip]
\uline{\hphantom{\@footorginfo}}\\
\@footorginfo}
\RequirePackage{fancyhdr}
\fancyhead[EC]{\itshape\nouppercase\leftmark}
\fancyhead[OC]{\itshape\nouppercase\rightmark}
\fancyhead[EL,OR]{}
\fancyhead[ER,OL]{}
\fancyfoot[C]{\footerbox}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[C]{\footerbox}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
% 列表样式设置
\RequirePackage[shortlabels]{enumitem}
\RequirePackage{pifont}
\setlist{nosep, partopsep=0.5ex}
\setlist[itemize,1]{label={\color{\ListColor}\ding{228}}, left=0.8em}
\setlist[itemize,2]{label={\color{\ListColor}\ding{111}}, left=2.8em}
\setlist[itemize,3]{label={\color{\ListColor}\ding{109}}, left=4.8em}
\setlist[enumerate,1]{label={\color{\ListColor}\textbf{\arabic*}.}, left=0.8em}
\setlist[enumerate,2]{label={\color{\ListColor}{\arabic*}.}, left=2.8em}
\setlist[enumerate,3]{label={\color{\ListColor}({\arabic*})}, left=4.8em}
\setlist[description]{style=nextline, font=\color{\ListColor}\bfseries}
% 参考文献定制
\RequirePackage[square,numbers]{natbib}
\renewcommand{\citenumfont}[1]{{\color{\LinkColor}#1}}
\renewcommand{\bibnumfmt}[1]{{\color{\ListColor}[#1]}}
\AtBeginEnvironment{thebibliography}{\addcontentsline{toc}{chapter}{\bibname}}
% 杂项
\RequirePackage{lastpage}
\RequirePackage{appendix}
\ctexset{appendix={number={\Roman{chapter}}}}
% 若干 metadata
\newcommand{\@subtitle}{}
\newcommand{\subtitle}[1]{\gdef\@subtitle{#1}}
\newcommand{\@typo}{}
\newcommand{\typo}[1]{\gdef\@typo{#1}}
\newcommand{\@cover}{}
\newcommand{\cover}[1]{\gdef\@cover{#1}}
\newcommand{\@orginfo}{%
\textit{钱学森书院学业辅导中心}\\[1ex]
\textsc{Xi'an Jiaotong University}}
\newcommand{\org}[1]{\gdef\@orginfo{#1}}
\newcommand{\@footorginfo}{\textsc{Qian Yuan Xue Fu}}
\newcommand{\footorg}[1]{\gdef\@footorginfo{#1}}
\newcommand{\@licenseinfo}{%
本作品采用%
\href{https://creativecommons.org/licenses/by-nc-nd/4.0/}%
{\bfseries CC BY-NC-ND 4.0 协议}进行许可。
使用者可以在给出作者署名及资料来源的前提下对本作品进行转载,%
但不得对本作品进行修改,亦不得基于本作品进行二次创作,%
不得将本作品运用于商业用途。}
\newcommand{\license}[1]{\gdef\@licenseinfo{#1}}
% 已废弃的 metadata
\newcommand{\version}[1]{\ClassWarning{\styname}{The metadata item `version' is deprecated}}
\newcommand{\sourcepage}[1]{\ClassWarning{\styname}{The metadata item `sourcepage' is deprecated}}
% 封面样式重定义
\newcommand{\titlefont}{\Huge\bfseries}
\newcommand{\subtitlefont}{\huge\itshape}
\newcommand{\authorfont}{\LARGE\itshape}
\newcommand{\datefont}{\Large}
\renewcommand*{\maketitle}{%
\begin{titlepage}
\null
\begin{center}\large
\begin{tcolorbox}[blanker,borderline west={1mm}{0pt}{\BoxFrame},%
left=20pt,top=1ex,bottom=1ex,after skip=0pt,no shadow]
{\color{\TitleColor}\titlefont\@title}
\ifdefempty\@subtitle{}{\\[1ex]{\color{\TitleColor}\subtitlefont\@subtitle}}
\end{tcolorbox}
\begin{tcolorbox}[blanker,borderline west={1mm}{0pt}{\TitleColor},%
left=20pt,top=2ex,bottom=1ex,before skip=0pt,after skip=0pt,no shadow]
{\authorfont\@author}\\\datefont\@date
\end{tcolorbox}
\vfil\@cover\vfil
\vbox{\@orginfo}
\end{center}
\vfilneg
\end{titlepage}
\thispagestyle{empty}
\newpage
\hypersetup{pageanchor=true}
\null\vfill
\begin{tcolorbox}[title={\bfseries 作品信息}]
\begin{itemize}
\item \textbf{标题:}\@title{}\ifdefempty\@subtitle{}{: \textit{\@subtitle}}
\item \textbf{作者:}\@author%
\ifdefempty{\@typo}{}{\item \textbf{校对排版:}\@typo}
\item \textbf{出品时间:}\@date
\item \textbf{总页数:}\pageref{LastPage}
\end{itemize}
\end{tcolorbox}
\ifdefempty\@licenseinfo{}{%
\begin{tcolorbox}[title={\bfseries 许可证说明}]
\@licenseinfo
\end{tcolorbox}}
\newpage
\pagestyle{fancy}}
\AtBeginDocument{%
\hypersetup{
pageanchor=false,
pdfauthor=\@author,
pdftitle=\@title,
pdfsubject={\@author: \@title\ifdefempty{\@subtitle}{}{ - \textit{\@subtitle}}},
pdfkeywords={qyxf, book},
pdfcreator={XeLaTeX with \styname\ v\styversion\ \ifdefempty{\@typo}{}{(by \@typo)}}
}}
% 目录样式重定义
\renewcommand\tableofcontents{%
\pagestyle{empty}
\begin{center}%
\normalfont\LARGE\bfseries\contentsname%
\@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}
\end{center}
\vskip 3ex%
{\setlength\parskip{0pt}\@starttoc{toc}}
\cleardoublepage
\pagestyle{fancy}
\setcounter{page}{1}
}
% 修正配色方案重定义问题
\newcommand{\selectcolor}{
\hypersetup{
linkcolor = \LinkColor,
anchorcolor = \MiscColor,
urlcolor = \LinkColor,
citecolor = \MiscColor
}
\tcbset{
colback = \BoxBackground,
colbacktitle = \BoxTitleBackground,
colframe = \BoxFrame,
coltitle = \BoxTitleColor,
coltext = \BoxColor
}
}
\endinput
|