-
Notifications
You must be signed in to change notification settings - Fork 1
/
pdfpcnotes.sty
70 lines (59 loc) · 1.69 KB
/
pdfpcnotes.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
\ProvidesPackage{pdfpcnotes}
% Handling of kv parameters.
% We have the following options, that all take time in the HH:MM format
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
family=PDFPC,
prefix=PDFPC@
}
\DeclareStringOption{duration}
\DeclareStringOption{starttime}
\DeclareStringOption{endtime}
\DeclareStringOption{lastminutes}
\DeclareStringOption{fontsize}
\ProcessKeyvalOptions*
% Small macro to make inserting options easier.
\newcommand\PDFPC@option[2]{
\ifx#2\@empty\else
\immediate\write\pdfpcnotesfile{[#1]}%
\immediate\write\pdfpcnotesfile{#2}%
\fi
}
% create a new file handle
\newwrite\pdfpcnotesfile
% open file on \begin{document}
\AtBeginDocument{%
\immediate\openout\pdfpcnotesfile\jobname.pdfpc\relax
\PDFPC@option{duration}{\PDFPC@duration}
\PDFPC@option{start_time}{\PDFPC@starttime}
\PDFPC@option{end_time}{\PDFPC@endtime}
\PDFPC@option{last_minutes}{\PDFPC@lastminutes}
\PDFPC@option{font_size}{\PDFPC@fontsize}
\immediate\write\pdfpcnotesfile{[notes]}
}
% define a # http://tex.stackexchange.com/a/37757/10327
\begingroup
\catcode`\#=12
\gdef\hashchar{#}%
\endgroup
\def\lastframenumber{0}
% define command \pnote{} that works like note but
% additionally writes notes to file in pdfpc readable format
\newcommand{\pnote}[1]{%
% keep normal notes working
\note{#1}%
% if frame changed - write a new header
\ifdim\theframenumber pt>\lastframenumber pt
\let\lastframenumber\theframenumber
\begingroup
\let\#\hashchar
\immediate\write\pdfpcnotesfile{\#\#\# \theframenumber}%
\endgroup
\fi
% write note to file
\immediate\write\pdfpcnotesfile{\unexpanded{#1}}%
}
% close file on \end{document}
\AtEndDocument{%
\immediate\closeout\pdfpcnotesfile
}