-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook.sty
296 lines (230 loc) · 8.1 KB
/
book.sty
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
% 一种书籍的风格,对中文处理较好。
%
% by wanze
% LPPL LaTeX Public Project License
%
%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{book}
%盒子填不满容忍?
%\hbadness=10000
%宏包编写基本命令。
%\def\hi{Hello, this is my own package}
%\let\myDate\date
%\newcommand\GoodBye[1][\bfseries]{{#1Good Bye}}
\newlength{\textpt}
\setlength{\textpt}{11pt}
%额外的一些命令
\newcommand\utriangle{\bgroup\markoverwith
{\raisebox{-0.4em}{\makebox[1em][c]{\tikz[blue]{\draw(0,0) -- (0.1,0) -- (0.05,0.05) --cycle;}}}}
\ULon}
\newcommand\ucircle{\bgroup\markoverwith
{\raisebox{-0.6em}{\makebox[1em][c]{\tikz[red]{\draw(0,0) circle (0.05) ;}}}}
\ULon}%
\newcommand{\flypage}[1]{\begin{titlepage}\begin{center}\vspace*{\stretch{1}}#1\vspace*{\stretch{1}}\end{center}\end{titlepage}}
%========基本必备的宏包========%
\RequirePackage{calc,float,multicol,moresize}
%\RequirePackage[onehalfspacing]{setspace}
\linespread{1.5}
%1.3 onehalfspacing
%试卷或需要文字紧凑的
%1.6 doublespacing
%===========加入目录 某章或某节=====%
\newcommand{\addchtoc}[1]{
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{#1}}
\newcommand{\addsectoc}[1]{
\phantomsection
\addcontentsline{toc}{section}{#1}}
%===========全文基本格式==========%
\setlength{\parskip}{1.6ex plus 0.2ex minus 0.2ex} %段落間距
\setlength{\parindent}{\textpt * \real{2}}
%=========页面设置=========%
\RequirePackage[a4paper, %a4paper size 297:210 mm
bindingoffset=10mm,%裝訂線
top=35mm, %上邊距 包括頁眉
bottom=30mm,%下邊距 包括頁腳
inner=10mm, %左邊距or inner
outer=10mm, %右邊距or outer
headheight=10mm,%頁眉
headsep=15mm,%
footskip=15mm,%
marginparsep=10pt, %旁註與正文間距
marginparwidth=6em,includemp=true% 旁註寬度計入width%旁註寬度
]{geometry}
%color
\RequirePackage[table,svgnames]{xcolor}
\definecolor{bgcolor-0}{HTML}{CCFFCC}
%================字體================%
%设置数学字体
\RequirePackage{amssymb,amsmath}
\RequirePackage{fontspec}
%si unit
\RequirePackage{siunitx}
\sisetup{
math-micro = \text{μ},
text-micro = μ
}
%num命令两边加上空格 numb
\providecommand{\numb}[1]{{~\num{#1}~}}
\providecommand{\abs}[1]{\lvert#1\rvert}
\everymath{\displaystyle}
%設置英文字體
\setmainfont[Mapping=tex-text]{DejaVu Serif}
\setsansfont[Mapping=tex-text]{DejaVu Sans}
\setmonofont[Mapping=tex-text]{DejaVu Sans Mono}
%中文環境
\RequirePackage[]{xeCJK}
\xeCJKsetup{PunctStyle=plain}
\setCJKmainfont[BoldFont=Adobe 黑体 Std,ItalicFont=Adobe 楷体 Std]
{Adobe 宋体 Std}%影響rmfamily字體
\setCJKsansfont{Adobe 黑体 Std}%影響sffamily字體
\setCJKmonofont{Adobe 楷体 Std}%影響ttfamily字體
\RequirePackage{xltxtra} %put here to avoid some package option error. maybe this package is useless ?
%%===============中文化=========%
\renewcommand\contentsname{目~录}
\renewcommand\listfigurename{插图目录}
\renewcommand\listtablename{表格目录}
\renewcommand\bibname{参~考~文~献}
\renewcommand\indexname{索~引}
\renewcommand\figurename{图}
\renewcommand\tablename{表}
\renewcommand\partname{部分}
\renewcommand\appendixname{附录}
\renewcommand{\today}{\number\year 年\number\month 月\number\day 日}
%=======页眉页脚格式=========%
\RequirePackage{fancyhdr} %頁眉頁腳
\RequirePackage{zhnumber} %计数器中文化
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]
{\markright{第\zhnumber{\arabic{section}}节~~#1}{}}
\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhf[HR]{\ttfamily \footnotesize \rightmark }
\fancyhf[FR]{\thepage}}
\pagestyle{plain}
%=========章節標題設計=========%
\RequirePackage{titlesec}
%修改part
\titleformat{\part}{\huge\sffamily}{}{0em}{}
%修改chapter
\titleformat{\chapter}{\LARGE\sffamily}{}{0em}{}
%修改section
\titleformat{\section}{\Large\sffamily}{}{0em}{}
%修改subsection
\titleformat{\subsection}{\large\sffamily}{}{0em}{}
%修改subsubsection
\titleformat{\subsubsection}{\normalsize\sffamily}{}{0em}{}
%================目录===============%
%toc label to contents space dynamic adjust
\RequirePackage{tocloft}%
\renewcommand{\numberline}[1]{%
\@cftbsnum #1\@cftasnum~\@cftasnumb%
}
%==============超鏈接===============%
\RequirePackage[colorlinks=true,linkcolor=blue,citecolor=blue]{hyperref} %設置書簽和目錄鏈接等
\newcommand{\hlabel}[1]{\phantomsection \label{#1}}%某一小段的引用
%=================文字強調=========%
\RequirePackage{ulem} %下劃線,加點
\normalem%normal em , not instead of the uline
\DeclareRobustCommand*{\uwave}%波浪线稍微下移点。
{\bgroup \markoverwith{\lower5\p@\hbox{\sixly \char58}}\ULon}
\newcommand\reduline{\bgroup\markoverwith
{\textcolor{red}{\rule[-0.5ex]{1em}{0.4pt}}}\ULon}
%modified udot command from the dotuline
\def\udot{\bgroup
\UL@setULdepth
\markoverwith{\begingroup
\advance\ULdepth0.1ex
\lower\ULdepth\hbox{\kern.25em . \kern.045em}%
\endgroup}%
\ULon}
\renewcommand\emshape{\color{red}}
%==================插入圖片=======%
\RequirePackage{wrapfig}
\RequirePackage{graphicx}
\graphicspath{{figures/}}
%change the caption style a little like 1-1
\renewcommand{\thefigure}{\arabic{chapter}-\arabic{figure}}
\newenvironment{fig}[2][1]
{\begin{figure}[H]
\centering
\includegraphics[scale=#1 , keepaspectratio]{#2}}
{\end{figure}}
\newenvironment{linefig}[2][1]
{\begin{figure}[H]
\centering
\includegraphics[width=#1\linewidth ,totalheight=0.95\textheight , keepaspectratio]{#2}}
{\end{figure}}
%==============插入表格========%
\RequirePackage{booktabs}
\renewcommand{\thetable}{\arabic{chapter}-\arabic{table}}
\RequirePackage{caption}
%\renewcommand{\arraystretch}{1.3}
%如果用setspace宏包而不是linespread调整行间距,那么才需要额外的表格行距拉大。
%=============插入尾注=========%
\RequirePackage{endnotes}
%==========其他宏包===========%
\RequirePackage{tikz}
\usetikzlibrary{calc}
%========脚注=========%
\newcommand*\circled[1]{%
\tikz[baseline=(char.base)]\node[shape=circle,draw,inner sep=0.4pt,minimum size=4pt] (char) {#1};}
\newcommand*\circledarabic[1]{\circled{\arabic{#1}}}
\RequirePackage{perpage} %the perpage package
\MakePerPage{footnote} %the perpage package command
\renewcommand*{\thefootnote}{\protect\circledarabic{footnote}}
\renewcommand\@makefntext[1]
{\vspace{5pt}
\noindent
\makebox[20pt][c]{\@makefnmark}
\fontsize{10pt}{12pt}\selectfont #1}
\setlength{\skip\footins}{20pt plus 10pt}
%main body 与脚注之间的距离
%===========旁注===========%
\newcommand{\notefont}{\itshape\fontsize{10pt}{10pt}\selectfont }
\newcommand{\sidenote}[1]{\marginpar{\notefont #1}}
%=====特殊的环境特殊的文字======%
%=========重新定义 quote=====%
\renewenvironment{quote}[1][anonymous]{
\newcommand{\quoteauthor}[1][anonymous]{#1}
\list{}{\rightmargin\leftmargin %右间距等于左间距
\itemindent 2em
}\item\relax
\ttfamily}
{\\
\makebox[\linewidth][r]{\sffamily —\quoteauthor}
\endlist}
%重新定义quotation
\renewenvironment{quotation}
{\list{}{\rightmargin\leftmargin %右间距等于左间距
\itemindent 2em%item的缩进也就是第一段的缩进
\listparindent \itemindent %第二段的缩进
}%
\item\relax
\ttfamily}
{\endlist}
%framed环境
\RequirePackage{framed}
%======notecard环境 一种卡片式记忆环境====%
%推荐的颜色有:black olive blue orange brown pink cyan purple darkgray red gray teal green violet lightgray white lime magenta yellow 建议都调淡30。!30
%不过推荐一个文档内部一种类型使用一种,其他颜色也是可以的。
\newsavebox{\tempbox}
\newenvironment{notecard}[2][white]
{\noindent\ignorespaces%
\setlength{\fboxsep}{10pt}
\newcommand{\tempcolor}{#1}
\begin{lrbox}{\tempbox}%
\begin{minipage}{#2}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1.618ex} %段落間距
}
{
\ignorespacesafterend%
\end{minipage}%
\end{lrbox}%
\colorbox{\tempcolor}{\usebox{\tempbox}}}
\endinput