%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%% File: FYM.sty, version 1.0, November 2002
%%% =========================================
%%% Copyright (c) 2002 by Bruno Welfert.  All rights reserved.
%%% This file is free and can be modified or distributed as long as
%%% you meet the following conditions:
%%%
%%% (1) This copyright notice is kept intact on all modified copies.
%%% (2) If you modify this file, you MUST NOT use the original file name.
%%%
%%% Usage:
%%% ======
%%%
%%% To use this file with LaTeX2e, keep it with the rest of your thesis
%%% files or make sure your TEXINPUTS environment variable contains the
%%% directory in which this file is located. Include this file as a
%%% package in the preamble:
%%%
%%% \documentclass[...]{report}
%%% \usepackage{FYM}
%%%
%%% A template for a final is provided in the file "FYMfinal.tex", available
%%% from the same place where you obtained this file.
%%%
%%% Command Names:
%%% ==============
%%%
%%% The following is a list of all variables the user needs to redefine
%%% using \renewcommand, e.g.,
%%%
%%% \renewcommand{\instructor}{First M. Last}
%%%
%%% after loading the package in LaTeX2e.
%%%
%%% \instructor    %% Instructor's name; defaults to "Stefania Tracogna".
%%% \course        %% Course name; defaults to "MAT 170".
%%% \examnumber    %% Exam type and number; defaults to "Exam 3".
%%% \examdate      %% Date(s) of the exam; defaults to "November 14, 2002".
%%% \examsemester  %% Semester exam is taken; defaults to "Fall".
%%% \examyear      %% Year exam is taken; defaults to "2002".
%%% \covers        %% Topics covered by the exam; defaults to " ".
%%% \directions    %% Directions for students; defaults to "SHOW YOU WORK!".
%%% \exampolicy    %% Policy for calculators,... defaults to "Calculators ok.".
%%% \optional      %% Optional text placed at bottom of test (e.g. formulas);
%%%                   defaults to " ".
%%%
%%% In addition to the above variables, the following commands are provided:
%%%
%%% \exampage      %% Generates the front page for an exam (test or final).
%%% \draft         %% Prints a (red) timestamp at the bottom of each page.
%%% \spot          %% Prints an underline blank for answers.
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\typeout{**********************************************************************}
\typeout{** Department of Mathematics & Statistics, Arizona State University   }
\typeout{** Exam style file version 1.0, November 2002. Written by B. Welfert.}
\typeout{**********************************************************************}

%%%
%%% Set up page layout parameters.
%%%
\setlength{\textheight}{9.0in}
\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in}
\setlength{\textwidth}{6.2in}
\setlength{\voffset}{-.5in}

%%%
%%% Set up default values.
%%%
\newcommand{\instructor}{Stefania Tracogna}
\newcommand{\course}{MAT 170}
\newcommand{\examnumber}{3}
\newcommand{\examdate}{November 14, 2001}
\newcommand{\examsemester}{Fall}
\newcommand{\examyear}{2001}
\newcommand{\covers}{ }
\newcommand{\directions}{SHOW YOUR WORK!}
\newcommand{\exampolicy}{Calculators ok.}
\newcommand{\optional}{ }

%%%
%%% Generate cover page.
%%%
\newcommand\spot[1]{\rule[-3pt]{#1}{.5pt}}%
\renewcommand\headheight{20pt}
\renewcommand{\ps@myheadings}{%
    \renewcommand{\@oddhead}{  
    \scriptsize\hfil\parbox[b]{\textwidth}{\begin{center}
    \course, \examsemester\hspace*{2pt}\examyear -- \textbf{\instructor} \\
    \copyright\hspace*{2pt}\examyear\hspace*{2pt}
    Arizona State University Department of Mathematics \& Statistics\\
    \textbf{{\examnumber} - \covers}\end{center}}\hfil}
    \renewcommand{\@oddfoot}{}
    }
\newcommand{\exampage}{
    \pagestyle{myheadings}
    \noindent
    \fbox{\parbox[t]{0.98\textwidth}{
         \vspace*{10pt}
         \hfill \emph{\large Place Label Here} \hspace*{10pt} \\[15pt]
         \textbf{\Large \hspace*{\parindent} \course}\\[15pt]
         \textbf{\Large \hspace*{\parindent} \examnumber}\\[15pt]
         \textbf{\Large \hspace*{\parindent} \instructor}\\[15pt]
         \textbf{\Large \hspace*{\parindent} \examdate}}}\\[15pt]
    Honor Statement:\\[10pt]
    I have neither given nor received information regarding this exam, 
    and I will not do so until all exams have been graded and returned.\\[15pt]
    Signed \spot{2in} \\[10pt]
    \begin{center}{\large\textbf{\underline{DIRECTIONS}}}\end{center}
    \vspace*{-10pt}
    \textbf{\parbox[t]{0.95\textwidth}{\directions}}\\[20pt]
    \fbox{\textbf{\parbox[t]{0.95\textwidth}{\exampolicy}}}
    \hspace*{0pt}\newline\newline\newline\optional
    \newpage
}

%%%
%%% Command to print draft version in red.
%%%
\def\Color#1#2{\special{color push cmyk #1}#2\special{color pop}}
\newcommand{\draft}{
    \renewcommand{\ps@myheadings}{%
        \renewcommand{\@oddhead}{  
        \scriptsize\hfil\parbox[b]{\textwidth}{\begin{center}
        \course, \examsemester\hspace*{2pt}\examyear -- \textbf{\instructor} \\
        \copyright\hspace*{2pt}\examyear\hspace*{2pt}
        Arizona State University Department of Mathematics \& Statistics\\
        \textbf{{\examnumber} - \covers}\end{center}}\hfil}
        \renewcommand{\@oddfoot}{  
        \Color{0 1 1 0}{\textsl{Draft of \timestamp}\hfil Page \thepage}
        }
    }
}
%
%%%
%%% Code to compute current timestamp.  Some parts by Martin Minow.
%%%
\newcount\hour \newcount\minute
\hour=\time  \divide \hour by 60
\minute=\time
\loop \ifnum \minute > 59 \advance \minute by -60 \repeat
\def\finaltime{\ifnum \hour<13 \number\hour:%
                      \ifnum \minute<10 0\fi
                      \number\minute
                      \ifnum \hour<12 \ am\else \ pm\fi
         \else \advance \hour by -12 \number\hour:%
                      \ifnum \minute<10 0\fi
                      \number\minute \ pm\fi}

\def\finaldate{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\day, \number\year}

\newcount\dow
\newcount\leap
\newcount\x
\newcount\y

%leap = year + (month - 14)/12
\leap=\month \advance\leap by -14 \divide\leap by 12
  \advance\leap by \year

%dow = (13 * (month + 10 - (month + 10)/13*12) - 1)/5
\dow=\month \advance\dow by 10
  \y=\dow \divide\y by 13 \multiply\y by 12
  \advance\dow by -\y \multiply\dow by 13 \advance\dow by -1 \divide\dow by 5

%dow += day + 77 + 5 * (leap % 100)/4
\advance\dow by \day \advance\dow by 77
  \x=\leap \y=\x \divide\y by 100 \multiply\y by 100 \advance\x by -\y
  \multiply\x by 5 \divide\x by 4 \advance\dow by \x

%dow += leap / 400
\x=\leap \divide\x by 400 \advance\dow by \x

%dow -= leap / 100 * 2;
%dow = (dow % 7)
\x=\leap \divide\x by 100 \multiply\x by 2 \advance\dow by -\x
  \x=\dow \divide\x by 7 \multiply\x by 7 \advance\dow by -\x

\def\finaldayofweek{\ifcase\dow
Sunday\or Monday\or Tuesday\or
Wednesday\or Thursday\or Friday\or Saturday\fi}

\def\timestamp{\finaltime, \finaldayofweek, \finaldate}
