-
Notifications
You must be signed in to change notification settings - Fork 10
/
qyxf-book.cls
221 lines (220 loc) · 7.32 KB
/
qyxf-book.cls
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
%%
%% This is file `qyxf-book.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% qyxf.dtx (with options: `book')
%%
%% This is a generated file.
%%
%% Copyright (C) 2019 by xjtu-blacksmith
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any later
%% version. 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 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is xjtu-blacksmith.
%%
%% -----------------------------------
%%
%% Note: 此模板相对于原有模板已做修改,修改为:
%% 优化了 sourcefont 重定义字体的方式,减少编译时间与警告
%% 此改动将在未来加入到 qyxf-sets 之中.
%% 为原始模板请访问:https://github.com/qyxf/qyxf-sets
%% 修改者:xjtu-blacksmith(maintainer)
%%
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesClass{qyxf-book}
[2019/05/26 v2.1 Template for qyxf's book]
\typeout{The book template provided by Qian Yuan Xue Fu}
\typeout{WARNING: The class file is modified by xjtu-blacksmith}
\LoadClass[10pt,twoside,openany]{book}
\newif\if@decoration
\newif\if@opensource
\newif\if@sourcefont
\DeclareOption{a4paper}{
\setlength\paperheight{297mm}%
\setlength\paperwidth{210mm}}
\DeclareOption{b5paper}{
\setlength\paperheight{250mm}%
\setlength\paperwidth{176mm}}
\DeclareOption{color}{}
\DeclareOption{parskip}{
\setlength\parskip{0.2\baselineskip}}
\DeclareOption{decoration}{\@decorationtrue}
\DeclareOption{opensource}{\@opensourcetrue}
\DeclareOption{sourcefont}{\@sourcefonttrue}
\ProcessOptions
\if@sourcefont
\PassOptionsToPackage{SlantFont}{xeCJK}
\RequirePackage[heading,fontset=none]{ctex}
\setCJKmainfont{思源宋体}
\setCJKsansfont{思源黑体}
\newCJKfontfamily[zhfs]\fangsong{FangSong}
\renewcommand\CJKttdefault{zhfs}
\else
\RequirePackage[heading]{ctex}
\fi
\setmainfont{Cambria} % 目前默认使用的serif字体
\setsansfont{Calibri} % 目前默认使用的sans-serif字体
\setmonofont{Courier New} % 目前默认使用的等宽字体
\RequirePackage{amsmath}
\RequirePackage{unicode-math}
\setmathfont{Cambria Math} % 与正文字体相适应的数学字体
\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}
\RequirePackage{tcolorbox,tabu}
\tcbuselibrary{listings,theorems,skins}
\newcommand{\exercise}[1]{\noindent\tcbox[on line,top=0mm,bottom=0mm,%
right=0mm,left=0mm]{\bfseries 练习#1}\ }
\newcommand{\note}{\noindent\textbf{注记}\ }
\newcommand{\solve}{\noindent\textbf{解}\ }
\newcommand{\analysis}{\noindent\textbf{分析}\ }
\RequirePackage{geometry}
\geometry{margin=1in}
\RequirePackage{hyperref}
\hypersetup{
breaklinks,
unicode,
linktoc=all,
bookmarksnumbered=true,
bookmarksopen=true,
pdfborder={0 0 0},
linktocpage,
pageanchor=true}
\RequirePackage{pgfornament-han}
\RequirePackage{pgfornament}
\ctexset{section={name={\S,}}}
\RequirePackage{titlesec,titletoc}
\newcommand{\decoration}{\vspace{-.3\baselineskip}\pgfornamenthan[scale=0.2,symmetry=h]{60}}
\titleformat{\chapter}[block]{\centering\bfseries\Huge}{\CTEXthechapter}
{1em}{}[\centering\decoration]%
\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}
\RequirePackage{fancyhdr}
\fancyhead[EC]{\fangsong\nouppercase\leftmark}
\fancyhead[OC]{\fangsong\nouppercase\rightmark}
\fancyhead[EL,OR]{\bf\thepage}
\fancyhead[ER,OL]{}
\fancyfoot[C]{\textsc{Qian Yuan Xue Fu}\\\resizebox{0.2\linewidth}{1.5ex}{%
\pgfornamenthan[scale=0.05]{58}}}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[C]{\textsc{Qian Yuan Xue Fu}\\\resizebox{0.2\linewidth}{1.5ex}{%
\pgfornamenthan[scale=0.05]{58}}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\setlength{\headheight}{13pt}
\RequirePackage{lastpage}
\RequirePackage{enumerate}
\RequirePackage{pifont}
\RequirePackage{appendix}
\ctexset{appendix={number={\Roman{chapter}}}}
\RequirePackage[scale=1.1]{ccicons}
\newtoks\subtitle
\newtoks\typo
\newtoks\version
\newtoks\sourcepage
\renewcommand*{\maketitle}{%
\hypersetup{
pageanchor=false,
pdfauthor=\@author,
pdftitle=\@title,
pdfsubject={\@author: \@title - \the\subtitle},
pdfkeywords={qyxf, book},
pdfcreator={XeLaTeX with qyxf-book class}
}
\begin{titlepage}
\phantom{s}
\vspace{3cm}
\begin{center}\large
\begin{tcolorbox}[blanker,borderline west={1mm}{0pt}{black!80},%
left=20pt]
{\fontsize{40pt}{\baselineskip}\selectfont\bfseries\@title}\\[0.5\baselineskip]
{\Huge\itshape\the\subtitle}
\end{tcolorbox}
\begin{tcolorbox}[blanker,borderline west={1mm}{0pt}{black!50},%
left=20pt]
{\Large 作者:\@author\\[0.2\baselineskip]
\@date}
\end{tcolorbox}
\vfill
\texttt{钱学森书院学业辅导中心}\\[0.5\baselineskip]
\textsc{Qian Yuan Xue Fu}\\[0.5\baselineskip]
{XI'AN JIAOTONG UNIVERSITY}
\end{center}
\begin{tikzpicture}[remember picture,overlay]
\begin{pgfonlayer}{background}
\node at ($(current page.east) +(0in,0in)$) {%
\includegraphics[width=0.8\textwidth]{cover.png}};
\end{pgfonlayer}
\end{tikzpicture}
\end{titlepage}
\thispagestyle{empty}
\newpage
\hypersetup{pageanchor=true}
\phantom{s}\vfill
\begin{tcolorbox}[title={\bfseries 作品信息}]
\ding{228} \textbf{标题:}\@title{} - \textit{\the\subtitle}\\
\ding{228} \textbf{作者:}\@author\\
\ding{228} \textbf{校对排版:}\the\typo\\
\ding{228} \textbf{出品时间:}\@date\\
\ding{228} \textbf{总页数:}\pageref{LastPage}
\end{tcolorbox}
\begin{tcolorbox}[title={\bfseries 许可证说明}]
\centerline{\tcbox{\ccbyncnd\ \fangsong 知识共享 (Creative Commons) BY-NC-ND 4.0 协议}%
\\[0.3\baselineskip]}
本作品采用 \href{https://creativecommons.org/licenses/by-nc-nd/4.0/}{\textbf{CC协议}}
进行许可。使用者可以在给出作者署名及资料来源的前提下对本作品进行转载,但不得对本作品进行
修改,亦不得基于本作品进行二次创作,不得将本作品运用于商业用途。
\end{tcolorbox}
\if@opensource
\begin{tcolorbox}
本作品已发布于GitHub之上,发布地址为:\\
\centerline{\the\sourcepage}
本作品的版本号为\textsf{\the\version}。
\end{tcolorbox}
\fi
\newpage
\pagestyle{fancy}
}
\renewcommand\tableofcontents{%
\pagestyle{empty}
\centerline{%
\normalfont\LARGE\bfseries\contentsname%
\@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}
}
\vskip 3ex%
{\setlength\parskip{0pt}\@starttoc{toc}}
\cleardoublepage
\pagestyle{fancy}
\setcounter{page}{1}
}
\endinput
%%
%% End of file `qyxf-book.cls'.