blob: ae947b845e38816b75f19dcde9a36813a2e1ed10 (
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
|
%% Copyright 2014 Maïeul Rouquette
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Maïeul Rouquette
% This work consists of the files handout.sty and example and documentation files.
\ProvidesPackage{handout}[2014/05/23 1.0.1 Handout package]
\RequirePackage{kvoptions,etoolbox}
% Options
\DeclareBoolOption[false]{disabled}
\DeclareBoolOption[false]{numbering}
\DeclareBoolOption[false]{sectioning}
\DeclareStringOption[.]{dir}
\ProcessKeyvalOptions*
% Warning tools
\newcommand{\handout@warning}[1]{\@latex@warning{Handout: #1}}
% Opening the handout file
\newwrite\@handout
\immediate\openout\@handout=\jobname.handout
% The main command, to be used by people
\newcommand{\handout}[1]{%
\ifhandout@disabled\else%Only if not disabled, of course!
\ifhandout@numbering%
\stepcounter{handoutnumber}%
\handoutnumberintxt{\thehandoutnumber}%
\fi%
\immediate\write\@handout {\string\csuse{handout@input}{#1}}%
\fi%
\input{\handout@dir/#1}% Add the handout
}
% The special commands to be used by people
\newcommand{\nothandout}[1]{#1}
\newcommand{\onlyhandout}[1]{}
\newcommand{\forhandout}[1]{%
\immediate\write\@handout{\noexpand #1}%
}
% The command written in the .handout file
\newcommand{\handout@input}[1]{%
\ifhandout@numbering%
\stepcounter{handoutnumber}%
\handoutnumber{\thehandoutnumber}%
\fi%
\input{\handout@dir/#1}%
}
% Output the sectionning commands in the .handout file
\ifhandout@sectioning%Only if needed by option
\apptocmd{\@sect}{%
\immediate\write\@handout{\string\csuse{#1}{\unexpanded{#8}}}%
}{}{\handout@warning{Can't patch sectioning commands}}
\fi
% Call the handout file at the end, if need
\ifhandout@disabled\else
\AtEndDocument{%
\immediate\closeout\@handout%
\before@handout%
\ifdef{\beforehandout}{\beforehandout}{\handout@warning{No command defined to be run before handout}}
\input\jobname.handout%
}
\fi
% Standard command before handout
\newcommand{\before@handout}{%
% New page
\newpage%
% Reset counter
\setcounter{page}{1}%
\setcounter{footnote}{0}%
\ifhandout@sectioning%
\setcounter{section}{0}%
\setcounter{subsection}{0}%
\setcounter{subsubsection}{0}%
\fi
\ifhandout@numbering
\setcounter{handoutnumber}{0}%
\fi
% No new data in content or in label or index
\def\addcontentsline##1##2##3{}
\let\label\@gobble
\renewcommand{\index}[2][1]{}
% Switches onlyhandout and nothandout commands
\renewcommand{\nothandout}[1]{}
\renewcommand{\onlyhandout}[1]{##1}
}
\AtBeginDocument{%
\@ifpackageloaded{biblatex}{%
\apptocmd{\before@handout}{\citereset}{}{}%
}{}}
% Handout numbering
\ifhandout@numbering
\newcounter{handoutnumber}
\renewcommand{\thehandoutnumber}{\fbox{\arabic{handoutnumber}}}
\fi
\newcommand{\handoutnumberintxt}[1]{\handoutnumber{#1}}
\newcommand{\handoutnumber}[1]{\marginpar{#1}}
|