%%% This is a LaTeX2e document class.
%%%
%%% Customization of the `seminar' style for overhead presentations
%%%
%%% Manuel M. T. Chakravarty <chak@score.is.tsukuba.ac.jp> [1997..1998]
%%%
%%% This file is free software; you can redistribute it and/or modify
%%% it under the terms of the GNU General Public License as published by
%%% the Free Software Foundation; either version 2 of the License, or
%%% (at your option) any later version.
%%%
%%% This file is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%%% GNU General Public License for more details.
%%%
%%% DOCU ======================================================================
%%%
%%% * `online' option for PostScript that can be used online (otherwise, it is 
%%%   for printed slides)
%%%
%%% TODO ======================================================================
%%%
%%% * \headingx should be improved, i.e., use optional argument for \heading
%%%   instead of a new command
%%% * \slitemize is a kludge
%%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{chaksem}[1998/11/04 v1.2b Chak's Seminar Style]

% Pipe options through to the `seminar' style
%
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{seminar}}
\DeclareOption{online}{%  overlays should accumulate
  \special{!tx@Dict begin /BeginOL { dup (all) eq exch TheOL le or { IfVisible
        not { CP OLUnit T moveto /IfVisible true def } if } { IfVisible { CP
          OLUnit NET moveto /IfVisible false def } if } ifelse } def end}%
  }
\ProcessOptions

% seminar style including support for overlays
%
\LoadClass[semlayer,semcolor]{seminar}

% Assume a printer driver that is capable to process the landscape special
%
\renewcommand{\printlandscape}{\special{landscape}}

\RequirePackage{newcent}        % as basic font
\RequirePackage{pifont}         % for labels in lists

% a nice sans font for the main text
%
\renewcommand{\familydefault}{pag}

% colors / grey scales
%
\newgray{darkgray}{.5}

% New page style, where the current heading is set in the lower right of all
% slides belonging to the heading
%
\newpagestyle{withheading}%
  {\thismark}{{\sc\thisheading}\hfill\thepage}
\def\thisheading{}
\pagestyle{withheading}

% Set footer
%
\newcommand{\setfooter}[1]{%
  \gdef\thisheading{#1}}

% A new heading is introduced with the following two commands; the latter is a
% variant that allows headings over two lines
%
\newcommand{\heading}[1]{%
  \centerline{\textbf{\textsc{\darkgray\large#1}}}%
  \vspace*{.2em}
  \par\ignorespaces%
  \setfooter{#1}}
\newcommand{\headingx}[2]{%
  \begin{center}\textbf{\textsc{\darkgray\large#1\\#2}}\end{center}%
  \setfooter{#1 #2}}

% For second level headings (set in small caps and left aligned, followed by a
% colon)
%
\newcommand{\subheading}[1]{%
  \textbf{\textsc{\darkgray#1:}}}
%
% and the same without colon
%
\newcommand{\subheadingx}[1]{%
  \textbf{\textsc{\darkgray#1}}}

% Mark optional slides with \markslide (they get a star set in the lower right
% corner)
%
\def\thismark{}                 % here we store the marker
\newcommand{\markslide}{%       % mark a slide
  \def\thismark{*}}             % note: this defines \thismark *locally*

% New slide frame, consisting of two horizontal lines -- above and below the
% main material (this is less heavy than full frames, but still more
% interesting than no frame at all)
%
\newslideframe{bars}{%
  \vbox{%
    \centerline{\raise1em\hbox{\rule{\textwidth}{.5pt}}}%
    #1%
    \centerline{\rule{\textwidth}{.5pt}}%
    }%
  } 
\slideframe{bars}

% an itemize environment using Zapf's rounded right arrow; the items are set in
% a slightly smaller font with modified spacing
%
\newenvironment{slitemize}{%
    \begin{dinglist}{220}%
      \small
      \vspace*{-.5em}
      \setlength{\itemsep}{-.15em}
      }{
    \end{dinglist}%
    \vspace*{-.1em}%
    \ignorespaces
    }

% an enumerate environment using Zapf's encircled numbers; the items are set in
% a slightly smaller font with modified spacing
%
\newenvironment{slumerate}{%
    \begin{dingautolist}{192}%
      \small
      \vspace*{-.5em}
      \setlength{\itemsep}{-.15em}
      }{
    \end{dingautolist}%
    \vspace*{-.1em}%
    \ignorespaces
    }

% for overlays
%

% format stuff for the second overlay
%
\newcommand{\snd}[1]{{\overlay{1}#1}}
\newenvironment{second}{%
  \bgroup\overlay{1}%
  }{%
  \egroup\ignorespaces
  }

% the first argument goes on the first overlay (original) and the second in
% a box of the same size as that used by the first, but on the second overlay
%
\makeatletter
\newcommand{\fstsnd}[2]{%
  \newif\ifouterm@th
  \ifmmode\outerm@thtrue\else\outerm@thfalse\fi
  \setbox0=\hbox{\ifouterm@th$#1$\else#1\fi}%
%  \unhcopy0\hskip-\wd0%  % doesn't work in math mode
  #1\hskip-\wd0%          % this does
  \snd{#2}%
  }
\makeatother

% stroke out in red in second overlay
%
\makeatletter
\newcommand{\snderase}[1]{%
  \newif\ifouterm@th
  \ifmmode\outerm@thtrue\else\outerm@thfalse\fi
  \setbox0=\hbox{\ifouterm@th$#1$\else#1\fi}%
%  \unhcopy0\hskip-\wd0\hskip-.15ex%
  #1\hskip-\wd0\hskip-.15ex%
  \snd{{\red\raise.25em\hbox{\rule{\wd0}{1pt}\rule{.15ex}{1pt}}}}%
  }
\makeatother
