summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fancyhandout/fancyhandout.cls
blob: 84f5156f225d79f451da9dd028a8367fb0750c33 (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
%%	This is file 'fancyhandout.cls', Version 2018-01-22
%%	Copyright 2017-18 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 maintenance status 'maintained'.
%%	Author: Sebastian Friedl
%%	Current maintainer of this work is Sebastian Friedl
%%
%%	This work consists of the files fancyhandout.cls and fancyhandout-doc.tex
%%
%%	---------------------------------------------------------------------------------------------------------------------------------------------
%%
%%	A LaTeX class for producing nice-looking handouts.
%%
%%	---------------------------------------------------------------------------------------------------------------------------------------------
%%
%%	Please report bugs and other problems as well as suggestions for improvements to the following email address: sfr682k@t-online.de
%%
%%	--------------------------------------------------------------------------------------------------------------------------------------------- 


\ProvidesClass{fancyhandout}[2018/01/22 fancyhandout: A LaTeX class for producing nice-looking handouts]
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{etoolbox}



% DEFINE OPTIONS ---------------------------------------------------------------------------------------------

% Option for using letter paper
\newif\if@letter
\@letterfalse
\DeclareOption{letter}{\@lettertrue}

% Option for one-sided layout
\newif\if@twoside
\@twosidetrue
\DeclareOption{oneside}{\@twosidefalse}

% Option for 10pt or 12pt font size
\newif\if@tenpt
\newif\if@twelvept
\@tenptfalse
\@twelveptfalse
\DeclareOption{10pt}{\@tenpttrue}
\DeclareOption{12pt}{\@twelvepttrue}

% Option for using the roman font as text font
\newif\if@sffont
\@sffonttrue
\DeclareOption{rmfont}{\@sffontfalse}

\ProcessOptions



% LOAD "article" ---------------------------------------------------------------------------------------------

% Pass font size to article
\if@tenpt           \PassOptionsToClass{10pt}{article}
\else\if@twelvept   \PassOptionsToClass{12pt}{article}
\else               \PassOptionsToClass{11pt}{article}
\fi\fi

% If not specified otherwise, use twoside layout
\if@twoside         \PassOptionsToClass{twoside}{article}
\fi

% All options specified. Load article.
\LoadClass{article}

% Set \parindent to zero
\parindent 0pt



% REQUIRE "geometry" -----------------------------------------------------------------------------------------

% If not specified otherwise, use twoside layout
\if@twoside \PassOptionsToPackage{twoside}{geometry}
\fi

% Page size
\if@letter	\PassOptionsToPackage{letterpaper}{geometry}
\else		\PassOptionsToPackage{a4paper}{geometry}
\fi

% Default page margins
\PassOptionsToPackage{left=2.25cm, right=2.25cm, top=2.25cm, bottom=2.25cm, includehead, includefoot}{geometry}

% All options specified. Load geometry.
\RequirePackage{geometry}



% REQUIRE OTHER PACKAGES -------------------------------------------------------------------------------------

\AtEndPreamble{\RequirePackage{csquotes}}

\RequirePackage{enumitem}
	\setlist{itemsep=0ex,topsep=.75ex}

\RequirePackage{fancyhdr}
	\pagestyle{fancy}
	\fancyhead{}
	\fancyfoot{}
	\if@twoside%
		\fancyhead[ro,le]{%
			\def\and{\unskip,~}%
			\insertshortauthor%
			\ifx\insertshorttitle\@empty\else\ifx\insertshortauthor\@empty\else :~\fi\fi%
			\insertshorttitle}
		\fancyfoot[ro,le]{\thepage}
		\fancyfoot[re,lo]{\insertshortdate}
	\else
		\fancyhead[r]{%
			\def\and{\unskip,~}
			\insertshortauthor%
			\ifx\insertshorttitle\@empty\else\ifx\insertshortauthor\@empty\else :~\fi\fi%
			\insertshorttitle}
		\fancyfoot[l]{\insertshortdate}
		\fancyfoot[r]{\thepage}
	\fi
	\def\footrulewidth{0.4pt}
	\headheight=14pt

% Required when hyperref is not loaded by the user
% This "fake command" gets redefined when hyperref is loaded
\ifx\phantomsection\@undefined	\let\phantomsection\@empty	\fi
% Also, write the document information to hyperref when loaded
\AtBeginDocument{%
	\ifx\hypersetup\@undefined\else%
		\hypersetup{pdftitle=\inserttitle,pdfauthor=\insertauthor,pdfcreator={LaTeX with fancyhandout class}}%
	\fi}



% COLOR SETTINGS ---------------------------------------------------------------------------------------------

\RequirePackage{xcolor}

% Basic color
\definecolor{fancyhandoutblue}{rgb}{0.2,0.2,0.7}

% Initial definition of a primary and a secondary color
\colorlet{fancyhandoutmaincolor}{fancyhandoutblue}
\colorlet{fancyhandoutsecondarycolor}{fancyhandoutblue!85}

% Line colors
\colorlet{fancyhandoutsectlinecolor}{fancyhandoutmaincolor}
\colorlet{fancyhandoutsubsectlinecolor}{fancyhandoutsecondarycolor}

% Title box colors
\colorlet{fancyhandouttboxlinecolor}{fancyhandoutmaincolor}
\colorlet{fancyhandouttboxfillcolor}{fancyhandoutmaincolor!12.5}



% FONT SETTINGS ----------------------------------------------------------------------------------------------

% As long as not specified otherwise, use the sans-serif font by default
\if@sffont    \def\familydefault{\sfdefault}
\fi



% TITLE COMMANDS ---------------------------------------------------------------------------------------------

% Redefine the provided commands and define beamer-like commands inserting their values
\def\title{}
\let\inserttitle\@empty
\let\insertshorttitle\@empty
%
\def\subtitle{}
\let\insertsubtitle\@empty
\let\insertshortsubtitle\@empty
%
\def\author{}
\let\insertauthor\@empty
\let\insertshortauthor\@empty
\let\and\@empty
%
\def\institute{}
\let\insertinstitute\@empty
\let\insertshortinstitute\@empty
%
\def\date{}
\let\insertdate\today
\let\insertshortdate\today

% Set the according variable when a command is used
\renewcommand{\title}[2][\inserttitle]{%
	\def\inserttitle{#2}%
	\def\insertshorttitle{#1}}
\renewcommand{\subtitle}[2][\insertsubtitle]{%
	\def\insertsubtitle{#2}%
	\def\insertshortsubtitle{#1}}
\renewcommand{\author}[2][\insertauthor]{%
	\def\insertauthor{#2}%
	\def\insertshortauthor{#1}}
\renewcommand{\institute}[2][\insertinstitute]{%
	\def\insertinstitute{#2}
	\def\insertshortinstitute{#1}}
\renewcommand{\date}[2][\insertdate]{%
	\def\insertdate{#2}%
	\def\insertshortdate{#1}}

% Typesets a title box
\def\maketitle{%
	\def\and{\qquad}%
	\thispagestyle{empty}
	\begin{center}
		\fcolorbox{fancyhandouttboxlinecolor}{fancyhandouttboxlinecolor}{%
			\fcolorbox{fancyhandouttboxlinecolor}{fancyhandouttboxfillcolor}{%
				\parbox{.95\textwidth}{\centering\vspace{\medskipamount}%
					\ifx\inserttitle\@empty\else {\LARGE\bfseries\inserttitle} \\[\smallskipamount] \fi
					\ifx\insertsubtitle\@empty\else {\large\insertsubtitle} \\ \fi
					\vspace{\medskipamount}\small
					\ifx\insertauthor\@empty\else \insertauthor \ifx\insertinstitute\@empty \\[\medskipamount] \else \\ \fi\fi
					\ifx\insertinstitute\@empty\else \insertinstitute \\[\medskipamount] \fi
					\insertdate
				\vspace{\medskipamount}}}}%
	\end{center}\smallskip}



% SECTION COMMANDS -------------------------------------------------------------------------------------------

% TOC (Pt. I):  Add some space below
\let\origtableofcontents\tableofcontents
\def\tableofcontents{%
	\origtableofcontents%
	\vskip 1.5\bigskipamount}

% TOC (Pt. II): No numbering of sections and subsections
\renewcommand{\numberline}[1]{}

% Own \section command
\def\fancysection#1{%
	\vskip 2\bigskipamount% \vskip, not \vspace; starts a new paragraph
	\noindent%
	\begin{minipage}{\textwidth}%
	{\Large\bfseries%
		#1}\vskip -1ex%
	{\color{fancyhandoutsectlinecolor}\rule{\textwidth}{3pt}}
	\end{minipage}
	\vskip \bigskipamount%
}

% Own \subsection command
\def\fancysubsection#1{%
	\vskip 1.25\bigskipamount%
	\noindent%
	\begin{minipage}{\textwidth}%
	{\large\bfseries%
		#1}\vskip -1.25ex%
	{\color{fancyhandoutsubsectlinecolor}\rule{\textwidth}{1.5pt}}
	\end{minipage}
	\vskip \medskipamount%
}

% Own \subsubsection command
\def\fancysubsubsection#1{%
	\vskip .75\bigskipamount% \vskip, not \vspace; starts a new paragraph
	\noindent%
	\begin{minipage}{\textwidth}%
	{\bfseries%
		#1}%
	\end{minipage}
	\vskip .75\smallskipamount%
}

% Redefine article's sectioning commands
\def\section{\@ifstar\@@section\@section}
\def\@section#1{%
	\phantomsection%
	\refstepcounter{section}%
	\def\@currentlabel{\enquote{#1}}% Manipulate LaTeX's internal mechanisms to print the section name when using \ref >:)
	\addcontentsline{toc}{section}{#1}%
	\@@section{#1}}
\def\@@section#1{\fancysection{#1}}

\def\subsection{\@ifstar\@@subsection\@subsection}
\def\@subsection#1{%
	\phantomsection%
	\refstepcounter{subsection}%
	\def\@currentlabel{\enquote{#1}}%
	\addcontentsline{toc}{subsection}{#1}%
	\@@subsection{#1}}
\def\@@subsection#1{\fancysubsection{#1}}

\def\subsubsection{\@ifstar\@@subsubsection\@subsubsection}
\def\@subsubsection#1{%
	\phantomsection%
	\refstepcounter{subsubsection}%
	\def\@currentlabel{\enquote{#1}}%
	\addcontentsline{toc}{subsubsection}{#1}%
	\@@subsubsection{#1}}
\def\@@subsubsection#1{\fancysubsubsection{#1}}



% OTHER TODOS ------------------------------------------------------------------------------------------------


% TODO: Beamer styled boxes!!