%---------------------------------------------------------------------------
% Time-stamp: <2016-03-12 12:05:08 sutner> 
%
% :File:	ksassgn.sty
% :Purpose:	exam wrapper class for article
%
%---------------------------------------------------------------------------

%---------------------------------------------------------------------------
% identification

\def\fileversion{0.9}
\def\filedate{2010/09/01}
\NeedsTeXFormat{LaTeX2e}

\ProvidesClass{ksassgn}%
[\filedate\space v\fileversion]


%---------------------------------------------------------------------------
% initial code


\def\coursename{CDM}
\def\filedate{XXXXXX/2003}         % CHANGE
\def\assgnum{XXXX}                 % CHANGE

\def\arrstr{1.5}

\newlength{\stwidth}
\setlength{\stwidth}{15mm}


%---------------------------------------------------------------------------
% options declarations

\DeclareOption{draft}{\setlength\overfullrule{5pt}}
\DeclareOption{final}{\setlength\overfullrule{0pt}}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

%---------------------------------------------------------------------------
% options execution

\ExecuteOptions{final}

\InputIfFileExists{ksassgn.cfg}{}{}

\ProcessOptions

%---------------------------------------------------------------------------
% package loading

\LoadClass{article}

\RequirePackage{kstexmacs}
\RequirePackage{logic}
\RequirePackage{fancyhdr}
\RequirePackage{amsmath}
\RequirePackage{amsfonts}
\RequirePackage{amssymb}
\RequirePackage{multido}
\RequirePackage{array}
\RequirePackage{url}
\RequirePackage{fancyvrb}
\RequirePackage{ifthen}
\RequirePackage{graphicx}
\RequirePackage{lastpage}
\RequirePackage{geometry}
\geometry{margin=18mm,top=25mm}
\RequirePackage{comment}
\RequirePackage{mathtools}
\RequirePackage{titlesec}
\RequirePackage{needspace}
\RequirePackage[dvipsnames]{xcolor}
\RequirePackage{multiaudience}

%---------------------------------------------------------------------------
% main code

\lhead[{\bfseries \coursename\quad HW \assgnum}]%
{{\bfseries \coursename\quad HW \assgnum}}
\chead[]{}
\rhead[{\bfseries\thepage\ of \pageref{LastPage}}]%
{{\bfseries\thepage\ of \pageref{LastPage}}}
\lfoot[]{}
\cfoot[]{}
\rfoot[]{}

\pagestyle{fancy}

%---------------------------------------------------------------------------

\newenvironment{Enumerate}%
{\renewcommand{\theenumi}{\Alph{enumi}}\begin{enumerate}}%
{\end{enumerate}}


\def\tblu#1{\textcolor{Blue!90!Black}{#1}}

\let\emph=\tblu


% \AtBeginDocument{}

\graphicspath{%
{/home/sutner/class/CDM/Pictures/}%
{/home/sutner/projects/Discrete/pics/auto/}%
{/home/sutner/projects/Discrete/pics/ca/}%
{/home/sutner/projects/Discrete/pics/disc/}%
{/home/sutner/projects/Discrete/pics/people/}%
{/home/sutner/projects/Discrete/pics/stuff/}%
{/home/sutner/projects/Discrete/standalone/}%
{/home/sutner/Docs/Images/}%
{./}}


\parindent=0pt
\parskip=1ex

% \newcounter{tscore}
% \newcounter{questnum}

% \newcommand{\titledquestion}[2]{
% \stepcounter{questnum} 
% \addtocounter{tscore}{#2}
% \bigskip\bigskip
% {\large\bf Problem \thequestnum:}\hspace{1ex}{\bfseries {#1}}%
% {\normalsize\hspace{1ex}({#2} pts.)\relax}}

% \newcommand{\Background}[0]{
% \medskip
% {\bf Background}
% \smallskip}

% \newcommand{\Task}[0]{
% \medskip
% {\bf Task}
% \smallskip}

% \newcommand{\Comment}[0]{
% \medskip
% {\bf Comment}\quad}

% \newcommand{\Solution}[1]{
% \setcounter{subsolcnt}{1}
% \bigskip \bigskip
% {\large \emph{Solution: {#1}}}}

% \newcounter{subsolcnt}
% \renewcommand{\thesubsolcnt}{\Alph{subsolcnt}}

% \newcommand{\subSolution}[1]{
% \medskip

% {\textbf{Part \thesubsolcnt: }}{#1}
% \stepcounter{subsolcnt}}

% \newenvironment{solution}{}{}


% \newcommand{\PICTURE}[4]{\vspace{#1}

% \hspace*{#2}
% \includegraphics[scale={#4}]{{#3}}}

\newcounter{tscore}
\newcounter{questioncnt}


\titleformat{\section}
{\vspace{1ex}\titlerule[1pt]
\vspace{.8ex}%
\Large\bfseries}
{\thesection}{.5em}{}


% \newenvironment{question}[2]
% {\refstepcounter{questioncnt}\section{{#1}}}{}


%---------------------------------------------------------------------------
%
%  control printing of problems/solutions
%
%  requires cleanup
%

\SetNewAudience{questions}
\SetNewAudience{solutions}

%
%  paras:  problem title,  point score
%
\newenvironment{question}[2]
{\stepcounter{questioncnt}\addtocounter{tscore}{#2}%
\par\noindent \section{{#1} \textnormal{(#2)}}}%
{}

\NewMultiaudienceSectionEnv{Question}{\question}


\newenvironment{thesolution}[0]
{\setcounter{subsolcnt}{1}%
\par\noindent \makebox[\textwidth]{\dotfill} \\[1ex]}%
{}

\NewMultiaudienceSectionEnv{solution}{\thesolution}


% \par\noindent \rule{\textwidth}{1pt} \vspace*{-2mm} \section{{#1 (#2)}}}


% \def\titledquestion#1#2{\bigskip \hrule \medskip\section{#1}}

\newcommand{\Background}[0]{\needspace{10mm}
\smallskip
\textbf{Background}}

\newcommand{\Task}[0]{\needspace{10mm}
\smallskip
\textbf{Task}}

\newcommand{\Comment}[0]{\needspace{10mm}
\smallskip
\textbf{Comment}\quad}

%
%  using package comment
%  
% \specialcomment{solution}
% {\begingroup\setcounter{subsolcnt}{1}%
% \par\noindent \makebox[\textwidth]{\dotfill} \\[1ex]}{\endgroup}

%
% using package multiaudience
%
\newcounter{subsolcnt}
% \NewMultiaudienceSectionEnv{solution}{\section}
% {\setcounter{subsolcnt}{1}%
% \par\noindent \makebox[\textwidth]{\dotfill} \\[1ex]}%
% {}

\newcommand{\Solution}[1]{\textbf{Solution: {#1}}}

% \newcommand{\Solution}[1]{
% \setcounter{subsolcnt}{1}
% \bigskip \makebox[\textwidth]{\dotfill} \medskip
% \textbf{Solution:}{#1}}

% \newcounter{subsolcnt}
\renewcommand{\thesubsolcnt}{\Alph{subsolcnt}}

\newcommand{\subSolution}[1]{
\medskip

\textbf{Part \thesubsolcnt: }{#1}
\stepcounter{subsolcnt}}



%---------------------------------------------------------------------------


\AtEndDocument{
\typeout{}
\typeout{****  Questions: \thequestioncnt}
\typeout{****  Score: \thetscore}
\typeout{}}


%---------------------------------------------------------------------------
\endinput
%---------------------------------------------------------------------------
% eof
