summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/hackthefootline/hackthefootline.sty
blob: 3b59d32441a06b9485446f30092b54a28f8b4799 (plain)
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
%%	This is file 'hackthefootline.sty', Version 2017-08-04
%%	Copyright 2017 Sebastian Friedl <sfr682k@t-online.de>
%% 
%%	This work may be distributed and/or modified under the conditions of the LaTeX Project
%%	Public License, either version 1.3c of this license or (at your option) any later version.
%%	The latest version of this license is available at
%%		http://www.latex-project.org/lppl.txt
%%	and version 1.3c or later is part of all distributions of LaTeX version 2008-05-04 or later
%%
%%	This work has the LPPL maintenace status 'maintained'.
%%	The current maintainer of this work is Sebastian Friedl.
%%
%%	This work consists of the files hackthefootline.sty and hackthefootline-doc.tex
%%
%%	-------------------------------------------------------------------------------------------
%%
%%	The hackthefootline package is a tool providing arbitrary footline selection for
%%	LaTeX beamer's standard themes (it may work with other themes as well)
%%
%%	-------------------------------------------------------------------------------------------
%%
%%	Please report bugs and other problems as well as suggestions for improvements
%%	to my email address (sfr682k@t-online.de).
%%
%%	-------------------------------------------------------------------------------------------
%%
%%	Acknowledgement:
%%	The basic layout of the two- and three-column footline is based on the original LaTeX
%%	beamer split and infolines outer themes written by Till Tantau.
%%
%%	-------------------------------------------------------------------------------------------


\ProvidesPackage{hackthefootline}[2017/08/04 hackthefootline: arbitrary footline selection for LaTeX beamer's standard themes]
\mode<presentation>



\newcommand{\htfprintmessage}{%
	\typeout{}
	\typeout{========================================}
	\typeout{FOOTLINE HACK PERFORMED}
	\typeout{}
	\typeout{hackthefootline package}
	\typeout{Version 2017/08/04}
	\typeout{}
	\typeout{(c) 2017 Sebastian Friedl}
	\typeout{Licensed under LPPL 1.3c or later}
	\typeout{========================================}
	\typeout{}}



% OPTION AND VARIABLES DECLARATION --------------------------------------------------------------------------------------------------------------

\newif\ifbeamer@htfonecolfootline
\beamer@htfonecolfootlinefalse
\DeclareOptionBeamer{onecol}{\beamer@htfonecolfootlinetrue}

\newif\ifbeamer@htftwocolsfootline
\beamer@htftwocolsfootlinefalse
\DeclareOptionBeamer{twocols}{\beamer@htftwocolsfootlinetrue}

\newif\ifbeamer@htfthreecolsfootline
\beamer@htfthreecolsfootlinefalse
\DeclareOptionBeamer{threecols}{\beamer@htfthreecolsfootlinetrue}

\newif\ifbeamer@htfcountappendixframes
\beamer@htfcountappendixframesfalse
\DeclareOptionBeamer{countappendixframes}{\beamer@htfcountappendixframestrue}

\newif\ifbeamer@htffunnystuff
\beamer@htffunnystufftrue
\DeclareOptionBeamer{nofun}{\beamer@htffunnystufffalse}


\ProcessOptionsBeamer


% Show frame numbers?
\newif\ifbeamer@htfshowframenrs
\beamer@htfshowframenrstrue

% Check for author and/or institute when inserting the separation symbol?
\newif\ifbeamer@htfcheckauth
\newif\ifbeamer@htfcheckinst
\newif\ifbeamer@htfinsertsep
\newcommand{\htfcheckauthor}{\beamer@htfcheckauthtrue	\beamer@htfcheckinstfalse}
\newcommand{\htfcheckinstit}{\beamer@htfcheckauthfalse	\beamer@htfcheckinsttrue}
\newcommand{\htfcheckboth}{	 \beamer@htfcheckauthtrue	\beamer@htfcheckinsttrue}
\newcommand{\htfchecknone}{  \beamer@htfcheckauthfalse	\beamer@htfcheckinstfalse}

% Has the navigation bar been removed by the package?
\newif\ifbeamer@navigationremoved
\beamer@navigationremovedfalse

% Variables
\newif\ifbeamer@htfnotitle			\newif\ifbeamer@htfshorttitle		\newif\ifbeamer@htflongtitle
\newif\ifbeamer@htfnoauthinst		\newif\ifbeamer@htfonlyauthor		\newif\ifbeamer@htfonlyinstitute
\newif\ifbeamer@htfinstitutepths	\newif\ifbeamer@htfauthorpths		\newif\ifbeamer@htfauthinst
\newif\ifbeamer@htfnodate			\newif\ifbeamer@htfshortdate		\newif\ifbeamer@htflongdate
\newif\ifbeamer@htfnoframenrs		\newif\ifbeamer@htfcounterframenrs	\newif\ifbeamer@htffractionframenrs
\newif\ifbeamer@htfpercentframenrs
\newif\ifbeamer@htfcolonsep			\newif\ifbeamer@htfcommasep			\newif\ifbeamer@htfsepspace
\newif\ifbeamer@htfnofootline



% DEFAULT VALUES --------------------------------------------------------------------------------------------------------------------------------

\beamer@htfnofootlinefalse
\ifbeamer@htfonecolfootline\else
	\ifbeamer@htftwocolsfootline\else
		\ifbeamer@htfthreecolsfootline\else
			\beamer@htfnofootlinetrue
\fi	\fi	\fi

\newcommand{\htfnofootlinedefault}{%
	\beamer@htfnoframenrstrue			\beamer@htfcounterframenrsfalse		\beamer@htffractionframenrsfalse
	\beamer@htfpercentframenrsfalse		\beamer@htfshowframenrsfalse
}

\newcommand{\htfonecolfootlinedefault}{%
	\beamer@htfnotitlefalse				\beamer@htfshorttitletrue			\beamer@htflongtitlefalse
	\beamer@htfnoauthinstfalse			\beamer@htfonlyauthorfalse			\beamer@htfonlyinstitutefalse
	\beamer@htfinstitutepthsfalse		\beamer@htfauthorpthsfalse			\beamer@htfauthinsttrue
	\beamer@htfnodatetrue				\beamer@htfshortdatefalse			\beamer@htflongdatefalse
	\beamer@htfnoframenrsfalse			\beamer@htfcounterframenrsfalse		\beamer@htffractionframenrstrue
	\beamer@htfpercentframenrsfalse
	\beamer@htfcolonseptrue				\beamer@htfcommasepfalse			\beamer@htfsepspacefalse
}

\newcommand{\htftwocolsfootlinedefault}{%
	\beamer@htfnotitlefalse				\beamer@htfshorttitletrue			\beamer@htflongtitlefalse
	\beamer@htfnoauthinstfalse			\beamer@htfonlyauthortrue			\beamer@htfonlyinstitutefalse
	\beamer@htfinstitutepthsfalse		\beamer@htfauthorpthsfalse			\beamer@htfauthinstfalse
	\beamer@htfnodatetrue				\beamer@htfshortdatefalse			\beamer@htflongdatefalse
	\beamer@htfnoframenrstrue			\beamer@htfcounterframenrsfalse		\beamer@htffractionframenrsfalse
	\beamer@htfpercentframenrsfalse
}

\newcommand{\htfthreecolsfootlinedefault}{%
	\beamer@htfnotitlefalse				\beamer@htfshorttitletrue			\beamer@htflongtitlefalse
	\beamer@htfnoauthinstfalse			\beamer@htfonlyauthorfalse			\beamer@htfonlyinstitutefalse
	\beamer@htfinstitutepthstrue		\beamer@htfauthorpthsfalse			\beamer@htfauthinstfalse
	\beamer@htfnodatefalse				\beamer@htfshortdatetrue			\beamer@htflongdatefalse
	\beamer@htfnoframenrsfalse			\beamer@htfcounterframenrsfalse		\beamer@htffractionframenrstrue
	\beamer@htfpercentframenrsfalse
}



% ACTIONS FOR NOT COUNTING APPENDIX FRAMES ------------------------------------------------------------------------------------------------------

\ifbeamer@htfcountappendixframes\else
	% Required packages
	\RequirePackage{appendixnumberbeamer}
	\RequirePackage{etoolbox}
	
	% Removes frame numbers for appendix slides
	\apptocmd{\appendix}{%
		\beamer@htfshowframenrsfalse
	}{}{}
\fi



% REQUIREMENTS FOR SOME "FUNNY STUFF" -----------------------------------------------------------------------------------------------------------

\ifbeamer@htffunnystuff
	% Frame numbering in %: requirements, package settings, variables, commands
	\RequirePackage{calc}
	\RequirePackage[addmissingzero,autolanguage,nosepfour]{numprint}
	\npdefunit{percent}{\%}{1}
	\newlength{\progress}
	\newcommand{\updateprogress}{\setlength{\progress}{100pt*\ratio{\insertframenumber pt}{\inserttotalframenumber pt}}}
\fi



% TEMPLATES: TITLE ------------------------------------------------------------------------------------------------------------------------------

\defbeamertemplate*{htf-title}{none}{}
\defbeamertemplate*{htf-title}{short}{\insertshorttitle}
\defbeamertemplate*{htf-title}{long}{\inserttitle}



% TEMPLATES: AUTHOR / INSTITUTE -----------------------------------------------------------------------------------------------------------------

\defbeamertemplate*{htf-authinst}{none}{}
\defbeamertemplate*{htf-authinst}{onlyauth}{\insertshortauthor}
\defbeamertemplate*{htf-authinst}{onlyinst}{\insertshortinstitute}
\defbeamertemplate*{htf-authinst}{instpths}{\insertshortauthor\ifx\beamer@shortinstitute\@empty\else~~(\insertshortinstitute)\fi}
\defbeamertemplate*{htf-authinst}{authpths}{\insertshortinstitute\ifx\beamer@shortauthor\@empty\else~~(\insertshortauthor)\fi}
\defbeamertemplate*{htf-authinst}{bothcmma}{\insertshortauthor\ifx\beamer@shortinstitute\@empty\else,~\insertshortinstitute\fi}



% TEMPLATES: DATE -------------------------------------------------------------------------------------------------------------------------------

\defbeamertemplate*{htf-date}{none}{}
\defbeamertemplate*{htf-date}{short}{\insertshortdate}
\defbeamertemplate*{htf-date}{long}{\insertdate}



% TEMPLATES: FRAME NUMBERS ----------------------------------------------------------------------------------------------------------------------

\defbeamertemplate*{htf-framenrs}{none}{}
\defbeamertemplate*{htf-framenrs}{counter}{\insertframenumber}
\defbeamertemplate*{htf-framenrs}{fraction}{\insertframenumber~/~\inserttotalframenumber}
\ifbeamer@htffunnystuff
	\defbeamertemplate*{htf-framenrs}{percent}{\updateprogress\nprounddigits{0}\lenprint[percent]{\progress}}
\fi



% TEMPLATES: AUTHOR-TITLE-SEPERATOR -------------------------------------------------------------------------------------------------------------

\defbeamertemplate*{htf-atsep}{colon}{:~~~~}
\defbeamertemplate*{htf-atsep}{comma}{,~}
\defbeamertemplate*{htf-atsep}{space}{~~~~~~~~~~}



% FOOTLINE DEFINITIONS --------------------------------------------------------------------------------------------------------------------------

% No footline
\defbeamertemplate*{footline}{htf-none}{}

% One column
\defbeamertemplate*{footline}{htf-onecol}{%
	\begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,leftskip=.3cm,rightskip=.3cm]{palette primary}%
		\usebeamerfont{author in head/foot}
		\usebeamertemplate{htf-authinst}%
		%
		\beamer@htfinsertsepfalse
		\ifbeamer@htfcheckauth\ifx\beamer@shortauthor\@empty\else\beamer@htfinsertseptrue\fi\fi
		\ifbeamer@htfcheckinst\ifx\beamer@shortinstitute\@empty\else\beamer@htfinsertseptrue\fi\fi
		%
		\ifx\beamer@shorttitle\@empty \beamer@htfinsertsepfalse \fi
		\ifbeamer@htfnotitle \beamer@htfinsertsepfalse \fi
		%
		\ifbeamer@htfinsertsep\usebeamertemplate{htf-atsep}\fi
		%
		\usebeamerfont{title in head/foot}
		\usebeamertemplate{htf-title}
		\hfill
		\usebeamercolor{date in head/foot}
		\usebeamertemplate{htf-date}
		% Dummy space for frame numbers
		\ifbeamer@htfshowframenrs \hspace{5.75em} \fi
	\end{beamercolorbox}%
	\ifbeamer@htfshowframenrs
		\vspace{-3.25ex}
		\hfill%
		\begin{beamercolorbox}[wd=6.25em,ht=2.25ex,dp=1ex,right,rightskip=.3cm]{palette primary}
			\usebeamertemplate{htf-framenrs}
		\end{beamercolorbox}
	\fi}

% Two columns
\defbeamertemplate*{footline}{htf-twocols}{%
	\leavevmode%
	\hbox{\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm]{author in head/foot}%
			\usebeamerfont{author in head/foot}\usebeamertemplate{htf-date}\hfill\usebeamertemplate{htf-authinst}
		\end{beamercolorbox}%
		\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm]{title in head/foot}%
			\usebeamerfont{title in head/foot}\usebeamertemplate{htf-title}\hfill
			\ifbeamer@htfshowframenrs \usebeamertemplate{htf-framenrs} \fi
	\end{beamercolorbox}}%
	\vskip0pt}

% Three columns
\defbeamertemplate*{footline}{htf-threecols}{
	\leavevmode%
	\hbox{%
		\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,left,leftskip=.3cm]{author in head/foot}%
			\usebeamerfont{author in head/foot}\usebeamertemplate{htf-authinst}
		\end{beamercolorbox}%
		\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
			\usebeamerfont{title in head/foot}\usebeamertemplate{htf-title}
		\end{beamercolorbox}%
		\begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right,rightskip=.3cm]{date in head/foot}%
			\usebeamerfont{date in head/foot}\usebeamertemplate{htf-date}%
			% Dummy space for frame numbers
			\ifbeamer@htfshowframenrs \hspace{5.75em} \fi
		\end{beamercolorbox}%
		\ifbeamer@htfshowframenrs%
			\hspace{-6.25em}%
			\begin{beamercolorbox}[wd=6.25em,ht=2.25ex,dp=1ex,right,rightskip=.3cm]{date in head/foot}%
				\usebeamertemplate{htf-framenrs}
			\end{beamercolorbox}%
		\fi}%
	\vskip0pt}



% CONFIGURATION COMMANDS ------------------------------------------------------------------------------------------------------------------------

% Internal commands setting all variables of a certain template to "false"
\newcommand{\htfcleartitle}{%
	\beamer@htfnotitlefalse				\beamer@htfshorttitlefalse			\beamer@htflongtitlefalse}
\newcommand{\htfclearauthinst}{%
	\beamer@htfnoauthinstfalse			\beamer@htfonlyauthorfalse			\beamer@htfonlyinstitutefalse
	\beamer@htfinstitutepthsfalse		\beamer@htfauthorpthsfalse			\beamer@htfauthinstfalse}
\newcommand{\htfcleardate}{%
	\beamer@htfnodatefalse				\beamer@htfshortdatefalse			\beamer@htflongdatefalse}
\newcommand{\htfclearframenrs}{%
	\beamer@htfnoframenrsfalse			\beamer@htfcounterframenrsfalse		\beamer@htffractionframenrsfalse
	\beamer@htfpercentframenrsfalse		\beamer@htfshowframenrsfalse}
\newcommand{\htfclearsep}{%
	\beamer@htfcolonsepfalse			\beamer@htfcommasepfalse			\beamer@htfsepspacefalse}
\newcommand{\htfclearfootline}{%
	\beamer@htfonecolfootlinefalse		\beamer@htftwocolsfootlinefalse		\beamer@htfthreecolsfootlinefalse
	\beamer@htfnofootlinefalse}

% Commands switching the title template
\newcommand{\htfnotitle}{			\htfcleartitle		\beamer@htfnotitletrue}
\newcommand{\htfshorttitle}{		\htfcleartitle		\beamer@htfshorttitletrue}
\newcommand{\htflongtitle}{			\htfcleartitle		\beamer@htflongtitletrue}

% Commands switching the author/institute template
\newcommand{\htfnoauthinst}{		\htfclearauthinst	\beamer@htfnoauthinsttrue}
\newcommand{\htfonlyauthor}{		\htfclearauthinst	\beamer@htfonlyauthortrue}
\newcommand{\htfonlyinstitute}{		\htfclearauthinst	\beamer@htfonlyinstitutetrue}
\newcommand{\htfinstitutepths}{		\htfclearauthinst	\beamer@htfinstitutepthstrue}
\newcommand{\htfauthorpths}{		\htfclearauthinst	\beamer@htfauthorpthstrue}
\newcommand{\htfauthinst}{			\htfclearauthinst	\beamer@htfauthinsttrue}

% Commands switching the date template
\newcommand{\htfnodate}{			\htfcleardate		\beamer@htfnodatetrue}
\newcommand{\htfshortdate}{			\htfcleardate		\beamer@htfshortdatetrue}
\newcommand{\htflongdate}{			\htfcleardate		\beamer@htflongdatetrue}

% Commands switching the frame numbering template
\newcommand{\htfnoframenrs}{		\htfclearframenrs	\beamer@htfnoframenrstrue}
\newcommand{\htfcounterframenrs}{	\htfclearframenrs	\beamer@htfcounterframenrstrue		\beamer@htfshowframenrstrue}
\newcommand{\htffractionframenrs}{	\htfclearframenrs	\beamer@htffractionframenrstrue		\beamer@htfshowframenrstrue}
\newcommand{\htfpercentframenrs}{	\htfclearframenrs	\beamer@htfpercentframenrstrue		\beamer@htfshowframenrstrue}

% Commands switching the author/title separator template
\newcommand{\htfcolonsep}{			\htfclearsep		\beamer@htfcolonseptrue}
\newcommand{\htfcommasep}{			\htfclearsep		\beamer@htfcommaseptrue}
\newcommand{\htfsepspace}{			\htfclearsep		\beamer@htfsepspacetrue}



% HACKING COMMAND -------------------------------------------------------------------------------------------------------------------------------

\newcommand{\hackthefootline}{%
	\htfprintmessage
	
	% Selects footline layout
	\ifbeamer@htfonecolfootline		\setbeamertemplate{footline}[htf-onecol]
	\else	\ifbeamer@htftwocolsfootline	\setbeamertemplate{footline}[htf-twocols]
			\else	\ifbeamer@htfthreecolsfootline	\setbeamertemplate{footline}[htf-threecols]
					\else	\setbeamertemplate{footline}[htf-none]
	\fi		\fi		\fi
	
	% Title
	\ifbeamer@htfnotitle			\setbeamertemplate{htf-title}[none] \fi
	\ifbeamer@htfshorttitle 		\setbeamertemplate{htf-title}[short] \fi
	\ifbeamer@htflongtitle			\setbeamertemplate{htf-title}[long] \fi
	
	% Author/Institute
	\ifbeamer@htfnoauthinst			\setbeamertemplate{htf-authinst}[none] \htfchecknone \fi
	\ifbeamer@htfonlyauthor			\setbeamertemplate{htf-authinst}[onlyauth] \htfcheckauthor \fi
	\ifbeamer@htfonlyinstitute		\setbeamertemplate{htf-authinst}[onlyinst] \htfcheckinstit \fi
	\ifbeamer@htfinstitutepths		\setbeamertemplate{htf-authinst}[instpths] \htfcheckboth \fi
	\ifbeamer@htfauthorpths			\setbeamertemplate{htf-authinst}[authpths] \htfcheckboth \fi
	\ifbeamer@htfauthinst			\setbeamertemplate{htf-authinst}[bothcmma] \htfcheckboth \fi
	
	% Date
	\ifbeamer@htfnodate				\setbeamertemplate{htf-date}[none] \fi
	\ifbeamer@htfshortdate			\setbeamertemplate{htf-date}[short] \fi
	\ifbeamer@htflongdate			\setbeamertemplate{htf-date}[long] \fi
	
	% Frame numbers
	\ifbeamer@htfnoframenrs			\setbeamertemplate{htf-framenrs}[none] \fi
	\ifbeamer@htfcounterframenrs	\setbeamertemplate{htf-framenrs}[counter] \fi
	\ifbeamer@htffractionframenrs	\setbeamertemplate{htf-framenrs}[fraction] \fi
	\ifbeamer@htfpercentframenrs	\ifbeamer@htffunnystuff \setbeamertemplate{htf-framenrs}[percent]
									\else	\PackageError{hackthefootline}{For using percent frame numbers don't pass the nofun option}{}
									\fi \fi
	
	% Author--Title--separators
	\ifbeamer@htfcolonsep			\setbeamertemplate{htf-atsep}[colon] \fi
	\ifbeamer@htfcommasep 			\setbeamertemplate{htf-atsep}[comma] \fi
	\ifbeamer@htfsepspace 			\setbeamertemplate{htf-atsep}[space] \fi
}



% PERFORMS THE "INITIAL HACK" AT BEGINNING A DOCUMENT -------------------------------------------------------------------------------------------

\AtBeginDocument{
	% Load default settings ...
	\ifbeamer@htfonecolfootline \htfonecolfootlinedefault
	\else	\ifbeamer@htftwocolsfootline \htftwocolsfootlinedefault
	\else	\ifbeamer@htfthreecolsfootline \htfthreecolsfootlinedefault
	\else	\htfnofootlinedefault
	\fi		\fi		\fi
	
	% ... and perform the hack
	\hackthefootline}



% END OF FILE -----------------------------------------------------------------------------------------------------------------------------------

\mode<all>
\endinput