forked from icgw/ucas-beamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beamerthemeucas.sty
238 lines (191 loc) · 7.9 KB
/
beamerthemeucas.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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerthemeucas}[2019/11/26]
\mode<presentation>
\DeclareOptionBeamer{sign}{\def\ucasbeamer@option@sign{#1}}
\ExecuteOptionsBeamer{sign=UCAS}
\DeclareOptionBeamer{logo}{\def\ucasbeamer@option@logo{#1}}
\ExecuteOptionsBeamer{logo=AMSS}
\RequirePackage{booktabs}
\RequirePackage[silent]{fontspec}
\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}
\RequirePackage{csquotes}
\RequirePackage{ctex}
% 设置字体
\usefonttheme{professionalfonts}
\setromanfont{Times New Roman}% 设置 Times New Roman 为默认的英文字体
\setsansfont{Arial}
\renewcommand*{\em}{\kaishu}
\ProcessOptionsBeamer
% 定义标志 (sign) 和 徽章 (logo) 的文件夹路径
\def\ucasbeamer@pathname@sign{sign/}
\def\ucasbeamer@pathname@logo{logo/}
% 定义标志及徽章的文件名
\def\ucasbeamer@filename@sign{%
\ucasbeamer@pathname@sign \ucasbeamer@option@sign%
}
\def\ucasbeamer@filename@logo{%
\ucasbeamer@pathname@logo \ucasbeamer@option@logo%
}
% --------------------------------- 预设长度 --------------------------------- %
% 定义边界间隔距离
\newlength\ucasbeamer@length@margin
\ucasbeamer@length@margin = 14pt
% 定义页脚占据的高度
\newlength\ucasbeamer@length@footlineheight
\ucasbeamer@length@footlineheight = 8pt
% 定义页脚与底边界的距离
\newlength\ucasbeamer@length@footlinebottompadding
\ucasbeamer@length@footlinebottompadding = 6pt
% 定义徽章的最大宽度、最大高度
\newlength\ucasbeamer@length@logomaxwidth
\ucasbeamer@length@logomaxwidth = 72pt
\newlength\ucasbeamer@length@logomaxheight
\ucasbeamer@length@logomaxheight = 36pt
% 定义展示页面标题与上边界的间隔
\newlength\ucasbeamer@length@toppadding
\ucasbeamer@length@toppadding = 24pt
% 定义扉页 (title page) 左上角标志的高度
\newlength\ucasbeamer@length@signheight@titlepage
\ucasbeamer@length@signheight@titlepage = 42pt
% 定义扉页之后 (Not title page) 左上角标志的高度
\newlength\ucasbeamer@length@signheight
\ucasbeamer@length@signheight = 28pt
% --------------------------------- 预设颜色 --------------------------------- %
\definecolor{ucasbeamer@base}{RGB}{0, 64, 152} % 底色:孔雀蓝
\definecolor{ucasbeamer@graybase}{RGB}{240, 240, 240}
\definecolor{ucasbeamer@gray}{RGB}{130, 130, 130}
\definecolor{ucasbeamer@orange}{RGB}{240,140,0}
\definecolor{ucasbeamer@red}{RGB}{210, 26, 66}
\definecolor{ucasbeamer@green}{RGB}{0, 127, 0}
% -------------------------------- 自定义命令 -------------------------------- %
\providecommand{\red}[1]{{\color{ucasbeamer@red}{#1}}}
\providecommand{\green}[1]{{\color{ucasbeamer@green}{#1}}}
% -------------------------------- 自定义设置 -------------------------------- %
% 使用页眉(章节题目)
\useoutertheme{infolines}
% 设置页码边距
\setbeamersize{%
text margin left=\ucasbeamer@length@margin,
text margin right=\ucasbeamer@length@margin}
% 设置展示页面的标题与副标题
\setbeamertemplate{frametitle}{%
\vskip\ucasbeamer@length@toppadding
\vtop{{%
\usebeamerfont{frametitle}{\insertframetitle}%
\ifx\insertframesubtitle\@empty\else\\
\usebeamerfont{framesubtitle}{\insertframesubtitle}
\fi}
\vfill}}
% 取消底部的导航栏
\setbeamertemplate{navigation symbols}{}
% 设置背景
\setbeamertemplate{background canvas}{%
\ifnum\value{page} = 1
\let\ucasbeamer@temp@length\ucasbeamer@length@signheight@titlepage
\else
\let\ucasbeamer@temp@length\ucasbeamer@length@signheight
\fi
\leavevmode\hskip\ucasbeamer@length@margin
\includegraphics[height = \ucasbeamer@temp@length]%
{\ucasbeamer@filename@sign}%
}
% 设置页脚的信息(姓名、题目、日期、页码)
\setbeamertemplate{footline}{%
\hskip\ucasbeamer@length@margin
\usebeamercolor[fg]{author in head/foot}%
\usebeamerfont{author in head/foot}\insertshortauthor
\ \lower2pt\hbox{\Large$\cdot$}\
\usebeamercolor[fg]{title in head/foot}%
\usebeamerfont{title in head/foot}\insertshorttitle
\ \lower2pt\hbox{\Large$\cdot$}\
\usebeamercolor[fg]{date in head/foot}%
\usebeamerfont{date in head/foot}\insertshortdate
\hfill
\insertframenumber{} / \inserttotalframenumber
\hskip\ucasbeamer@length@margin
\vrule width 0pt height \ucasbeamer@length@footlineheight
depth \ucasbeamer@length@footlinebottompadding}
% 设置扉页
\setbeamertemplate{title page}{%
\vfill
\begin{center}
{\usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle}%
\smallskip
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle}%
\vfill
{\usebeamerfont{author} \insertauthor}%
\medskip
{\usebeamerfont{institute} \insertinstitute}%
\medskip
\includegraphics%
[
width = .6\textwidth,
height = .15\textheight,
keepaspectratio
]{\ucasbeamer@filename@logo}%
\vfill
{\usebeamerfont{date}\centering \insertdate}%
\end{center}
}
% 设置结构 (structure) 的字体及前景颜色
\setbeamerfont{structure}{series = \bfseries}
\setbeamercolor{structure}{fg = ucasbeamer@gray}
% 设置警示 (alerted) 的字体及前景颜色
\setbeamerfont{alerted text}{series = \bfseries}
\setbeamercolor{alerted text}{fg = ucasbeamer@orange}
% 设置题目 (title) 的字体、大小及颜色
\setbeamerfont{title}{size = \Large, series = \bfseries}
\setbeamercolor{title}{fg = ucasbeamer@base}
\setbeamerfont{title in head/foot}{size = \tiny, series = \bfseries}
\setbeamercolor{title in head/foot}{parent = structure}
% 设置作者的字体及大小
\setbeamerfont{author}{series = \bfseries, size = \small}
\setbeamerfont{author in head/foot}{size = \tiny, series = \bfseries}
\setbeamercolor{author in head/foot}{parent = structure}
% 设置日期的字体大小
\setbeamerfont{date}{size = \footnotesize}
\setbeamerfont{date in head/foot}{size = \tiny, series = \bfseries}
\setbeamercolor{date in head/foot}{parent=structure}
% 设置项目符号 (item) 为方形 (square)
\setbeamertemplate{itemize items}[square]
% 设置 脚注 (footnote) 的字体大小、脚注的标号属性
\setbeamerfont{footnote}{size = \footnotesize}
\setbeamercolor{footnote mark}{parent = structure}
% 设置幻灯片标题、副标题、章节、子章节的字体及大小
\setbeamerfont{frametitle}{size = \Large, series = \bfseries}
\setbeamercolor{frametitle}{parent = title}
\setbeamerfont{framesubtitle}{size = \large, series = \bfseries}
\setbeamercolor{framesubtitle}{parent = subtitle}
\setbeamerfont{section in head/foot}{parent = structure}
\setbeamercolor{section in head/foot}{parent = structure}
\setbeamerfont{subsection in head/foot}{parent = normal text}
\setbeamercolor{subsection in head/foot}{parent = structure}
% 设置展示块是否有阴影显示
\setbeamertemplate{blocks}[rounded][shadow = true]
% 设置展示块,一般块、示例块、警醒块 (block title) 的标题颜色,前景色与背景色
\setbeamercolor{block title}{fg = white, bg = ucasbeamer@base}
\setbeamercolor{block title example}{%
use = alerted text, fg = white, bg = ucasbeamer@gray}
\setbeamercolor{block title alerted}{%
use = alerted text, fg = white, bg = ucasbeamer@orange}
% 设置展示块内容的文本颜色、背景颜色
\setbeamercolor{block body}{%
parent = normal text, use = block title,
bg = block title.bg!10!bg}
\setbeamercolor{block body example}{%
parent = normal text, bg = ucasbeamer@graybase}
\setbeamercolor{block body alerted}{%
parent = normal text, use = block title alerted,
bg = block title alerted.bg!10!bg}
\setbeamertemplate{bibliography item}{%
\ifboolexpr{ test {\ifentrytype{book}} or test {\ifentrytype{mvbook}}
or test {\ifentrytype{collection}} or test {\ifentrytype{mvcollection}}
or test {\ifentrytype{reference}} or test {\ifentrytype{mvreference}} }
{\setbeamertemplate{bibliography item}[book]}
{\ifentrytype{online}
{\setbeamertemplate{bibliography item}[online]}
{\setbeamertemplate{bibliography item}[article]}}%
\usebeamertemplate{bibliography item}}
\mode<all>
\endinput