% Macros converting foils.cls into CMP slides (screens supported talks)
% (c) Vit Zyka
% 1999-11-30 : first version created in Ljubjana
% 2000-04-05 : correction of \shref in \cmpiistyle
% 2000-05-09 : rename of \linethickness to \talklinethickness
% 2000-05-18 : \long for \shyperlink and \shref
%              \maskfoil for not presented slide in main course
% 2000-12-02 : \itemize with plus?ex glue
% 2000-12-06 : remove final \vfill in \@foilhead (conflict with texpower)
%              frame rule by cmprulecolor (default by black)
%              slidetitle set to \appendixname
% 2001-05-11 : when using TeXPower package make text color black
% 2001-05-23 : arpgcell included (two column for page numbers)
% 2001-10-06 : \enumerate with plus?ex glue
% 2001-10-16 : CAKi style, cmpiistyle cleaning
% 2001-10-17 : \sideImgAB
% 2001-12-03 : v1.9; correction of package loading, CAKorange color
%              noloadhyperref, noloadgraphicx
%              corrections in hyperlinks: \@pdfborder, no highlight
%
% To do:
% - background color
% - simple style without page numbers -- only 4/9 (Pajdla)
% - mouse control: Prev/Next Page
% - empty page switch
% ========================================================================
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cmptalk}[2001/12/03 v1.9 (Vit Zyka)]
\DeclareOption{emptystyle}{\AtBeginDocument{\let\@outputpage=\outputpageEmpty}}
\DeclareOption{basestyle}{\AtBeginDocument{\let\@outputpage=\outputpageBase}}
\DeclareOption{cmpistyle}{\AtBeginDocument{\let\@outputpage=\outputpagei
  \setCMPi}}
\DeclareOption{cmpiistyle}{\AtBeginDocument{\let\@outputpage=\outputpageCMPii
  \setCMPii}}
\DeclareOption{cakistyle}{\AtBeginDocument{\let\@outputpage=\outputpagei
  \setCAKi}}
\newif\ifnoloadhyperref
\newif\ifnoloadgraphicx
\DeclareOption{noloadhyperref}{\noloadhyperreftrue}
\DeclareOption{nothyperref}{\noloadhyperreftrue}% for compatibility reasons
\DeclareOption{noloadgraphicx}{\noloadgraphicxtrue}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{foils}}
\ProcessOptions
\LoadClass[20pt,dvips,a4paper,landscape]{foils}

\def\hyperlink#1#2{#2} \let\href=\hyperlink \def\hypertarget#1#2{#2}
\newif\ifPDF \ifx\pdfoutput\undefined\else\ifnum\pdfoutput>0\PDFtrue\fi\fi
\ifPDF
  \ifnoloadhyperref\else\RequirePackage[pdftex]{hyperref}\fi
  \ifnoloadgraphicx\else\RequirePackage[pdftex]{graphicx}\fi
  \RequirePackage[pdftex]{color}
\else
  \ifnoloadhyperref\else\RequirePackage[colorlinks]{hyperref}\fi
  \ifnoloadgraphicx\else\RequirePackage{graphicx}\fi
  \RequirePackage{color}
\fi
\RequirePackage{amssymb}
\RequirePackage{arpgcell}

\newdimen\hborder    \hborder=8mm
\newdimen\vborder    \vborder=\hborder
\newdimen\hmargin    \hmargin=1em
\newdimen\vmargin    \vmargin=\hmargin
\newdimen\headheight \headheight=2cm
\newdimen\hlmargin   \hlmargin=1em
\newdimen\hrmargin   \hrmargin=\hlmargin
\newdimen\vtmargin   \vtmargin=\hlmargin
\newdimen\vbmargin   \vbmargin=\hlmargin
\newdimen\talklinethickness \talklinethickness=1pt
\newdimen\logoopticdelusion \logoopticdelusion=1pt
\newdimen\slidewidth \slidewidth=\paperwidth \advance\slidewidth by-2\hborder
\newdimen\slideheight\slideheight=\paperheight\advance\slideheight by-2\vborder
\newbox\logobox \setbox\logobox=\hbox{} 
  \ht\logobox=\headheight \wd\logobox=\headheight
  %\setbox\logobox=\hbox{%
  %\includegraphics[height=2cm,hiresbb=true]{cmp}}
\newdimen\colwidth %\colwidth=\wd\CMPbox\advance\colwidth by-2\talklinethickness
\newdimen\windwidth %\windwidth=\slidewidth \advance\windwidth by-\wd\CMPbox
  %\advance\windwidth by-\talklinethickness
\newdimen\windheight %\windheight=\slideheight \advance\windheight by-\ht\CMPbox
  %\advance\windheight by-\talklinethickness
%\textwidth=\windwidth \advance\textwidth by-2\hmargin
%\textheight=\windheight \advance\textheight by-2\vmargin
\newdimen\colheight %\colheight=\windheight \advance\colheight by-2\vmargin
\newdimen\pagecolwidth \pagecolwidth=1em
\newdimen\pagerule \pagerule=1pt
\newcount\pagecolnumber

\definecolor{fryellow}{cmyk}{0,0,0.15,0}
\definecolor{frgray}{gray}{0.85}
\definecolor{cmporange}{rgb}{1,0.4,0}         % CMP original logo orange color
\definecolor{cakorange}{rgb}{0.737,0.31,.027} % CAK original orange color
\def\headcolor{black}
\def\pagecolor{black}
\def\thepagecolor{black}
\def\headbgrcolor{white}
\def\pagebgrcolor{frgray}
\def\thepagebgrcolor{fryellow}
\def\cmprulecolor{black}

\def\appendixname{Appendix}

%------------------------------------------------------------- TexPower setting
\def\texpowersetting{\ifx\replacecolorsbyone@TP\undefined\else%
  \definecolor{textcolor@whitebg}{gray}{0}%
  \fi}
\AtBeginDocument{\texpowersetting}

%======================================================================= Styles
\def\outputpageEmpty{%--------------------------------------------------- Empty
  \hsize=\slidewidth
  \vsize=\slideheight
  \hoffset=\hborder \advance\hoffset by-1in
  \voffset=\vborder \advance\voffset by-1in
  \textwidth=\slidewidth
  \textheight=\slideheight
  \global\advance\count0 by 1
  \offinterlineskip
  \shipout\box\@outputbox}
\def\outputpageBase{%----------------------------------------------------- Base
  \hsize=\slidewidth
  \vsize=\slideheight
  \hoffset=\hborder \advance\hoffset by-1in
  \voffset=\vborder \advance\voffset by-1in
  \textwidth=\slidewidth
  \linewidth=\slidewidth
  \global\advance\count0 by 1
  %
  \shipout\vbox{\offinterlineskip
    \hbox to\slidewidth{%
      \hskip\hmargin%
      %\parbox[\ht\logobox]{\textwidth}{\hypertarget{talkslide\the\slideno}{}%
      \parbox[\headheight]{\textwidth}{\hypertarget{talkslide\the\slideno}{}%
         \centering\reset@font\large\bfseries\@slidetitle}%
      \hbox to\windwidth{\hfil%
        \vbox to\windheight{\vfill
          \vbox to\textheight{\boxmaxdepth=\maxdepth\box\@outputbox}\vfill}%
        \hfil}%
      \hskip\hmargin}}}
\def\setCMPi{%------------------------------------------------------------ CMPi
  \message{ <A> }
  \setbox\logobox=\hbox{\ifx\Ginclude@graphicsnew\undefined\else\bigfigfalse\fi%
    \includegraphics[height=\headheight,hiresbb=true]{cmp}}
  \message{ <b> }
  \def\apcell##1{{\sffamily\bfseries\nextii{##1}}}
  \def\apcelltype##1{\ifnum\count0=\appage%
      \def\next{\colorbox{\thepagebgrcolor}}%
      \def\nextii{\bfseries\textcolor{\thepagecolor}}%
    \else\def\next{\colorbox{\pagebgrcolor}}%
      \def\nextii{\textcolor{\pagecolor}}\fi%
    \shyperlink{talkslide\the\appage}{\next{\textcolor{black}{##1}}}}
  \def\apcellframe##1{\colorbox{\thepagebgrcolor}{##1}}
  \hlmargin=0em \hrmargin=\hborder \vtmargin=2\hrmargin \vbmargin=0em
  \talklinethickness=1.4pt
  \pagerule=.5\talklinethickness
  \apvrulewidth=\pagerule
  \aphrulewidth=\pagerule
  \hlmargin=0pt \vtmargin=1ex \vbmargin=0pt
  \windwidth=\slidewidth \advance\windwidth by-.51\wd\logobox
  \windheight=\slideheight \advance\windheight by-\ht\logobox
  \textwidth=\windwidth \advance\textwidth by-\hlmargin
    \advance\textwidth by-\hrmargin
  \textheight=\windheight \advance\textheight by-\vtmargin
    \advance\textheight by-\vbmargin
  \colheight=\windheight
    \advance\colheight by\logoopticdelusion
  \colwidth=.51\wd\logobox %\advance\colwidth by-\talklinethickness
  \pagecolwidth=\colwidth \advance\pagecolwidth by-2\pagerule
  \def\pagecolor{black}
  \def\thepagecolor{white}
  \def\headbgrcolor{white}
  \def\pagebgrcolor{white}
  \def\thepagebgrcolor{black}
  \def\labelitemicolor{cmporange}}
\def\outputpagei{% current design
  \hsize=\slidewidth
  \vsize=\slideheight
  \hoffset=\hborder \advance\hoffset by-1in
  \voffset=\vborder \advance\voffset by-1in
  \global\advance\count0 by 1
  %
   \shipout\vbox{\offinterlineskip
     \hbox to\slidewidth{% heading
       \dimen0=\slidewidth \advance\dimen0 by-\wd\logobox
       \advance\dimen0 by-\talklinethickness
       \dimen1=\dimen0 \advance\dimen1 by-\hlmargin \advance\dimen1 by-\hrmargin
       \textcolor{\cmprulecolor}{%
         \vrule width\talklinethickness height\ht\logobox}%
       \fboxsep=0pt\colorbox{\headbgrcolor}{%
         \vbox to\ht\logobox{\hsize=\dimen0
           \textcolor{\cmprulecolor}{%
             \hrule height\talklinethickness width\dimen0}%
           \vfil
           \hbox to\dimen0{\hskip\hlmargin%
             \parbox{\dimen1}{\hypertarget{talkslide\the\slideno}{}%
                \centering\reset@font\large\bfseries\@slidetitle}%
             \hskip\hrmargin}
           \vfil
           \hbox{\ignorespaces\textcolor{\cmprulecolor}{%
             \vrule height\talklinethickness width\dimen0}}}}%
      \shref{http://cmp.felk.cvut.cz}{\copy\logobox}}%
    \hbox to\slidewidth{% body 
      \hbox to\windwidth{\hskip\hlmargin\hfil%
        \vbox to\windheight{\hsize=\textwidth\vskip\vtmargin \vfil
          \vbox to\textheight{\boxmaxdepth=\maxdepth\box\@outputbox}%
          \vfil \vskip\vbmargin}%
        \hfil\hskip\hrmargin}%
      \fboxsep=0pt\colorbox{\headbgrcolor}{%
        \hbox to\colwidth{% page column
           \textcolor{\cmprulecolor}{%
             \vrule width\pagerule height\windheight}%
           \vbox to\windheight{\hsize=\pagecolwidth% \unvcopy1
             %\message{ <H=\the\windheight\space W=\the\pagecolwidth>}%
             \ifnum\totalslides>20\pagecolnumber=2\else\pagecolnumber=1\fi%
             \arrangepages{\windheight}{\pagecolwidth}%
                          {\pagecolnumber}{\totalslides}%
%             \textcolor{\cmprulecolor}{%
%               \hrule height\logoopticdelusion width\pagecolwidth}%
%             \hbox to\pagecolwidth{%
%               \dimen0=\colheight
%                  \divide\dimen0 by\totalslides
%               \count0=1 \advance\totalslides by1 % cycle for page numbers
%               \dimen1=\pagecolwidth
%               \vbox to\colheight{\hsize=\pagecolwidth % slide #
%                 \loop\hbox to\pagecolwidth{%
%                    \ifnum\count0=\slideno\def\next{\colorbox{\thepagebgrcolor}}%
%                      \def\nextii{\bfseries\textcolor{\thepagecolor}}%
%                    \else\def\next{\colorbox{\pagebgrcolor}}%
%                      \def\nextii{\textcolor{\pagecolor}}\fi%
%                    \next{\shyperlink{talkslide\the\count0}{%
%                      \vbox to\dimen0{\hsize=\dimen1
%                        % set font according to page cell height
%                        \vfil\hbox to\dimen1{\hfil\nextii{\the\count0}\hfil}%
%                        \vfil\textcolor{\cmprulecolor}{\hrule height\pagerule}}%
%                    }}}
%                   \vfil\advance\count0 by1
%                 \ifnum\count0<\totalslides\repeat}}
             \vskip\vbmargin}%
           \textcolor{\cmprulecolor}{%
             \vrule width\pagerule height\windheight}%
          }}%
      }%
    %\hrule height\talklinethickness width\slidewidth
  }}
\def\setCMPii{%---------------------------------------------------------- CMPii
  \setbox\logobox=\hbox{\ifx\Ginclude@graphicsnew\undefined\else\bigfigfalse\fi%
    \includegraphics[height=\headheight,hiresbb=true]{cmp}}
  \colwidth=\wd\logobox \advance\colwidth by-2\talklinethickness
  \windwidth=\slidewidth \advance\windwidth by-\wd\logobox
  \advance\windwidth by-\talklinethickness
  \windheight=\slideheight \advance\windheight by-\ht\logobox
  \advance\windheight by-\talklinethickness
  \textwidth=\windwidth \advance\textwidth by-2\hmargin
  \textheight=\windheight \advance\textheight by-2\vmargin
  \colheight=\windheight \advance\colheight by-2\vmargin
  \def\labelitemicolor{cmporange}}
\def\outputpageCMPii{% old fashioned design (page bar at left)
  \hsize=\slidewidth
  \vsize=\slideheight
  %\hsize=\windwidth
  %\vsize=\windheight
  %\hsize=\textwidth
  %\vsize=\textheight
  \hoffset=\hborder \advance\hoffset by-1in
  \voffset=\vborder \advance\voffset by-1in
  \global\advance\count0 by 1
  %
  \shipout\vbox{\offinterlineskip
    \hbox to\slidewidth{%
      {\shref{http://cmp.felk.cvut.cz}{\copy\logobox}}%
      %\ifPDF\pdfannotlink user{/Subtype /Link /A << /Type /Action /S /URI /URI
      %   (http://cmp.felk.cvut.cz) >> }\copy\logobox\pdfendlink%
      %\else\copy\logobox\fi%
      \fboxsep=0pt\colorbox{fryellow}{%
        \vbox to\ht\logobox{\hsize=\windwidth
          \textcolor{\cmprulecolor}{%
            \hrule height\talklinethickness width\windwidth}
          \vfil
          \hbox to\windwidth{\hskip\hmargin%
            \parbox{\textwidth}{\hypertarget{talkslide\the\slideno}{}%
               \centering\reset@font\large\bfseries\@slidetitle}%
            \hskip\hmargin}
          \vfil
          \textcolor{\cmprulecolor}{%
            \hrule height\talklinethickness width\windwidth}}}%
      \textcolor{\cmprulecolor}{\vrule width\talklinethickness}}
     \hbox to\slidewidth{%
       \fboxsep=0pt\colorbox{frgray}{%
         \hbox to\wd\logobox{%
           \textcolor{\cmprulecolor}{%
             \vrule width\talklinethickness height\windheight}%
           \setbox0=\hbox{\tiny Machine Perception}%
           \setbox1=\vbox{\hsize=\colwidth \vskip2mm
             \hbox to\colwidth{\hfil\tiny Center for\hfil} \vskip2mm
             \hbox to\colwidth{\hfil\unhcopy0\hfil} \vskip2mm
             \hbox to\colwidth{\hfil\textcolor{\cmprulecolor}{%
                 \vrule height.4\talklinethickness width\wd0}\hfil}}%
           \advance\colheight by-\ht1
           \vbox to\windheight{\hsize=\colwidth \unvcopy1
             \vskip\vmargin \vfil
             \hbox to\colwidth{\hskip.1\hmargin\hfil%
               \rotatebox{90}{\parbox{\colheight}{\raggedright\lineskip=8pt%
                  \reset@font\normalsize\bfseries\@talktitle}}%
               \hfil%
               \rotatebox{90}{\reset@font\small\bfseries\itshape\@authorname}%
               \hfil%
               %\hskip.2\hmargin
               \dimen0=\colheight \advance\dimen0 by-\pagerule
                  \divide\dimen0 by\totalslides
               \count0=1 \advance\totalslides by1 % cycle for page numbers
               \dimen1=\pagecolwidth \advance\dimen1 by-\pagerule
               \vbox to\colheight{\hsize=\pagecolwidth % slide #
                 \loop\hbox to\pagecolwidth{\textcolor{\cmprulecolor}{%
                       \vrule height\dimen0 width\pagerule}%
                     \ifnum\count0=\slideno\def\next{\colorbox{fryellow}}%
                     \else\def\next{\colorbox{frgray}}\fi%
                     \next{\shyperlink{talkslide\the\count0}{%
                     %\next{%
                       \vbox to\dimen0{\hsize=\dimen1
                         \textcolor{\cmprulecolor}{%
                           \hrule height\pagerule\footnotesize}
                         \vfil\hbox to\dimen1{\hfil\the\count0\hfil}\vfil}%
                       %\ifnum\count0=\slideno%
                       % \textcolor{white}{\hbox to0pt{\textcolor{\cmprulecolor}%
                       % {\vrule height\dimen0 width\linethicknes}\hss}}\fi%
                     }}}
                   \vfil\advance\count0 by1
                 \ifnum\count0<\totalslides\repeat%
%                   \hbox to\pagecolwidth{\leaders\textcolor{\cmprulecolor}{%
%}}%                       \hrule height\pagerule}\hfil}}}
                   \hbox to\pagecolwidth{\textcolor{\cmprulecolor}{%
                       \leaders\hrule height\pagerule\hfil}}}}
             \vskip\vmargin}%
           \textcolor{\cmprulecolor}{%
             \vrule width\talklinethickness height\windheight}}}%
       \hbox to\windwidth{\hfil%
         \vbox to\windheight{\vfill
           \vbox to\textheight{\boxmaxdepth=\maxdepth\box\@outputbox}\vfill}%
         \hfil}%
       \textcolor{\cmprulecolor}{%
         \vrule width\talklinethickness height\windheight}}%
    %\textcolor{\cmprulecolor}{
      \hrule height\talklinethickness width\slidewidth%}
      }}
\def\setCAKi{%------------------------------------------------------------ CAKi
  \talklinethickness=1.4pt
  \setbox\logobox=\hbox{\fboxsep=0pt\fboxrule=\talklinethickness\fbox{%
      %\dimen0=\headheight \advance\dimen0 by-2\talklinethickness
      \textcolor{cakorange}{%
        \ifx\Ginclude@graphicsnew\undefined\else\bigfigfalse\fi%
        \includegraphics[height=\headheight]{cak}}}}%
  \dp\logobox=0pt
  \message{ <1:\the\ht\logobox> }%
  \def\apcell##1{{\sffamily\bfseries\nextii{##1}}}
  \def\apcelltype##1{\ifnum\count0=\appage%
      \def\next{\colorbox{\thepagebgrcolor}}%
      \def\nextii{\bfseries\textcolor{\thepagecolor}}%
    \else\def\next{\colorbox{\pagebgrcolor}}%
      \def\nextii{\textcolor{\pagecolor}}\fi%
    \shyperlink{talkslide\the\appage}{\next{\textcolor{black}{##1}}}}
  \def\apcellframe##1{\colorbox{\thepagebgrcolor}{##1}}
  \hlmargin=0em \hrmargin=\hborder \vtmargin=2\hrmargin \vbmargin=0em
  \pagerule=.5\talklinethickness
  \apvrulewidth=\pagerule
  \aphrulewidth=\pagerule
  \hlmargin=0pt \vtmargin=1ex \vbmargin=0pt
  \windwidth=\slidewidth \advance\windwidth by-\wd\logobox
  \windheight=\slideheight \advance\windheight by-\ht\logobox
  \textwidth=\windwidth \advance\textwidth by-\hlmargin
    \advance\textwidth by-\hrmargin
  \textheight=\windheight \advance\textheight by-\vtmargin
    \advance\textheight by-\vbmargin
  \colheight=\windheight
    \advance\colheight by\logoopticdelusion
  \colwidth=\wd\logobox %\advance\colwidth by-\talklinethickness
  \pagecolwidth=\colwidth \advance\pagecolwidth by-2\pagerule
  \def\pagecolor{black}
  \def\thepagecolor{white}
  \def\headbgrcolor{white}
  \def\pagebgrcolor{white}
  \def\thepagebgrcolor{black}
  \def\labelitemicolor{cakorange}}
% \def\outputpageCAKi{% current design
%   \hsize=\slidewidth
%   \vsize=\slideheight
%   \hoffset=\hborder \advance\hoffset by-1in
%   \voffset=\vborder \advance\voffset by-1in
%   \global\advance\count0 by 1
%   %
%    \shipout\vbox{\offinterlineskip
%      \hbox to\slidewidth{% heading
%        \dimen0=\slidewidth \advance\dimen0 by-\wd\logobox
%        \advance\dimen0 by-\talklinethickness
%        \dimen1=\dimen0 \advance\dimen1 by-\hlmargin \advance\dimen1 by-\hrmargin
%        %\textcolor{\cmprulecolor}{%
%          \vrule width\talklinethickness height\ht\logobox depth0pt%}%
%        %\fboxsep=0pt\colorbox{\headbgrcolor}{%
%          \vbox to\ht\logobox{\hsize=\dimen0
%            %\textcolor{\cmprulecolor}{%
%              \hrule height\talklinethickness width\dimen0 depth0pt%}%
%            \vfill
%            \hbox to\dimen0{\hskip\hlmargin%
%              \parbox{\dimen1}{\hypertarget{talkslide\the\slideno}{}%
%                 \centering\reset@font\large\bfseries\@slidetitle}%
%              \hskip\hrmargin}
%            \vfill
%            %\hbox{\ignorespaces%\textcolor{\cmprulecolor}{%
%              \hrule height\talklinethickness width\dimen0 depth0pt}%}}%}%
%       \shref{http://www.c-a-k.cz/}{\copy\logobox}}%
%     \hbox to\slidewidth{% body 
%       \hbox to\windwidth{\hskip\hlmargin\hfil%
%         \vbox to\windheight{\hsize=\textwidth\vskip\vtmargin \vfil
%           \vbox to\textheight{\boxmaxdepth=\maxdepth\box\@outputbox}%
%           \vfil \vskip\vbmargin}%
%         \hfil\hskip\hrmargin}%
%       \fboxsep=0pt\colorbox{\headbgrcolor}{%
%         \hbox to\colwidth{% page column
%            \textcolor{\cmprulecolor}{%
%              \vrule width\pagerule height\windheight depth0pt}%
%            \vbox to\windheight{\hsize=\pagecolwidth% \unvcopy1
%              %\message{ <H=\the\windheight\space W=\the\pagecolwidth>}%
%              \ifnum\totalslides>20\pagecolnumber=2\else\pagecolnumber=1\fi%
%              \arrangepages{\windheight}{\pagecolwidth}%
%                           {\pagecolnumber}{\totalslides}%
%              \vskip\vbmargin}%
%            \textcolor{\cmprulecolor}{%
%              \vrule width\pagerule height\windheight depth0pt}%
%           }}%
%       }%
%   }}
\let\@outputpage=\outputpageEmpty
\let\bigfigoutputpage=\outputpageEmpty

%############################################################### General macros
\def\slidetitle#1{\def\@slidetitle{#1}} \def\@slidetitle{}
\def\talktitle#1{\def\@talktitle{#1}} \def\@talktitle{}
\def\title#1{\def\@title{#1}\talktitle{#1}}
\def\authorname#1{\def\@authorname{#1}}

\newcount\sectno
\newcount\subsectno
\def\@foilhead[#1]#2{\vfill\eject
  \global\advance\slideno by1 \global\advance\subsectno by1
  \slidetitle{#2}\hrule height0pt}%\vskip-\baselineskip}
\def\subhead#1{{\bfseries#1}\par}
\def\@maketitle{\newpage
  %\zerolistvertdimens
  \null\medskip
  \begin{center}
     {\Large\bfseries \@title \par}
     %\vskip\titleauthorskip
     {\smallskip%\lineskip \authorauthorskip
       \begin{tabular}[t]{c}\@author\end{tabular}
       \par}
  \end{center}
  \par\vfil}

\newcount\slideno \slideno=1
\newcount\totalslides \totalslides=1
\def\settotalslides#1{\global\totalslides=#1 }
\AtEndDocument{\vfill\immediate\write\@mainaux{%
  \string\settotalslides\string{\the\slideno\string}}}

%--------------------------------------------------- lists (itemize, enumerate)
\def\labelitemimark{$\m@th\scriptstyle\blacksquare$}
\def\labelitemicolor{black}
\AtBeginDocument{%
  \def\labelitemi{\textcolor{\labelitemicolor}{\ifx\rotate\undefined%
    \labelitemimark\else\rotate{45}{\labelitemimark}\fi}}}
\def\labelitemii{$\m@th\bullet$}
\let\olditemize=\itemize
\def\itemize{\olditemize\setlength{\itemsep}{0pt plus3ex}
  \setlength{\topsep}{0pt plus6ex}
  %\setlength{\parskip}{0pt}
  \setlength{\partopsep}{0pt plus5ex}}
\let\oldenumerate=\enumerate
\def\enumerate{\oldenumerate\setlength{\itemsep}{0pt plus3ex}
  \setlength{\topsep}{0pt plus6ex}
  %\setlength{\parskip}{0pt}
  \setlength{\partopsep}{0pt plus5ex}}
\long\def\maskfoil#1#2{\AtEndDocument{\newpage\hypertarget{#1}{}%
  \setbox0=\hbox{\strut}\wd0=1em
  \shyperlink{talkslide1}{\box0}\slidetitle{\appendixname}\kern-1em #2}}
%----------------------------------------------------------------- bibliography
\renewenvironment{thebibliography}[1]{
 %\bigskip \noindent{\large\refname} \smallskip
 \list{\@biblabel{\arabic{enumiv}}}%
 {\settowidth\labelwidth{\@biblabel{#1}}%
 \leftmargin\labelwidth \advance\leftmargin\labelsep
 \if@openbib
   \advance\leftmargin\bibindent
   \itemindent -\bibindent
   \listparindent \itemindent
   \parsep \z@
 \fi
 \usecounter{enumiv}%
 \let\p@enumiv\@empty
 \renewcommand\theenumiv{\arabic{enumiv}}}
 \if@openbib
   \renewcommand\newblock{\par}
 \else
   \renewcommand\newblock{\hskip .11em \@plus .33em \@minus -.07em}
 \fi
 \sloppy\clubpenalty4000\widowpenalty4000%
 \sfcode`\.=\@m\relax}%
 {\def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
 \endlist}

%------------------------------------------------------------------- hyperlinks
\def\noBorderLinkAttr{\makeatletter%
  \def\pdfBorderAttrs{/Border [0 0 0]}%
  \def\hy@colorlink##1{\begingroup}\def\@pdfhighlight{/None}%
  \def\@pdfborder{0 0 0}\def\@urlcolor{black}\makeatother}
%\AtBeginDocument{%
\long\def\shyperlink{\noBorderLinkAttr\hyperlink}
\long\def\shref{\noBorderLinkAttr\href}
%}

%============================================================== User definitions
%% \begin{narrow}{3} \end{narrow}
\newenvironment{narrow}[1][1]
  {\list{}{\rightmargin=#1\hrmargin \leftmargin=#1\hrmargin}\item\relax}
  {\endlist}

\def\sideImgAB#1#2#3#4#5{\parbox[t]{.9\textwidth}{%
  \mbox{}\vskip0pt\vskip-#3\baselineskip%
  \begin{minipage}[b]{#1\textwidth}\raggedright #4\end{minipage}\hfill%
  \begin{minipage}[b]{#2\textwidth}\centering#5\end{minipage}}}

%------------------------------------------------------------------------ video
%% {width}{proportion}{videofile}
\def\videomode{/Open} %\def\videomode{/Repeat}
\def\video#1#2#3{{\dimen0=#1 \dimen1=#2\dimen0
 \setbox0=\hbox{} \wd0=\dimen0 \ht0=\dimen1 \dp0=0pt
 \hbox{\pdfannot width #1 height \dimen1 depth 0cm {%
    /Subtype /Movie /T (Video)  
    /Movie << /F (#3) /Poster true >>
    /A << /ShowControls true /Mode \videomode >> }\copy0}}}

\endinput
