-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathbeamerouterthemenwafusidebar.sty
More file actions
executable file
·302 lines (278 loc) · 11.8 KB
/
beamerouterthemenwafusidebar.sty
File metadata and controls
executable file
·302 lines (278 loc) · 11.8 KB
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
% 这是nwafu(西北农林科技大学)边栏主题的外部主题.
% 版权(c) 2015-2016, 信息工程学院 耿楠<nangeng@nwafu.edu.cn>
%
% 本主题基于丹麦奥尔堡大学(Aalborg University)的AAU Beamer主题
% 有关这一主题的详情请参考:http://kom.aau.dk/~jkn/latex/latex.php
%
% 这是一个免费代码:发布和修改该代码,请遵守最新版的自由软件联盟发布
% 的GNU通用公共协议
%
% 期望这一代码对你有用,但值得注意的是,我不对任何后续问题进行维护,
% 请参考<http://www.gnu.org/licenses/>查看最新的协议内容。
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerouterthemenwafusidebar}[2019/06/14 v2.0.00 The nwafu Sidebar Beamer Theme]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 载入需要的宏包
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{tikz}
\usetikzlibrary{external}
\RequirePackage{calc}
\RequirePackage[font=Helv]{tdclock}% 时钟宏包,由于原tdclock用XeLaTeX编译时会有垂直方向遮挡,对其参数进行了调整,请使用当前目录下的tdclock.sty宏包
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 主题选项和定义
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% 主题选项
\newlength{\beamer@width}
\setlength{\beamer@width}{2cm}
\DeclareOptionBeamer{width}{\beamer@width=#1}
\DeclareOptionBeamer{left}{\def\beamer@sidebarside{left}}
\DeclareOptionBeamer{right}{\def\beamer@sidebarside{right}}
\DeclareOptionBeamer{hideothersubsections}[]{\beamer@nav@subsectionstyle{show/show/hide}}
\DeclareOptionBeamer{hideallsubsections}[]{\beamer@nav@subsectionstyle{hide}}
\DeclareOptionBeamer{hidetitle}{\def\beamer@hidetitle{true}}
\DeclareOptionBeamer{hideauthor}{\def\beamer@hideauthor{true}}
\DeclareOptionBeamer{hideinstitute}{\def\beamer@hideinst{true}}
\DeclareOptionBeamer{shownavsym}{\def\beamer@shownavsym{true}}
\ExecuteOptionsBeamer{left}
\ProcessOptionsBeamer
% 设置页眉高度为帧标题高度的1.3倍
\newlength{\beamer@height}
\usebeamerfont{frametitle} % 使用帧标题字体
\setlength{\beamer@height}{1.3\baselineskip}
\reset@font % 恢复字体
\def\beamer@lefttext{left} %为了后面的比较
% 分割主文本区域和边栏的分割条的宽度
\newlength{\beamer@barwidth}
\setlength{\beamer@barwidth}{2\beamer@height/40} % 分割条宽度取决于页眉的高度(比例系数是20,于建涛老师建议窄点好,2015.07.09)
%\setbeamertemplate{headline}{\initclock}%启动计时器
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% beamer特殊选项
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mode<presentation>% 参考前四个模式(beamer,handout,second and trans).也就是说,除article外的所有模式
{
\ifbeamercolorempty[fg]{nwafusidebar}{%
% 如果没有定义边栏颜色主题,则定义(主要是因为未载入nwafusidebar颜色主题)
\setbeamercolor{nwafusidebar}{use={structure,palette sidebar primary},fg=palette sidebar primary.fg,bg=structure.fg}%
}{%
% nwafu页眉已定义,什么都不用处理
}
\setbeamersize{sidebar width \beamer@sidebarside=\beamer@width}%
\setbeamersize{text margin left=0.5cm,text margin right=0.5cm}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 模板
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % 页眉线
\defbeamertemplate*{headline}{nwafusidebar theme}{%
\nwafuheaderbackground%
}%
% 帧标题
\defbeamertemplate*{frametitle}{nwafusidebar theme}{%
\ifx\beamer@sidebarside\beamer@lefttext% 边栏在左边
\hfill%
\fi%
\begin{minipage}[c][\beamer@height][c]{\textwidth-\beamer@height/2}%
{\usebeamercolor[fg]{framesubtitle}\usebeamerfont{frametitle}\insertframesubtitle\hfill\usebeamercolor[fg]{frametitle}\usebeamerfont{frametitle}|\insertframetitle\par}%
\end{minipage}%
\ifx\beamer@sidebarside\beamer@righttext% 边栏在右边
\hfill%
\fi%
}
% 边栏
\defbeamertemplate*{sidebar \beamer@sidebarside}{nwafusidebar theme}{%
\nwafusidebarbackground%
\vspace{\beamer@height}%
\vspace{2\baselineskip}\par%
\ifx\beamer@hidetitle\undefined% 短标题
\vspace{-\baselineskip}%
\hspace{0.05\beamer@width}%
{%
\usebeamercolor[fg]{title in sidebar}%
\usebeamerfont{title in sidebar}%
\insertshorttitle[width={0.9\beamer@width},center,respectlinebreaks]%
}%
\hspace{0.05\beamer@width}%
\vspace{2\baselineskip}\par%
\fi%
\ifx\beamer@hideauthor\undefined% 作者缩写
\vspace{-\baselineskip}%
\hspace{0.05\beamer@width}%
{%
\usebeamercolor[fg]{author in sidebar}%
\usebeamerfont{author in sidebar}%
\insertshortauthor[width={0.9\beamer@width},center,respectlinebreaks]%
}%
\hspace{0.05\beamer@width}%
\vspace{\baselineskip}\par%
\fi%
\insertverticalnavigation{1.0\beamer@width}%
\strut\vfill%
\ifx\beamer@hideinst\undefined% 单位缩写
\vbox{\hspace{0.05\beamer@width}%
{%
\usebeamercolor[fg]{title in sidebar}%
\usebeamerfont{subtitle in sidebar}%
\insertshortinstitute[width={0.9\beamer@width},center,respectlinebreaks]%
}%
\hspace{0.05\beamer@width}%
\vspace*{\baselineskip}%
}%
\fi%
\ifx\beamer@shownavsym\undefined% 导航符号
% 什么都不做
\else%
% 如果边栏在右边,插入导航符号
\ifx\beamer@sidebarside\beamer@lefttext % 边栏在左边
% 什么都不做
\else%
\vspace*{-2\baselineskip}%
\llap{\usebeamertemplate***{navigation symbols}\hskip0.4cm}%
\vskip2pt%
\fi%
\fi%
}%
% 当边栏在左边时,默认主题将logo放置在右下角(边栏在右边时不存在这一问题),在此删除这个logo.
\ifx\beamer@sidebarside\beamer@lefttext % 边栏在左边
\defbeamertemplate*{sidebar right}{nwafusidebar theme}{%
% 删除logo,插入导航符号
\ifx\beamer@shownavsym\undefined% 插入导航符号
%什么都不做
\else % 插入导航符号
\vfill%
\llap{\usebeamertemplate***{navigation symbols}\hskip0.4cm}%
\vskip2pt%
\fi%
}%
\fi%
% 边栏中的当前section
\defbeamertemplate*{section in sidebar}{nwafusidebar theme}{%
\vbox{%
\vskip1ex% 插入一个新section时,增加一个额外的距离
\sidebarnavitem{4pt}{section in sidebar}{%
\sidebarcurframe{\insertframenumber}%
\insertsectionhead%
}%
}%
}%
% 除了当前section外的其它section
\defbeamertemplate*{section in sidebar shaded}{nwafusidebar theme}{%
\vbox{%
\vskip1ex% 插入一个新section时,增加一个额外的距离
\sidebarnavitem{4pt}{section in sidebar shaded}{\insertsectionhead}%
}%
}%
% 边栏中的当前subsection
\defbeamertemplate*{subsection in sidebar}{nwafusidebar theme}{%
\sidebarnavitem{6pt}{subsection in sidebar}{%
\sidebarcurframe{\insertframenumber}%
\insertsubsectionhead%
}%
}%
% 除了当前subsection外的其它subsection
\defbeamertemplate*{subsection in sidebar shaded}{nwafusidebar theme}{%
\sidebarnavitem{6pt}{subsection in sidebar shaded}{\insertsubsectionhead}%
}%
% 边栏中的当前subsubsection
\defbeamertemplate*{subsubsection in sidebar}{nwafusidebar theme}{%
\sidebarnavitem{8pt}{subsubsection in sidebar}{%
\sidebarcurframe{\insertframenumber}%
\insertsubsubsectionhead%
}%
}%
% 除了当前subsubsection外的其它subsubsection
\defbeamertemplate*{subsubsection in sidebar shaded}{nwafusidebar theme}{%
\sidebarnavitem{8pt}{subsubsection in sidebar shaded}{\insertsubsubsectionhead}%
}%
\ifx\beamer@shownavsym\undefined% 插入导航符号
\setbeamertemplate{navigation symbols}{%
% 禁用导航符号
}%
\fi%
}% 结束beamer特殊选项设置
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 主题中要用到的宏
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 漂亮的页眉背景
\newcommand{\nwafuheaderbackground}[0]{%
\tikzexternaldisable%
\begin{tikzpicture}[overlay]%
\ifx\beamer@sidebarside\beamer@lefttext% 边栏在左边
\coordinate (UC) at (\paperwidth,0); % 右上角
\coordinate (LC) at (0,-\paperheight); % 左下角
\coordinate (BS) at (\paperwidth,-\beamer@height); % 分割条的起始坐标
\coordinate (BE) at (\beamer@width+\beamer@barwidth/2,-\paperheight); % 分割条的终止坐标
\coordinate (UW) at (\beamer@width/2 - \beamer@height/4, 0); % 边栏顶边水平中点
\else% 边栏在右边
\coordinate (UC) at (0,0); % 左上角
\coordinate (LC) at (\paperwidth,-\paperheight); % 右下角
\coordinate (BS) at (0,-\beamer@height); % 分割条起始坐标
\coordinate (BE) at (\paperwidth-\beamer@width-\beamer@barwidth/2,-\paperheight); % 分割条终止坐标
\coordinate (UW) at (\paperwidth-\beamer@width/2+\beamer@height/4, 0); % 边栏水平顶边中点
\fi%
\coordinate (IS) at (BS -| BE); % 求过BS的水平线与过BE的垂直线的交点
\coordinate (logopos) at ([yshift=\beamer@height/2] IS);% logo的坐标
\coordinate (tdclockpos) at (logopos -| UW);% 时钟中心坐标
% 绘制页眉背景、圆和logo
{\usebeamercolor{frametitle}%
\usebeamercolor{nwafusidebar}%
\draw[draw=none,fill=frametitle.bg] (UC) rectangle (IS -| LC);% 标题栏背景
\fill[fill=nwafusidebar.fg] ([yshift=\beamer@height/2] IS) circle (1.0*\beamer@height/2);% logo背景
\node at (logopos){\includegraphics[width=0.96\beamer@height]{nwafulogo/circle}};% 圆形logo
\node[anchor=center, frametitle.fg] at (tdclockpos){\factorclockfont{1.7}\hhmm\tdtime};% 布置时钟
}%
\end{tikzpicture}%
\tikzexternalenable%
}%
% 漂亮的边栏背景
\newcommand{\nwafusidebarbackground}[0]{%
\tikzexternaldisable
\begin{tikzpicture}[remember picture,overlay]%
\ifx\beamer@sidebarside\beamer@lefttext% 边栏在左边
\coordinate (BS) at (\paperwidth,-\beamer@height); % 分割条的起始坐标
\coordinate (BE) at (\beamer@width+\beamer@barwidth/2,-\paperheight); % 分割条的终止坐标
\else% 边栏在右边
\coordinate (BS) at (-\paperwidth+\beamer@width,-\beamer@height); % 分割条的起始坐标
\coordinate (BE) at (-\beamer@barwidth/2,-\paperheight); % 分割条的终止坐标
\fi%
\coordinate (IS) at (BS -| BE); % 求过BS的水平线与过BE的垂直线的交点
% 绘制粗线
{\usebeamercolor{nwafusidebar}%
\draw[color=fg,line width=\beamer@barwidth] (IS) -- (BE);%
}%
% 绘制带圈的帧总数数字
{\usebeamercolor{palette sidebar primary}%
\usebeamercolor{nwafusidebar}%
\usebeamerfont{subsection in sidebar}%
\node[fill=palette sidebar primary.bg,draw=nwafusidebar.fg,circle,very thick,minimum width=4mm] at ([yshift=2mm] BE) {{\usebeamercolor[fg]{subsection in sidebar}\inserttotalframenumber}};%
}%
\end{tikzpicture}%
\tikzexternalenable%
}
% 边栏导航条目
\newcommand{\sidebarnavitem}[3]{%
\begin{beamercolorbox}[wd=\beamer@width,leftskip=#1,rightskip=1ex plus1fil,vmode]{#2}%
%\vbox{}% 插入空白线
#3\par%
\vbox{}% 插入空白线
\vskip-1.5ex%
\end{beamercolorbox}%
}%
% 当前帧数
\newcommand{\sidebarcurframe}[1]{%
\tikzexternaldisable%
\begin{tikzpicture}[remember picture,overlay]%
\coordinate (CS) at (0,0.8ex); % 当前section标记的坐标
\coordinate (CF) at (IS |- CS); % 当前帧数的坐标
{%
\usebeamercolor{palette sidebar primary}%
\usebeamercolor{nwafusidebar}%
\draw[color=bg,line width=\beamer@barwidth] (IS) -| (CF);%
\node[fill=palette sidebar primary.bg,draw=nwafusidebar.fg,circle,minimum width=3.5mm,thick] at (CF) {{\fontsize{4}{5}\selectfont{\usebeamercolor[fg]{subsection in sidebar}#1}}};%
}%
\end{tikzpicture}%
\tikzexternalenable%
}%
\mode<all>
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "main.tex"
%%% End: