%%
%% Presentation style
%%

%% can call commands even when they are not defined
\def\safe#1{%
\ifdefined#1%
#1%
\else%
{\color{red}\bf?}%
\fi%
}


%% paper size
\setlength\paperheight{240pt}
\setlength\paperwidth{320pt}

%% body size
% height=paperheight-2xtopmargin-footskip
\textheight=208pt
% width=paperwidth-2xoddsidemargin
\textwidth=272pt

%% margins
\voffset=-1in
\hoffset=-1in
\oddsidemargin=24pt
\evensidemargin=24pt
\topmargin=8pt
\headheight=0pt
\headsep=0pt
\marginparsep=0pt
\marginparwidth=0pt
\footskip=16pt
\skip\footins=0pt

%% reset skips
\parskip=0pt
\parindent=0pt
\baselineskip=0pt
\AtBeginDocument{
}

%% footer
\def\ps@plain{
  \def\@oddhead{}
  \def\@evenhead{\@oddhead}
  \def\@oddfoot{\tiny\hfill\thepage/\safe\slidecount\hfill}
  \def\@evenfoot{\@oddfoot}
}
\def\ps@empty{
  \def\@oddhead{}
  \def\@evenhead{\@oddhead}
  \def\@oddfoot{}
  \def\@evenfoot{\@oddfoot}
}

%% save total slide count
\AtEndDocument{
  \immediate\write\@auxout{\noexpand\gdef\noexpand\slidecount{\thepage}}
}

\pagestyle{plain}

%% title of slide
\def\title#1{
  \hfil{\bf\large #1}\par
  \hfil\vrule width0.75\textwidth height0.3pt\par
  \vskip5pt
}

%% itemize
\newlength\itemizeskip
% left margin for items
\setlength\itemizeskip{20pt}
% item symbol
\def\itemizept{\textbullet}
\newlength\itemizeseparator
% space between the item symbol and the text
\setlength\itemizeseparator{5pt}

\newlength\current@itemizeskip
\setlength\current@itemizeskip{0pt}
\def\itemize{
  \vfil
  \addtolength\current@itemizeskip{\itemizeskip}
  \leftskip\current@itemizeskip
}
\def\enditemize{
  \addtolength\current@itemizeskip{-\itemizeskip}
  \par\leftskip\current@itemizeskip
  \vfil
}
\newlength\itempt@total
\def\item{
  \settowidth\itempt@total{\itemizept}
  \addtolength\itempt@total{\itemizeseparator}
  \par
  \vfil
  \hskip-\itempt@total\itemizept\hskip\itemizeseparator
}

\def\itemptchange#1{
  \let\itempt@prev\itemizept
  \def\itemizept{#1}
}
\def\itemptreset{
  \def\itemizept{\itempt@prev}
}
