% \iffalse
%% File: slidenotes.dtx Copyright (C) 1993-1994 Hans van der Meer
%<*driver>
\documentclass{ltxdoc}
\CodelineIndex
\EnableCrossrefs
\RecordChanges
%
\begin{document}
\title{The \textsf{slidenotes} package}
\author{Hans van der Meer\\hansm@fwi.uva.nl}
\date{version number 3.12\\revised 1995/10/23}
\maketitle
%
% \begin{abstract}
%   This article describes the use and the implementation of the 
%   \emph{slidenotes class}.
%   Its purpose is the typesetting of slides and accompanying notes.
%   Slides can be in portrait or landscape orientation.
%   Options are the typesetting of the slides or slides plus notes,
%   or a collection of slides in small format.
% \end{abstract}
%
\DocInput{slidenotes.dtx}
\end{document}
%</driver>
% \fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \CheckSum{801}
%
% \changes{3.0a}{1994/03/21}{First version for LaTeX2E and docstrip}
% \changes{3.0b}{1994/11/24}{Recoded for direct typesetting dtx-file}
% \changes{3.01}{1994/12/10}{Removed @vpt... macros}
% \changes{3.02}{1995/01/26}{sheets->slides, various changes}
% \changes{3.03}{1995/02/02}{small changes}
% \changes{3.04}{1995/08/11}{@currdir in folder defaults}
% \changes{3.05}{1995/08/28}{restructured documentation}
% \changes{3.06}{1995/08/29}{frame variations, LaTeX2e-isms}
% \changes{3.07}{1995/09/01}{frame variations, oval boxing problematic}
% \changes{3.08}{1995/09/04}{note (section) title -> toc error}
% \changes{3.09}{1995/09/05}{added vertical slide centering option}
% \changes{3.10}{1995/09/18}{cue macro changed}
% \changes{3.11}{1995/10/12}{everyslide, nofiles for slides added}
% \changes{3.12}{1995/10/23}{cue macro marginpar always same side}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
%  ^^A  We don't want everything to appear in the index
%
% \DoNotIndex{\#}
% \DoNotIndex{\@dblarg}
% \DoNotIndex{\@empty}
% \DoNotIndex{\@firstoftwo}
% \DoNotIndex{\@height}
% \DoNotIndex{\@ifstar}
% \DoNotIndex{\@ifundefined}
% \DoNotIndex{\@m}
% \DoNotIndex{\@makeother}
% \DoNotIndex{\@namedef}
% \DoNotIndex{\@sanitize}
% \DoNotIndex{\@secondoftwo}
% \DoNotIndex{\@tempdima}
% \DoNotIndex{\@tempdimb}
% \DoNotIndex{\@title}
% \DoNotIndex{\@width}
% \DoNotIndex{\\}
% \DoNotIndex{\{}
% \DoNotIndex{\}}
% \DoNotIndex{\^}
% \DoNotIndex{\ }
% \DoNotIndex{\addtolength}
% \DoNotIndex{\addvspace}
% \DoNotIndex{\advance}
% \DoNotIndex{\begin}
% \DoNotIndex{\begingroup}
% \DoNotIndex{\bigskip}
% \DoNotIndex{\bigskipamount}
% \DoNotIndex{\box}
% \DoNotIndex{\catcode}
% \DoNotIndex{\csname}
% \DoNotIndex{\def}
% \DoNotIndex{\dimen@}
% \DoNotIndex{\divide}
% \DoNotIndex{\dp}
% \DoNotIndex{\edef}
% \DoNotIndex{\else}
% \DoNotIndex{\end}
% \DoNotIndex{\endcsname}
% \DoNotIndex{\endgroup}
% \DoNotIndex{\endlist}
% \DoNotIndex{\enspace}
% \DoNotIndex{\expandafter}
% \DoNotIndex{\fbox}
% \DoNotIndex{\fi}
% \DoNotIndex{\gdef}
% \DoNotIndex{\global}
% \DoNotIndex{\hbox}
% \DoNotIndex{\hfil}
% \DoNotIndex{\hfill}
% \DoNotIndex{\hrule}
% \DoNotIndex{\hspace}
% \DoNotIndex{\ht}
% \DoNotIndex{\if}
% \DoNotIndex{\ifdim}
% \DoNotIndex{\ifnum}
% \DoNotIndex{\ifodd}
% \DoNotIndex{\ifx}
% \DoNotIndex{\item}
% \DoNotIndex{\let}
% \DoNotIndex{\list}
% \DoNotIndex{\m@ne}
% \DoNotIndex{\medskip}
% \DoNotIndex{\medskipamount}
% \DoNotIndex{\multiply}
% \DoNotIndex{\newcommand}
% \DoNotIndex{\newcounter}
% \DoNotIndex{\newenvironment}
% \DoNotIndex{\newif}
% \DoNotIndex{\newlength}
% \DoNotIndex{\newpage}
% \DoNotIndex{\newsavebox}
% \DoNotIndex{\newtoks}
% \DoNotIndex{\next}
% \DoNotIndex{\noexpand}
% \DoNotIndex{\noindent}
% \DoNotIndex{\null}
% \DoNotIndex{\p@}
% \DoNotIndex{\par}
% \DoNotIndex{\parbox}
% \DoNotIndex{\raggedright}
% \DoNotIndex{\relax}
% \DoNotIndex{\renewcommand}
% \DoNotIndex{\setbox}
% \DoNotIndex{\setlength}
% \DoNotIndex{\sloppy}
% \DoNotIndex{\smallskip}
% \DoNotIndex{\smallskipamount}
% \DoNotIndex{\space}
% \DoNotIndex{\stepcounter}
% \DoNotIndex{\string}
% \DoNotIndex{\strut}
% \DoNotIndex{\test}
% \DoNotIndex{\the}
% \DoNotIndex{\tw@}
% \DoNotIndex{\typeout}
% \DoNotIndex{\undefined}
% \DoNotIndex{\value}
% \DoNotIndex{\vbox}
% \DoNotIndex{\vfil}
% \DoNotIndex{\vfill}
% \DoNotIndex{\vskip}
% \DoNotIndex{\vspace}
% \DoNotIndex{\wd}
% \DoNotIndex{\xdef}
% \DoNotIndex{\z@}
%
% \tableofcontents
%
% \section{Usage}
%
% An input file may consist of a series of slides
% accompanied by notes. Below the format of a slide in
% a nutshell:
%
% \begin{verbatim}
% \begin{slide}[SLIDE TITLE (optional)]
%    ...
%    \slidesubtitle{SUBTITLE}
%    ...
%    <more slide text>
%    ...
% \end{slide}
% % Do not put extra text in between notes/slide, 
% % because it interferes destructively with the layout.
% \begin{note}[NOTE TITLE (optional)]
%    ...
%    \cue{MARGIN TEXT}
%    ...
%    <more note text>
%    ...
% \end{note}
% \end{verbatim}
%
% Use \verb+\chapter+ for the main structure, each note will
% be converted to a \verb+\section+.
% There is a special \verb+\pagestyle+ defined.
% Several parameters and font macro's are defined for various
% style features; they can be redefined, either in the document
% or in the \texttt{slidenotes.cfg} file.
% These parameters exist for the dimensions of the slide,
% the font in the various text parts, several standard texts.
%
% Options exist for:
% \begin{itemize}\setlength{\itemsep}{0pt}
% \item choosing between slides, slides + notes, a collection of slides; 
% \item landscape or portrait format;
% \item notes in a type one notch smaller than in the slides;
% \item variation in frame around slide.
% \end{itemize}
% 
% See the implementation sections for further details.
% 
% \StopEventually
%
% \section{Identification}
%
%    This document classes can only be used with \LaTeXe, so we make
%    sure that an appropriate message is displayed when another \TeX{}
%    format is used.
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
%    \end{macrocode}
%
%    Announce the Class name and its version:
%    \begin{macrocode}
\ProvidesClass{slidenotes}[1995/10/23 vs 3.12  Slides and notes]
%    \end{macrocode}
%
% \section{Declaration of Class Options}
%
%    In this part we define the options for this class that are additional
%    to those of its parent class.
%
% \subsection{Show Options in the Log}
%
% Show options to the user.
%
%    \begin{macrocode}
  \ClassWarningNoLine{slidenotes}{%
    Options (first one is default):
      \MessageBreak
    notes,slides,minis:\space type of production;
      \MessageBreak
    landscape,portrait:\space slide orientation;
      \MessageBreak
    center,nocenter:\space vertical centering slide text;
      \MessageBreak
    oval,rect,rules,noframe:\space type of slideframe;
      \MessageBreak
    smallnotes:\space notes one notch smaller}
%    \end{macrocode}
%
% \subsection{Slides and/or Notes}
%
% The flag |\ifnotes| governs the production of notes in the
% typesetting of slides and notes. 
% The flag |\ifminis| signals the production of a slide collection
% in small format.
%
% \begin{macro}{\ifnotes}
% \begin{macro}{\ifminis}
%    \begin{macrocode}
\newif\ifnotes
\newif\ifminis
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% The \texttt{notes} option leads to production of annotated slides.
% If option \texttt{slides} is given, 
% slides are produced in a format ready
% for printing or copying on transparencies.
% Option \texttt{minis} typesets a collection of slides in small format.
% Notes are suppressed in the latter two cases.
%
%    \begin{macrocode}
\DeclareOption{notes}{\notestrue\minisfalse}
\DeclareOption{slides}{\notesfalse\minisfalse}
\DeclareOption{minis}{\ministrue\notesfalse}
%    \end{macrocode}
%
% \subsection{Portrait or Landscape Orientation}
%
% Typesetting of slides can come in portrait or landscape format.
% However mixing of these within one document is not implemented.
% We are on the guard for the existing \texttt{landscape} option and pass
% it on to the parent class.
%
% \begin{macro}{\iflandscape}
%    \begin{macrocode}
\newif\iflandscape
\DeclareOption{landscape}{\landscapetrue}
\DeclareOption{portrait}{\landscapefalse}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Vertical Centering of Slide Material}
%
% Everything below the title at the head of the slide can
% be centered vertically as well as kept tightly below the
% head. Filling is done with |\vfil|, thereby allowing it
% to be overridden simply by the inclusion of a |\vfill|.
%
% \begin{macro}{\belowheadfil}
%    \begin{macrocode}
\newcommand{\belowheadfil}{}
\DeclareOption{center}{\renewcommand{\belowheadfil}{\vfil}}
\DeclareOption{nocenter}{\renewcommand{\belowheadfil}{}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Notes in Smaller Type}
%
% The \texttt{smallnotes} option switches the font set
% in the notes one notch smaller than the standard
% sizes chosen in the style. However the sizes in the slides
% are always the same as to those specified by the style.
%
% \begin{macro}{\ifsmallnotes}
%    \begin{macrocode}
\newif\ifsmallnotes
\DeclareOption{smallnotes}{\smallnotestrue}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Variation in Slideframe}
%
% The frame of a slide can be rectangular, oval or empty.
% In the latter case however, this wish is obeyed for slide
% production only; otherwise the result is unclear.
%
% \begin{macro}{\framevariant}
%    \begin{macrocode}
\newcommand{\framevariant}{}
\DeclareOption{noframe}{\renewcommand{\framevariant}{n}}
\DeclareOption{rules}{\renewcommand{\framevariant}{r}}
\DeclareOption{rect}{\renewcommand{\framevariant}{f}}
\DeclareOption{oval}{\renewcommand{\framevariant}{o}}
%    \end{macrocode}
% \end{macro}
%
% The |\obox| macro is in file \texttt{obox.sty};
% if necessary read in when document processing starts.
%
%    \begin{macrocode}
\AtBeginDocument{\@ifundefined{obox}%
  {\IfFileExists{obox.sty}{\RequirePackage{obox}}%
    {\if\framevariant o
    \PackageWarningNoLine{slidenotes}{oval option disabled}%
    \renewcommand{\framevariant}{f}\fi}}%
  {}}
%    \end{macrocode}
%
% Oval slideframe is drawn using LaTeX's picture command.
% Therefore the range of linethicknesses is restricted to
% those provided by the circle fonts. The following macro
% is defined to one of the standard linethickness commands.
%
% \begin{macro}{\ovalslideframesize}
%    \begin{macrocode}
\newcommand{\ovalslideframesize}{\thicklines}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Pass Options and Load Parent Class}
%
% Since the \emph{slidenotes class} is implemented as a modification
% of an existing document class, we must load the parent class.
% However in order to ease changes in parent classthe
% name of this class is parametrized in macro |\parentclass|.
% An obvious candidate is \emph{report} or friends.
%
% Customize with a definition of |\parentclass| before
% calling |\documentclass|.
%
% \begin{macro}{\parentclass}
%    \begin{macrocode}
\providecommand\parentclass{report}
%    \end{macrocode}
% \end{macro}
%
% Set the class defaults to transparencies without notes and
% portrait format.
%
%    \begin{macrocode}
\ExecuteOptions{notes,landscape,oval,center}
%    \end{macrocode}
%
% The options of the |\documentclass| call which are not specific for the
% \emph{slidenotes class} must be passed to the parent class.
% We take the opportunity to select some defaults, e.g.\ the
% point size and the production of a titlepage 
% in case the parent class is \emph{article}.
%
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\parentclass}}
\PassOptionsToClass{titlepage,a4paper}{\parentclass}
\ProcessOptions
%    \end{macrocode}
%
% Reset the noframe option except in the case where slides are produced.
% This is done because slides without frames in the other cases
% do not present a pleasant filling of the paper.
%
%    \begin{macrocode}
\typeout{}
\if\framevariant n 
  \ifnotes\renewcommand{\framevariant}{f}\fi
  \ifminis\renewcommand{\framevariant}{f}\fi
  \if\framevariant n \else
  \PackageWarningNoLine{slidenotes}{slide frames temporarily on}
  \fi
\fi
%    \end{macrocode}
%
% Show other options chosen.
%
%    \begin{macrocode}
\typeout{slidenotes: slides in 
  \iflandscape LANDSCAPE\else PORTRAIT\fi\space format}
\ifminis
  \typeout{slidenotes: SLIDE COLLECTION}
\else\ifnotes
  \typeout{slidenotes: SLIDES + NOTES}
\else
  \typeout{slidenotes: SLIDE PRODUCTION}
\fi\fi
\typeout{}
%    \end{macrocode}
%
% After this we load the parent class.
% Note that the landscape option is not passed if \texttt{notes}
% is also specified.
%
%    \begin{macrocode}
\iflandscape\ifnotes\else
  \PassOptionsToClass{landscape}{\parentclass}%
\fi\fi
\LoadClass{\parentclass}
%    \end{macrocode}
%
% When notes are suppressed, we also suppress the production
% of auxiliary files.
%
%    \begin{macrocode}
\ifnotes\else\nofiles\fi
%    \end{macrocode}
%
% \section{Slide Environment}
%
% \subsection{Dimensions}
%
% We give default values for height and width in portrait format,
% |\slideheight| and |\slidewidth| respectively. 
% In the initialization section the landscape format is set
% by an exchange of height and width.
% All values are for the small (i.e. slide and notes) production set. 
% For the production of the slides
% themselves, these values are magnified by
% the factor |\slidemagnification|.
%
% \begin{macro}{\slidemagnification}
% \begin{macro}{\slidewidth}
% \begin{macro}{\slideheight}
%    \begin{macrocode}
\newcommand{\slidemagnification}{\magstep4}
\newlength{\slidewidth}\setlength{\slidewidth}{85mm}
\newlength{\slideheight}\setlength{\slideheight}{120mm}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Furthermore we define special parameters for the
% separation between frame and contents of the slide,
% |\slideboxsep| and for the thickness of the frame, |\slideboxrule|.
% Length |\slidenotesep| is the distance between the slide
% and the note, |\slidetitlesep| the skip below a call of
% a (sub)title macro.
%
% \begin{macro}{\slideboxrule}
% \begin{macro}{\slideboxsep}
% \begin{macro}{\slidenotesep}
% \begin{macro}{\slidetitlesep}
%    \begin{macrocode}
\newlength{\slideboxrule}\setlength{\slideboxrule}{.2mm}
\newlength{\slideboxsep}\setlength{\slideboxsep}{3mm}
\newlength{\slidenotesep}\setlength{\slidenotesep}{8mm}
\newlength{\slidetitlesep}\setlength{\slidetitlesep}{\medskipamount}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Registers}
% 
% The slides are counted and the counter is reset whenever
% a new chapter is begun.
%
% \begin{macro}{\slidecounter}
%    \begin{macrocode}
\newcounter{slidecounter}[chapter]
%    \end{macrocode}
% \end{macro}
%
% Slides are typeset in a box for later placement and
% height adjustement.
%
% \begin{macro}{\slidebox}
%    \begin{macrocode}
\newsavebox{\slidebox}
%    \end{macrocode}
% \end{macro}
%
% Slides are marked by a text and a number. The text by
% default stems from the |\chapter| macro and is put into
% a token register named |\slidemarker|.
%
% \begin{macro}{\slidemarker}
%    \begin{macrocode}
\newtoks\slidemarker
%    \end{macrocode}
% \end{macro}
%
% Each slide has an optional title, to be printed at the
% top of the slide. In the next tokenregister this title
% is kept, because it is also used in the production
% of the table of contents entry.
%
% \begin{macro}{\slidetitletext}
%    \begin{macrocode}
\newtoks\slidetitletext
%    \end{macrocode}
% \end{macro}
%
% At the start of each slide a token register is executed,
% where the user can place settings that should be local
% to each slide. The same for the start of each note.
%
% \begin{macro}{\everyslide}
% \begin{macro}{\everynote}
%    \begin{macrocode}
\newtoks\everyslide
\newtoks\everynote
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Redefine Chapter Code}
%
% In order to process the slide marking
% two macro's in the production of chapter heads are redefined.
% Also a new chapter starts a new page and the
% pagestyle for this page is set to \texttt{empty}.
%
% \begin{macro}{\@makechapterhead}
% \begin{macro}{\@makeschapterhead}
%    \begin{macrocode}
\let\old@makechapterhead=\@makechapterhead
\let\old@makeschapterhead=\@makeschapterhead
\renewcommand{\@makechapterhead}[1]{%
  \global\slidemarker={#1}\old@makechapterhead{#1}%
  \thispagestyle{empty}\newpage}
\renewcommand{\@makeschapterhead}[1]{%
  \global\slidemarker={#1}\old@makeschapterhead{#1}%
  \thispagestyle{empty}\newpage}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Slide Environment}
%
% Slides are collected in the \texttt{slide} environment.
% Each slide starts a new page, except when a collection is made.
% The font is set to the special chosen |\slidefont|.
% The fontsize is initialized to the normal size.
% From the optional argument the title on top of the slide is taken.
%
% \begin{environment}{slide}
%    \begin{macrocode}
\newenvironment{slide}[1][]{%
  \global\slidetitletext{#1}%
  \ifminis\noindent\else\newpage\fi
  \stepcounter{slidecounter}%
  \slidefont
  \normalsize
%    \end{macrocode}
%
% \subsubsection{Typeset Slide Contents}
%
% The contents of the slide is typeset in a \texttt{minipage},
% which is captured in a box. 
% Execution starts the box with the code in token register |\everyslide|.
% When the optional argument is not empty, this
% furnishes the slide title at its top.
% The width of the \texttt{minipage}, in which the contents of
% the slide are typeset,
% is the |\slidewidth| adjusted for the thickness of the
% surrounding frame and the separation between frame and contents.
%
%    \begin{macrocode}
  \@tempdima\slidewidth
  \advance\@tempdima-\tw@\slideboxrule
  \advance\@tempdima-\tw@\slideboxsep
  \@tempdimb\slideheight
  \advance\@tempdimb-\tw@\slideboxrule
  \advance\@tempdimb-\tw@\slideboxsep
  \begin{lrbox}{\slidebox}%
    \the\everyslide
    \begin{minipage}[][\@tempdimb][t]{\@tempdima}%
     \slidetitle{\the\slidetitletext}\belowheadfil
  }{\vfil\end{minipage}\end{lrbox}%
%    \end{macrocode}
%
% \subsubsection{Enclose Slide Contents in Frame}
%
% The slide contents are enclosed in a framed box and
% then together with the marker placed into a |\parbox|.
% The slide is horizontally centered on the paper; except
% when a collection is made. The height of the box is
% adjusted to slideheight minus frame.
%
%    \begin{macrocode}
  \ifminis\noindent\else\begin{center}\fi
  \parbox{\slidewidth}{%
    \fboxsep\slideboxsep
    \fboxrule\slideboxrule 
    \if\framevariant f 
        \fbox{\usebox\slidebox}\fi
    \if\framevariant o 
        \@tempdimb\dp\slidebox
        \advance\@tempdimb-\fboxsep
        \advance\@tempdimb-\fboxrule
        \obox[][\ovalslideframesize]{%
            \raisebox{\@tempdimb}{\usebox\slidebox}}\fi
    \if\framevariant n 
        \advance\fboxsep\fboxrule \fboxrule\z@
        \fbox{\usebox\slidebox}\fi
    \if\framevariant r
        \rule{\slidewidth}{\fboxrule}\\[\fboxsep]
        \usebox{\slidebox}\\[\fboxsep]
        \rule{\slidewidth}{\fboxrule}\fi
    \\*[\smallskipamount]
    \hbox to\slidewidth{%
      \small\strut\the\slidemarker
      \hfil\Slidenumber~\theslidecounter}%
  }%
  \ifminis
    \ifodd\value{slidecounter}\hfill\else\par\vfill\fi
  \else\end{center}\fi
%    \end{macrocode}
%
% \medskip
% When we are typesetting notes, finish the paragraph.
% Then close the environment.
%
%    \begin{macrocode}
  \ifnotes\par\fi}
%    \end{macrocode}
% \end{environment}
%
% \subsection{Titles on Slides}
%
% Put centered title or subtitle on the slide.
% The first (and optional) argument controls the font setting.
% These titles are followed by a |\medskip|; whitespace before
% the title is the responsibility of the slidewriter.
% These titles are suppressed if their argument somehow
% turns out to be empty.
%
% \begin{macro}{\@slidetitle}
% \begin{macro}{\slidetitle}
% \begin{macro}{\slidesubtitle}
%    \begin{macrocode}
\newcommand{\@slidetitle}[2]{%
    \@ifemptyarg{#2}{}{\begin{center}#1#2\end{center}\vspace{\slidetitlesep}}}
\newcommand*{\slidetitle}{\@slidetitle{\slidetitlefont}}
\newcommand*{\slidesubtitle}{\@slidetitle{\slidesubtitlefont}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Cues in the Margin}
%
% The length variable |\marginwidth| holds the margin space
% that will be reserved for short remarks.
%
% \begin{macro}{\marginwidth}
%    \begin{macrocode}
\newlength{\marginwidth}
\setlength{\marginwidth}{3cm}
%    \end{macrocode}
% \end{macro}
%
% Giving short remarks in the margin of the notes text.
% To be used for finding specific text parts with a glance.
%
% \begin{macro}{\cue}
%    \begin{macrocode}
\newcommand*{\cue}[2][\cuefont]{%
  \marginpar{\hspace*{-\marginwidth}%
  \parbox{\marginparwidth}{\raggedright\sloppy#1#2}}}
%    \end{macrocode}
% \end{macro}
%
% |\cue| cannot allow marginpar switching from left to
% right margin when typesetting twosided material; therefore
% force all marginpars into the same margin.
%
%    \begin{macrocode}
\@mparswitchfalse
%    \end{macrocode}
%
% \section{Style Features}
%
% \subsection{Pagestyle}
%
% As default style \texttt{headings} is chosen.
% However the appearance is altered a bit.
% Note that we add somewhat to |\headheight|.
% In draft mode the date is added to the heading.
%
% \begin{macro}{\thehead}
% \begin{macro}{\ps@headings}
%    \begin{macrocode}
\newcommand{\thehead}{%
    \@title\ifdim\overfullrule>\z@---\@date\fi}
\renewcommand{\ps@headings}{%
  \let\@oddfoot\@empty
  \let\@evenfoot\@empty
  \renewcommand{\@oddhead}{%
    \vbox{%
    \hbox to\textwidth{\headerfont\thehead\hfil\upshape\thepage}%
    \vskip1.5\p@
    \hrule\@height.5\p@\@width\textwidth
    }}%
  \let\@evenhead\@oddhead}
  \addtolength{\headheight}{2pt}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% Notes get the \texttt{headings} style and,
% of course, slides the \texttt{empty} style.
%
%    \begin{macrocode}
\ifnotes\pagestyle{headings}\else\pagestyle{empty}\fi
%    \end{macrocode}
%
% \subsection{Fonts}
%
% Choose fonts for the various elements of slides and notes.
% Their names speak for themselves.
%
% \begin{macro}{\headerfont}
% \begin{macro}{\slidefont}
% \begin{macro}{\notesfont}
% \begin{macro}{\footnotefont}
% \begin{macro}{\slidetitlefont}
% \begin{macro}{\slidesubtitlefont}
% \begin{macro}{\cuefont}
%    \begin{macrocode}
\newcommand{\headerfont}{\rmfamily}
\newcommand{\slidefont}{\sffamily}
\newcommand{\notesfont}{\rmfamily}
\newcommand{\footnotefont}{\sffamily\mdseries\upshape}
\newcommand{\slidetitlefont}{\Large\bfseries}
\newcommand{\slidesubtitlefont}{\normalsize\bfseries}
\newcommand{\cuefont}{\sffamily\bfseries}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \section{Language Adjustments}
%
% A small problem arose with the Babel system.
% If a language is not defined with |\addlanguage| an
% |\errmessage| interfers with the smooth processing.
% We avoid this problem with the following macro.
%
% \begin{macro}{\onlanguage}
%    \begin{macrocode}
\newcommand\onlanguage[4]{% {current}{existing}{not existing}
  \expandafter\ifx\csname l@#1\endcsname\relax
  #4\else
    \ifnum\csname l@#1\endcsname=\language #2%
    \else#3\fi
  \fi}
%    \end{macrocode}
% \end{macro}
%
% Next we define a series of language specific verbs, such
% as |\Collection| and |\Slidenumber|; the latter being the
% designation preceding the slide number.
%
% \begin{macro}{\Collection}
% \begin{macro}{\Slidenumber}
%    \begin{macrocode}
\newcommand{\Collection}{LECTURE NOTES}%
\newcommand{\Slidenumber}{\#}%
\newcommand{\Slide}{Slide}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{English}
%
% Put here all english equivalents.
% \begin{macro}{\englishSlideNames}
%    \begin{macrocode}
\newcommand{\englishSlideNames}{%
  \renewcommand{\Collection}{LECTURE NOTES}%
  \renewcommand{\Slidenumber}{\#}%
  \renewcommand{\Slide}{Slide}%
  }
%    \end{macrocode}
% \end{macro}
%
% If appropriate set one of these languages at the start of the document.
%
%    \begin{macrocode}
\AtBeginDocument{\onlanguage{english}{\englishSlideNames}{}{}}
\AtBeginDocument{\onlanguage{american}{\englishSlideNames}{}{}}
%    \end{macrocode}
%
% \subsection{Dutch}
%
% Put here all dutch equivalents.
%
% \begin{macro}{\dutchSlideNames}
%    \begin{macrocode}
\newcommand{\dutchSlideNames}{%
  \renewcommand{\Collection}{COLLEGE AANTEKENINGEN}%
  \renewcommand{\Slidenumber}{Nr.}%
  \renewcommand{\Slide}{Slide}%
  }
\AtBeginDocument{\onlanguage{dutch}{\dutchSlideNames}{}{}}
%    \end{macrocode}
% \end{macro}
%
% Put here other language specific macros at will.
%
% \section{Macros That May Be Missing}
%
% Testing for the presence or absence of a parameter.
%
% \begin{macro}{\@ifemptyarg}
%    \begin{macrocode}
\providecommand*{\@ifemptyarg}[1]{% {absence}{presence}
  \ifx\@empty#1\@empty
  \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
%    \end{macrocode}
% \end{macro}
%
% \section{Directory Localization}
%
% Specify folders (directories) for the main source,
% a common folder for related material and a folder
% for e.g.\ EPSF figures etc.
%
% \begin{macro}{\Mainfolder}
% \begin{macro}{\Commonfolder}
% \begin{macro}{\Figuresfolder}
%    \begin{macrocode}
\newcommand{\Mainfolder}[1]{\def\mainfolder{#1}}
\newcommand{\Commonfolder}[1]{\def\commonfolder{#1}}
\newcommand{\Figuresfolder}[1]{\def\figuresfolder{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Initialize them on empty values.
%
%    \begin{macrocode}
\Mainfolder{\@currdir}
\Commonfolder{\@currdir}
\Figuresfolder{\@currdir}
%    \end{macrocode}
%
% \section{Configuration File}
%
% Last, but not least, see if there is a configuration
% file \texttt{slidenotes.cfg} and read it for the final adjustments.
% In this file one can change things like the
% font selection, size of various length variables, etc.
% Final settings take place afterwards.
%
%    \begin{macrocode}
\InputIfFileExists{slidenotes.cfg}{}{}
%    \end{macrocode}
%
% \section{Process the Orientation Options}
%
% Now that all variable data have there final value, either
% from the style or from the \texttt{slidenotes.cfg} file, we can
% process al parameter dependent settings.
%
% \subsection{Page Orientation}
%
% In case of landscape format the height and width of the page
% need to be exchanged when slides and notes are produced.
% Then we use a portrait format with a landscaped slide on it.
%
%    \begin{macrocode}
\iflandscape\ifnotes
  \setlength{\@tempdima}{\paperheight}
  \setlength{\paperheight}{\paperwidth}
  \setlength{\paperwidth}{\@tempdima}
\fi\fi
%    \end{macrocode}
%
% \subsection{Slide Orientation}
%
% In case of landscape format the height and width of slides
% need to be exchanged.
%
%    \begin{macrocode}
\iflandscape
  \setlength{\@tempdima}{\slideheight}
  \setlength{\slideheight}{\slidewidth}
  \setlength{\slidewidth}{\@tempdima}
\fi
%    \end{macrocode}
%
% \section{Note Production}
%
% We use the comment mechanism of Victor Eijkhout for 
% the inclusion or exclusion of notes.
%
% \begin{macro}{\includenote}
% \begin{macro}{\excludenote}
%    \begin{macrocode}
\ifx\undefined\ThrowAwayComment
\newcommand\ThrowAwayComment[1]{\begingroup
    \def\CurrentComment{#1}%
    \@sanitize \@makeother\{ \@makeother\}
    \@makeother\^^L% and whatever other special cases
    \endlinechar`\^^M\@makeother\^^M\xComment}
{%
    \catcode`\^^M=12 \endlinechar=-1 %
    \gdef\xComment#1^^M{\def\test{#1}%
    \expandafter\ifx\csname PlainEnd\CurrentComment Test\endcsname\test
    \let\next\endgroup
    \else
    \expandafter\ifx\csname LaLaEnd\CurrentComment Test\endcsname\test
    \edef\next{\endgroup\noexpand\end{\CurrentComment}}%
    \else \let\next\xComment\fi \fi \next}%
}
%
\def\includecomment
 #1{\@namedef{#1}{}\@namedef{end#1}{}}%
\def\excludecomment
 #1{\@namedef{#1}{\ThrowAwayComment{#1}}%
    {\escapechar=\m@ne\relax
     \expandafter\xdef\csname PlainEnd#1Test\endcsname
        {\string\\end#1}%
     \expandafter\xdef\csname LaLaEnd#1Test\endcsname
        {\string\\end\string\{#1\string\}}%
    }}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Note Environment}
%
% In case of productions of slides the notes are simply left out;
% we effectuate this with the comment mechanism. Otherwise
% the \texttt{note} environment is defined.
% Start the environment for notes with font selection.
% The fontsize is initialized on the normal size.
% If the smallnotes option has been chosen, all fontsizes
% are set one notch down.
% Execution starts the note with the code in token register |\everynote|.
%
% \begin{environment}{note}
%    \begin{macrocode}
\ifnotes
\newenvironment{note}[1][]{%
  \notesfont
  \ifsmallnotes
    \let\Huge\huge
    \let\huge\LARGE
    \let\LARGE\Large
    \let\Large\large
    \let\large\normalsize
    \let\normalsize\small
    \let\small\footnootsize
    \let\footnotesize\scriptsize
    \let\scriptsize\tiny
  \fi
  \normalsize
  \the\everynote
%    \end{macrocode}
%
% The optional argument to the notes part replaces
% the title given on the slide.
%
%    \begin{macrocode}
  \@ifemptyarg{#1}{}{\slidetitletext{#1}}%
%    \end{macrocode}
%
% A line is written to the \texttt{toc} file.
%
%    \begin{macrocode}
  \addcontentsline{toc}{section}%
    {\Slide\,\theslidecounter:\space\the\slidetitletext}%
%    \end{macrocode}
%
% Seperate slide and note with some white space.
%
%    \begin{macrocode}
  \addvspace{\slidenotesep}%
%    \end{macrocode}
%
% We use the \texttt{list} environment for offsetting
% the margin inside the notes, a variation on the
% \texttt{quote} environment. However, the leftmargin is
% reduced to zero, because we do not want extra indentation
% for the text of the notes.
%
%    \begin{macrocode}
  \list{}{\leftmargin=\z@ \rightmargin=\marginwidth}\item[]
%    \end{macrocode}
%
% Finish the \texttt{note} environment, close page with a filler.
%
%    \begin{macrocode}
  }{\endlist\vfill\newpage}
%    \end{macrocode}
% \end{environment}
%
%    \begin{macrocode}
\else
\excludecomment{note}
\fi
%    \end{macrocode}
%
% \subsection{Shutoff Titles if Necessary}
%
% Kill the title and the chapter pages for slide production, 
% but not when a collection is prepared.
% Also allow for the fact that |\chapter| effects
% a change to pagestyle \texttt{plain}.
%
% \begin{macro}{\maketitle}
% \begin{macro}{\@makechapterhead}
% \begin{macro}{\@makeschapterhead}
%    \begin{macrocode}
\ifnotes\else\ifminis\else
  \renewcommand{\maketitle}{}
  \renewcommand{\@makechapterhead}[1]{\global\slidemarker={#1}%
    \thispagestyle{empty}}
  \renewcommand{\@makeschapterhead}[1]{\global\slidemarker={#1}%
    \thispagestyle{empty}}
\fi\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \section{Page Dimensions}
%
% \subsection{Fullsize Slides}
%
% First we typeset with an enlarged magnification.
%
%    \begin{macrocode}
\ifnotes\else\ifminis\else
  \mag\slidemagnification\relax
%    \end{macrocode}
%
% Horizontal dimensions:
%
%    \begin{macrocode}
  \setlength{\hoffset}{-25.4mm}
    \divide\hoffset by\slidemagnification
    \multiply\hoffset by\@m
  \setlength{\textwidth}{\paperwidth}
    \divide\textwidth by\slidemagnification
    \multiply\textwidth by\@m
  \setlength{\oddsidemargin}{0pt}
  \setlength{\evensidemargin}{\oddsidemargin}
%    \end{macrocode}
%
% Vertical dimensions:
%
%    \begin{macrocode}
  \setlength{\voffset}{-25.4mm}
    \divide\voffset by\slidemagnification
    \multiply\voffset by\@m
  \setlength{\headheight}{0pt}
  \setlength{\headsep}{0pt}
  \setlength{\textheight}{\slideheight}
    \addtolength{\textheight}{10mm}
    \divide\textheight by\@m
    \multiply\textheight by\slidemagnification
%    \end{macrocode}
%
%    \begin{macrocode}
\fi\fi
%    \end{macrocode}
%
% \subsection{Collection of Slides}
%
%    \begin{macrocode}
\ifnotes\else\ifminis
  \dimen@=2\slidewidth
  \advance\dimen@ 5mm
  \ifdim\dimen@>\textwidth \setlength{\textwidth}{\dimen@}\fi
  \setlength{\headheight}{0pt}
  \setlength{\headsep}{0pt}
  \setlength{\footskip}{0pt}
  \dimen@=2\slideheight
    \setbox0=\vbox{\hbox{\slidefont\small\strut}\smallskip\null}
    \advance\dimen@ by 2\ht0
  \ifdim\dimen@>\textheight
    \setlength{\textheight}{\dimen@}
    \dimen@\paperheight
    \advance\dimen@-\textheight
    \addtolength{\topmargin}{-.5\dimen@}
  \fi
  \setlength{\oddsidemargin}{0pt}
  \setlength{\evensidemargin}{\oddsidemargin}
\fi\fi
%    \end{macrocode}
%
% \subsection{Slides and Notes}
%
% Change margin settings and enlarge |\marginparwidth|
% by the extra margin.
%
%    \begin{macrocode}
\ifnotes
  \setlength{\marginparsep}{5mm}
  \addtolength{\marginparwidth}{\marginwidth}
\fi
%
% Initialize the font.
%
%    \begin{macrocode}
\notesfont
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \Finale \PrintIndex\PrintChanges
%
