%%
%% This is file `mathexam.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mathexam.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2007 by Jan Hlavacek
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mathexam}
        [2007/07/30 v1.00 Package for typesetting exams]
\newif\ifExamHdr
\ExamHdrtrue
\DeclareOption{nohdr}{\ExamHdrfalse}
\ProcessOptions
\ifExamHdr
\RequirePackage{fancyhdr}
\RequirePackage{lastpage}
\RequirePackage{ifthen}
\fi
\newcommand{\ExamName}[1]{\def\@xamname{#1}}
\newcommand{\ExamClass}[1]{\def\@xamclass{#1}}
\newcommand{\ExamHead}[1]{\def\@xamrighthdr{#1}}
\def\@xamname{\relax}
\def\@xamclass{\relax}
\def\@xamrighthdr{\relax}
\ifExamHdr
\pagestyle{fancy}

\lhead{\@xamclass}
\chead{\@xamname}
\rhead{Page \thepage\ of \pageref{LastPage}}

\rfoot{\ifthenelse{\value{page}=\pageref{LastPage}}{The End.}{Cont.}}
\cfoot{}
\AtBeginDocument{
\begin{center}
   \large\scshape \@xamclass \hfill \@xamname \hfill \@xamrighthdr
\end{center}}

\thispagestyle{empty}
\fi
\newcommand{\answ@r}[1][\fill]{%
   \nopagebreak\vspace{#1}\par\nopagebreak\hfill\hbox to
   .5\columnwidth{Answer:\hrulefill}\vspace{\baselineskip}}

\newcommand{\addansw@r}[1][\baselineskip]{%
   \nopagebreak\vspace{#1}\par\nopagebreak\hfill\hbox to
   .5\columnwidth{Answer:\hrulefill}\vspace{\baselineskip}}
\newcommand{\answ@rstar}[2][\fill]{%
   \nopagebreak\vspace{#1}\par\nopagebreak\hfill\hbox to
   .5\columnwidth{#2\hrulefill}\vspace{\baselineskip}}

\newcommand{\addansw@rstar}[2][\baselineskip]{%
   \nopagebreak\vspace{#1}\par\nopagebreak\hfill\hbox to
   .5\columnwidth{#2\hrulefill}\vspace{\baselineskip}}
\def\answer{%
   \def\e@t*{}%
   \def\n@xt{\if\noexpand\myn@@xt*%
      \expandafter\expandafter\expandafter\answ@rstar\expandafter\e@t\else%
      \expandafter\answ@r\fi}%
   \futurelet\myn@@xt\n@xt}

\def\addanswer{%
   \def\e@t*{}%
   \def\n@xt{\if\noexpand\myn@@xt*%
      \expandafter\expandafter\expandafter\addansw@rstar\expandafter\e@t\else%
      \expandafter\addansw@r\fi}%
   \futurelet\myn@@xt\n@xt}
\newcommand{\noanswer}[1][\fill]{\nopagebreak\vspace{#1}\par}
\newcommand{\ExamNameLine}{%
\par
\vspace{\baselineskip}
Name:\hrulefill\relax
\par}
\newcommand{\ExamInstrBox}[1]{\begin{center}\vspace{\baselineskip}%
   \fbox{\fbox{\parbox{.8\hsize}{#1}}}\end{center}}

\endinput
%%
%% End of file `mathexam.sty'.
