-
Notifications
You must be signed in to change notification settings - Fork 3
/
beamerinnerthemechamfered.sty
232 lines (199 loc) · 9.25 KB
/
beamerinnerthemechamfered.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
% LaTeX Beamer inner theme "chamfered"
%
% Copyright Christian Gogolin 2011 (beamer@cgogolin.de)
%
% http://www.cgogolin.de
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% features: - Boxes with arbitrary rounding radius, content-to-box-
% boder and head-to-body distance, customizable via the
% [corners=] and [padding=] options. Both are set to a
% default value of 2pt.
% - A drop shadow that can be activated with the [shadow]
% option that is compatible with all box shapes(!).
% - A real drop shadow that can be activated with the [realshadow]
% option that is compatible with all box shapes(!) and is really opaque.
% - A surrounding outline can be activated by giving the
% [outline] options.
% - Draws the whole box "at once" (and not in two steps, as
% the normal beamer colorbox does) using the TikZ-Package
% and thus has a very easy to read code structure.
%
% problems: - Uses your TikZ-Package (Not really a problem, I think.)
% - Overwrites the "\beamerboxesrounded" and the
% "\endbeamerboxesrounded" commands. (Not really a problem
% as well, I think.)
%
% to do: - Jet no custom parts page and only a very minimal
% title page.
% - Perhaps add custom "items" and "sections/subsections in
% toc" templates.
\RequirePackage{keyval}
\RequirePackage{tikz}
\RequirePackage{mathtools}
\newif\ifbeamer@chamfered@shadow
\DeclareOptionBeamer{shadow}[true]{\csname beamer@chamfered@shadow#1\endcsname}
\ExecuteOptionsBeamer{shadow=false}
\newif\ifbeamer@chamfered@realshadow
\DeclareOptionBeamer{realshadow}[true]{\csname beamer@chamfered@realshadow#1\endcsname}
\ExecuteOptionsBeamer{realshadow=fal1se}
\newif\ifbeamer@chamfered@outline
\DeclareOptionBeamer{outline}[true]{\csname beamer@chamfered@outline#1\endcsname}
\ExecuteOptionsBeamer{outline=false}
\newdimen\bmb@corners
\DeclareOptionBeamer{corners}{\bmb@corners=#1}
\ExecuteOptionsBeamer{corners=2pt}
\newdimen\bmb@padding
\DeclareOptionBeamer{padding}{\bmb@padding=#1}
\ExecuteOptionsBeamer{padding=2pt}
\ProcessOptionsBeamer
\mode<presentation>
\newdimen\bmb@headheight
\newdimen\bmb@headdepth
\newdimen\bmb@bodyheight
\newdimen\bmb@bodydepth
%\newdimen\bmb@corners
%\newdimen\bmb@padding
\newdimen\bmb@headbodyseperation
\newlength{\tmpa}
\newbox\bmb@headbox
\newbox\bmb@bodybox
\define@key{beamerboxes}{realshadow}[false]{\csname bmb@realshadow#1\endcsname}
\define@key{beamerboxes}{outline}[false]{\csname bmb@outline#1\endcsname}
\renewcommand\beamerboxesrounded[2][]{%
\global\let\beamer@firstlineitemizeunskip=\relax%
\vbox\bgroup%
\setkeys{beamerboxes}{upper=block title,lower=block body,width=\textwidth,shadow=false,realshadow=false}%
\setkeys{beamerboxes}{#1}%
{%
\usebeamercolor{\bmb@lower}%
\globalcolorstrue%
\colorlet{lower.bg}{bg}%
}%
{%
\usebeamercolor{\bmb@upper}%
\globalcolorstrue%
\colorlet{upper.bg}{bg}%
}%
% lengths are set via beameroptions
% \bmb@corners=2pt
% \bmb@padding=2pt
%
\setbox\bmb@headbox=\hbox{%
\begin{minipage}[b]{\bmb@width-\bmb@corners-\bmb@corners-\bmb@padding-\bmb@padding}%
\usebeamercolor[fg]{\bmb@upper}%
#2%
\end{minipage}}%
\ifdim\wd\bmb@headbox=0pt%
\setbox\bmb@headbox=\hbox{}%
\ht\bmb@headbox=0pt%
\dp\bmb@headbox=0pt%
\bmb@headheight=0pt%
\bmb@headdepth=1.4ex%
\bmb@headbodyseperation=0pt%
{\usebeamercolor{\bmb@lower}% make head and body bg color equal if head is empty
\globalcolorstrue%
\colorlet{upper.bg}{bg}}%
\else
\bmb@headheight=\ht\bmb@headbox
\bmb@headdepth=1.5ex%
\bmb@headbodyseperation=\bmb@padding
\fi%
\setbox\bmb@bodybox=\hbox\bgroup\begin{minipage}[b]{\bmb@width-\bmb@corners-\bmb@corners-\bmb@padding-\bmb@padding}%
\usebeamercolor[fg]{\bmb@lower}%
\colorlet{beamerstructure}{upper.bg}%
\colorlet{structure}{upper.bg}%
}
\def\endbeamerboxesrounded{%
\end{minipage}\egroup%
% Fix by Vasyl
\bmb@temp=\dp\bmb@bodybox%
\setbox\bmb@bodybox=\hbox{\raise\bmb@temp\hbox{\box\bmb@bodybox}}%
\dp\bmb@bodybox=0pt%
\ifdim\wd\bmb@bodybox=0pt%
\setbox\bmb@bodybox=\hbox{}%
\ht\bmb@bodybox=0pt%
\dp\bmb@bodybox=0pt%
\bmb@bodyheight=1pt%
\bmb@bodydepth=\bmb@padding%
\else
\bmb@bodyheight=\ht\bmb@bodybox\advance\bmb@headheight by\bmb@corners
\bmb@bodydepth=1.5ex%
\fi%
\begin{tikzpicture}
\ifbeamer@chamfered@shadow%
\foreach \x in {75,50,15}
{
\setlength{\tmpa}{1.25pt * 1/75 * \real{\x}}
\fill[xshift=0.4pt,yshift=-0.5pt,fill=lower.bg!\x!black,rounded corners=\bmb@corners] (-\tmpa,-\bmb@headdepth-\bmb@headbodyseperation) -- (-\tmpa,\bmb@headheight+\bmb@padding+0.5pt+\tmpa) -- (\bmb@width+\tmpa,\bmb@headheight+\bmb@padding+0.5pt+\tmpa) -- (\bmb@width+\tmpa,-\bmb@headdepth-\bmb@headbodyseperation) -- (\bmb@width+\tmpa,-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight-\bmb@bodydepth-\bmb@padding-\bmb@corners-\tmpa) -- (-\tmpa,-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight-\bmb@bodydepth-\bmb@padding-\bmb@corners-\tmpa) -- (-\tmpa,-\bmb@headdepth-\bmb@headbodyseperation);
}
\fi
\ifbeamer@chamfered@realshadow%
\foreach \x in {75,50,15}
{
\setlength{\tmpa}{1.25pt * 1/75 * \real{\x}}
\fill[xshift=0.4pt,yshift=-0.5pt,fill=black,opacity=0.3,rounded corners=\bmb@corners] (-\tmpa,-\bmb@headdepth-\bmb@headbodyseperation) -- (-\tmpa,\bmb@headheight+\bmb@padding+0.5pt+\tmpa) -- (\bmb@width+\tmpa,\bmb@headheight+\bmb@padding+0.5pt+\tmpa) -- (\bmb@width+\tmpa,-\bmb@headdepth-\bmb@headbodyseperation) -- (\bmb@width+\tmpa,-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight-\bmb@bodydepth-\bmb@padding-\bmb@corners-\tmpa) -- (-\tmpa,-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight-\bmb@bodydepth-\bmb@padding-\bmb@corners-\tmpa) -- (-\tmpa,-\bmb@headdepth-\bmb@headbodyseperation);
}
\fi
\ifbeamer@chamfered@outline% The 1pt offset added to \bmb@headdepth is a hack to fix the rounding errors of some stupid pdf viewers!
\filldraw[fill=upper.bg,draw=structure.fg,thin,rounded corners=\bmb@corners] (0pt,-\bmb@headdepth-1pt) -- (0pt,\bmb@headheight+\bmb@padding+0.5pt) -- (\bmb@width,\bmb@headheight+\bmb@padding+0.5pt) -- (\bmb@width,-\bmb@headdepth-1pt);
\filldraw[fill=lower.bg,draw=structure.fg,thin,rounded corners=\bmb@corners] (\bmb@width,-\bmb@headdepth+1pt) -- (\bmb@width,-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight-\bmb@bodydepth-\bmb@padding-\bmb@corners) -- (0pt,-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight-\bmb@bodydepth-\bmb@padding-\bmb@corners) -- (0pt,-\bmb@headdepth+1pt);
\else
\fill[fill=upper.bg,rounded corners=\bmb@corners] (0pt,-\bmb@headdepth-1pt) -- (0pt,\bmb@headheight+\bmb@padding+0.5pt) -- (\bmb@width,\bmb@headheight+\bmb@padding+0.5pt) -- (\bmb@width,-\bmb@headdepth-1pt);
\fill[fill=lower.bg,rounded corners=\bmb@corners] (\bmb@width,-\bmb@headdepth+1pt) -- (\bmb@width,-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight-\bmb@bodydepth-\bmb@padding-\bmb@corners) -- (0pt,-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight-\bmb@bodydepth-\bmb@padding-\bmb@corners) -- (0pt,-\bmb@headdepth+1pt);
\fi
\pgfputat{\pgfpoint{\bmb@padding+\bmb@corners}{0pt}}{\pgftext[left,base]{\copy\bmb@headbox}}
\pgfputat{\pgfpoint{\bmb@padding+\bmb@corners}{-\bmb@headdepth-\bmb@headbodyseperation-\bmb@bodyheight}}{\pgftext[left,base]{\copy\bmb@bodybox}}
\end{tikzpicture}
\egroup% of \vbox\bgroup
}
\defbeamertemplate*{title page}{chamfered}[1][]
{
\vbox{}
\vfill
\begin{centering}
\begin{centering}
\usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle\par%
\ifx\insertsubtitle\@empty%
\else%
\vskip0.25em%
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\fi%
\end{centering}
\vskip1.5em\par
\begin{centering}
\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor
\end{centering}
\vskip1em\par
\begin{centering}
\usebeamerfont{institute}\usebeamercolor[fg]{institute}\insertinstitute
\end{centering}
\vskip1em\par
\begin{centering}
\usebeamerfont{date}\usebeamercolor[fg]{date}\insertdate
\end{centering}\vskip0.5em
{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
\end{centering}
\vfill
}
\setbeamertemplate{sections/subsections in toc}[square]
\setbeamertemplate{items}[square]
\setbeamertemplate{blocks}[rounded]
\setbeamertemplate{title page}[chamfered]
\setbeamertemplate{part page}[default]
\mode<all>
%%% Local Variables:
%%% TeX-master: "~/texmf/tex/latex/beamer/test/test.tex"
%%% End: