forked from yhwu-is/Linear-Algebra-Left-Undone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLALUbook.cls
226 lines (189 loc) · 6.42 KB
/
LALUbook.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
222
223
224
225
226
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8
% This class is based on AJbook by Wen-Wei Li, originally released under CC BY 4.0.
% Linear Algebra Left Undone is released under CC BY-NC-SA 4.0.
% Identification
% --------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{LALUbook}[Class for the book Linear Algebra Left Undone]
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
\SetupKeyvalOptions{
family = @LALU,
prefix = @LALU@
}
% Declaration of options
% ----------------------
\DeclareBoolOption[false]{draft} % 是否打上未定稿标记
\DeclareBoolOption[true]{colors} % 是否让链接带颜色
\DeclareBoolOption[false]{CJKthechapter} % 是否让天眉的各章编号使用中文数字
\DeclareStringOption{coverpage} % 封面档档名, 默认为空
\DeclareStringOption{fontsetup} % 字体设定档档名
\DeclareStringOption{titlesetup} % 章节标题设定档档名
\DeclareStringOption[16k]{geometry} % 版面(默认 16k)
\PassOptionsToPackage{dvipsnames}{xcolor} % 让 xcolor 带 dvipsnames 选项; tikz 随后会载入之.
\ProcessKeyvalOptions*
\relax
% Package loading
\LoadClass{ctexbook}
\RequirePackage{ctex}
\RequirePackage{geometry}
\RequirePackage{fontspec}
\RequirePackage{bm}
\RequirePackage{mathrsfs}
\RequirePackage{amssymb}
\RequirePackage{mathtools}
% 加入字串处理功能
\RequirePackage{xstring}
% 设置天眉所需
\RequirePackage{fancyhdr}
\RequirePackage{graphicx}
\RequirePackage{float}
\RequirePackage{enumitem}
\RequirePackage{multicol}
\RequirePackage{pdfpages}
\RequirePackage{indentfirst}
\RequirePackage{ntheorem}
\RequirePackage{titlesec}
\RequirePackage{mismath} % 包含 rank, span 等运算符
\RequirePackage{zhnumber}
\RequirePackage{array}
\RequirePackage{arydshln}
\RequirePackage{tikz}
\RequirePackage{rotating}
\RequirePackage[many]{tcolorbox}
% Package settings
% ----------------
\titleformat{\section}{\centering\Large\bfseries}{\thesection}{1em}{}
\renewcommand{\vec}[1]{\boldsymbol{#1}} % 生成粗体向量,而非带箭头的向量
% 首行缩进 2 字符
\setlength{\parindent}{2em}
% 定理字体
\theoremheaderfont{\bfseries\heiti}
\theorembodyfont{\fangsong}
\usetikzlibrary{shapes.symbols}
% 设置页面尺寸
\IfStrEq{\@LALU@geometry}{16k}{% 载入 16k 版面设置
\geometry{
paperheight = 260mm,
paperwidth = 185mm,
top = 23mm,
bottom = 23mm,
left = 20mm,
right = 20mm,
headheight = 5ex,
headsep = 5ex,
textwidth = 132mm,
textheight = 198mm,
twoside,
asymmetric, % 单双数页不分
% bindingoffset = 18pt,
}}{}
\IfStrEq{\@LALU@geometry}{a4}{% 载入 a4 版面设置
\geometry{
a4paper,
twoside,
asymmetric,
}}{}
% 使空页恒空
\fancypagestyle{plain}{
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
}
% 嵌套 enumerate 环境的 label
\setlist[enumerate,2]{label=(\arabic*)}
\setlist[enumerate,3]{label=\roman*.}
\titleformat{\section}{\centering\Large\bfseries}{\thesection}{1em}{}
\DeclareMathOperator{\diag}{diag}
\tcbset{laluthmstyle/.style={
breakable,
colframe=#1!50!black,
coltitle=black,
colbacktitle=#1!5,
colback=white,
fonttitle=\bfseries,
leftrule=0pt,
rightrule=0pt,
enhanced jigsaw,
sharp corners,
toptitle=1mm,
bottomtitle=1mm,
separator sign={\quad},
toprule=1pt,
titlerule=1pt,
bottomrule=1pt,
overlay first={
\draw[thick,#1!50!black,dashed]
(frame.south west) -- (frame.south east);
},
overlay middle={
\draw[thick,#1!50!black,dashed]
(frame.north west) -- (frame.north east)
(frame.south west) -- (frame.south east);
},
overlay last={
\draw[thick,#1!50!black,dashed]
(frame.north west) -- (frame.north east);
},
}
}
\NewTColorBox{tcblaluthmbox}{mmm}{
laluthmstyle={teal},
colframe=teal!80!black,
title=#1\IfBlankF{#2}{\quad#2},
#3,
}
\NewDocumentEnvironment{proof}{O{}O{}}{\begin{tcblaluthmbox}{{\heiti 证明}}{#1}{#2}\fangsong}{\hspace*{\fill}$\square$\end{tcblaluthmbox}}
\NewDocumentEnvironment{solution}{O{}O{}}{\begin{tcblaluthmbox}{{\heiti 解}}{#1}{#2}\fangsong}{\end{tcblaluthmbox}}
\NewDocumentCommand{\term}{m}{{\sffamily\heiti\bfseries{#1}}}
\DeclareMathOperator{\Ob}{Ob}
\DeclareMathOperator{\Hom}{Hom}
\newcommand{\cC}{\mathcal{C}}
\newcommand{\cD}{\mathcal{D}}
\newcommand{\FVect}{\mathsf{FVect}}
\newcommand{\Set}{\mathsf{Set}}
\newcommand{\FSet}{\mathsf{FSet}}
\AtEndPreamble{
\RequirePackage[Bjornstrup]{fncychap} % found on Internet
% hyperref 与 cleveref 需要最后引入
\RequirePackage{hyperref}
\RequirePackage{bookmark}
\RequirePackage{cleveref}
\newtcbtheorem[number within=chapter]{definition}{定义}{laluthmstyle={red}}{def}
\newtcbtheorem[number within=chapter]{example}{例}{laluthmstyle={blue}}{ex}
\newtcbtheorem[number within=chapter]{lemma}{引理}{laluthmstyle={orange}}{lem}
\newtcbtheorem[number within=chapter]{theorem}{定理}{laluthmstyle={violet}}{thm}
\newtcbtheorem[number within=chapter]{corollary}{推论}{laluthmstyle={green}}{cor}
\newtcbtheorem[number within=chapter]{axiom}{公理}{laluthmstyle={olive}}{axm}
\hypersetup{
unicode,
bookmarksnumbered,
pdfborder={0 0 0},
}
% 按 colors 的 Bool 值设置链接色彩.
\if@LALU@colors
\hypersetup{
colorlinks,
% linkcolor=blue,
% citecolor=red,
% urlcolor=teal
}
\else
\hypersetup{hidelinks}
\fi
\renewcommand{\figureautorefname}{图}
\renewcommand{\tableautorefname}{表}
\renewcommand{\equationautorefname}{式}
\renewcommand{\chapterautorefname}{章}
\renewcommand{\sectionautorefname}{节}
\makeatletter
\newcommand{\tcb@cnt@theoremautorefname}{定理}
\newcommand{\tcb@cnt@lemmaautorefname}{引理}
\newcommand{\tcb@cnt@corollaryautorefname}{推论}
\newcommand{\tcb@cnt@exampleautorefname}{例}
\newcommand{\tcb@cnt@definitionautorefname}{定义}
\newcommand{\tcb@cnt@axiomautorefname}{公理}
\makeatother
\crefrangeformat{equation}{式~#3#1#4--#5#2#6}
\crefrangeformat{example}{例~#3#1#4--#5#2#6}
}