diff --git a/pdfpcnotes.sty b/pdfpcnotes.sty index 3d1b6ea..3897589 100644 --- a/pdfpcnotes.sty +++ b/pdfpcnotes.sty @@ -1,4 +1,25 @@ -\ProvidesPackage{pdfpcnotes} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% pdfpcnotes.sty +% +% Create notes for PDFPC from a beamer file +% +% Copyright 2013 Carsten Brandt +% Copyright 2013 Aggelos Karalias +% Copyright 2014-2016 Raphaƫl Beamonte +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\ProvidesPackage% + {pdfpcnotes}% + [2016/05/04 \space ver 0.2 \space To generate notes to use with pdfpc] + +\RequirePackage{forloop} +\RequirePackage{pdftexcmds} + +\RequirePackage{kvoptions} +\DeclareStringOption{fontsize}[32130] +\ProcessKeyvalOptions*\relax % create a new file handle \newwrite\pdfpcnotesfile @@ -6,6 +27,12 @@ % open file on \begin{document} \AtBeginDocument{% \immediate\openout\pdfpcnotesfile\jobname.pdfpc\relax + \immediate\write\pdfpcnotesfile{[file]} + \immediate\write\pdfpcnotesfile{\jobname.pdf} + \ifx\pdfpcnotes@fontsize\@empty + \else + \immediate\write\pdfpcnotesfile{[font_size]^^J\pdfpcnotes@fontsize} + \fi \immediate\write\pdfpcnotesfile{[notes]} } % define a # http://tex.stackexchange.com/a/37757/10327 @@ -15,28 +42,55 @@ \endgroup -\def\lastframenumber{0} +\global\def\pdfpcnotes@lastframenumber{0} +\newcounter{pdfpcnotes@currentframenotes} +\newcounter{pdfpcnotes@checkifnoteexists} +\newif\ifpdfpcnotes@noteexists % 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 + \ifdim\theframenumber pt>\pdfpcnotes@lastframenumber pt + \global\edef\pdfpcnotes@lastframenumber{\theframenumber}% + \setcounter{pdfpcnotes@currentframenotes}{0}% + \begingroup% + \let\#\hashchar% \immediate\write\pdfpcnotesfile{\#\#\# \theframenumber}% - \endgroup - \fi - - % write note to file - \immediate\write\pdfpcnotesfile{\unexpanded{#1}}% + \endgroup% + \fi% +% + % check if note was already stored + \pdfpcnotes@noteexistsfalse% + \forloop{pdfpcnotes@checkifnoteexists}{0}{% + \value{pdfpcnotes@checkifnoteexists} < \value{pdfpcnotes@currentframenotes}% + }{% + \ifnum\pdf@strcmp{\unexpanded{#1}}{\csname pdfpcnotes@currentframenotes@\thepdfpcnotes@checkifnoteexists\endcsname}=0 + \pdfpcnotes@noteexiststrue% + \setcounter{pdfpcnotes@checkifnoteexists}{\value{pdfpcnotes@currentframenotes}}% + \else% + \fi% + }% +% + % and then, only if the note was not stored + \ifpdfpcnotes@noteexists% + \else% + % add note in stored notes + \expandafter\global\expandafter\def\csname pdfpcnotes@currentframenotes@\thepdfpcnotes@currentframenotes\endcsname{\unexpanded{#1}}% + \stepcounter{pdfpcnotes@currentframenotes}% +% + % write note to file + \begingroup% + \def\\{^^J}% + \def\par{^^J^^J}% + \immediate\write\pdfpcnotesfile{#1}% + \endgroup% + \fi% } % close file on \begin{document} \AtEndDocument{% \immediate\closeout\pdfpcnotesfile } -