% macros for Stat 241 in fall 2014

\immediate\write16{^^JLOADING 241-fall2014.sty^^J} 
\input dbp-book.sty
\input dbp-hyperref.sty

\GiveChapNumber{Prob}
\GiveChapNumber{Expect}
\GiveChapNumber{Binomial}
%\GiveChapNumber{Symmetry}
\GiveChapNumber{Variance}
\GiveChapNumber{BinNormal}
\GiveChapNumber{Continuous}
\GiveChapNumber{CtsCondition}
\GiveChapNumber{CLT}
\GiveChapNumber{Poisson}
\GiveChapNumber{PoissonProc}
\GiveChapNumber{JointDensity}
\GiveChapNumber{ConditDensity}
\GiveChapNumber{MultiNormal}
\GiveChapNumber{MGF}




\def\bookNAME{Stat241/541}
\def\coursename{Statistics 241/541 fall 2014}
\def\path{.}
\def\INPUT#1{\input\path/#1}

\def\inpuT#1{\input #1}
% \def\inpuT#1{{\smc input #1\smallskip}} 

\def\INCLUDE#1{%
	\def\path{#1}%
	\input \path/chapter.tex
	\IfFileExists{\path/#1.bbl}{\input \path/#1.bbl}
	{% if missing
		\immediate\write16{^^J\path/#1.bbl not found^^J}
}}

\def\runninghead{} % will be set by Chapter
\reversemarginpar
%\oddsidemargin = 1.9in
\oddsidemargin = 1.4in
\setlength{\marginparwidth}{1.5in}

%\fancypagestyle{handout}{%
%	\normaltrue
%	\fancyhf{} % clear all header and footer fields
%%	\fancyhead[L]{%
%%		\coursename
%%		\ifnormal\thesection\quad\fi
%%		\normalsize\scshape\SectionName
%%	}%
%	\fancyhead[R]{\thepage}
%%	\fancyhead[LE]{\thepage}
%	%\fancyhead[RE]{\scshape \normalsize\ChapterName}
%%	\fancyfoot{}
%	\fancyfoot[L]{\today}
%	\fancyfoot[R]{\coursename}
%%	\renewcommand{\headrulewidth}{0.5pt}
%%	\renewcommand{\footrulewidth}{0pt}%
%	\renewcommand{\headrulewidth}{0pt}
%	\renewcommand{\footrulewidth}{0.5pt}%
%}
%
%\long\def\READ#1#2{%
%\goodbreak
%\bgroup
%\setlength{\theorempreskipamount}{4pt}%
%\setlength{\theorempostskipamount}{2pt}%
%\color{Purple4}%
%\bigskip\hrule width\textwidth
%\vskip5pt\noindent
%{\bf Example~\cref{#1}\quad}
%%\begin{example}%\label{#1}%
%\rm #2
%\vskip5pt
%\hrule width\textwidth
%%\end{example}%
%\egroup
%\bigskip
%}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	Colored elements
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\def\bExample#1{\bigskip\subheading{Example~\ref{#1}}}
%\def\eExample{\QED\goodbreak}
%\def\bExample#1{\begin{example}\label{#1}}

\def\newdef#1{\textcolor{blue}{\itshape\bfseries#1}}

%\def\bDefn{\vskip-\lastskip\textcolor{DarkOrchid3}\bgroup\begin{Defn}}
\def\bDefn{\vskip-\lastskip\textcolor{DarkOrchid3}\bgroup\begin{Defn}}
\def\eDefn{\end{Defn}\egroup}

\def\bExample#1#2{%
	\begin{example}%
	\label{#1}%
	\phantomsection
	\addcontentsline{toc}{subsection}{#2}

	}
\def\eExample{\QED\end{example}}

\def\Important{\bgroup\color{blue}}
\def\endImportant{\egroup}

%\def\Rules#1{ \bgroup\color{blue}\subheading{#1} }
\def\Rules#1{ \bgroup\color{DarkOrchid3}\subheading{#1} }
\def\endRules{\egroup\smallskip}

\def\Remark{\vskip-\lastskip
%\bgroup\color{DarkGoldenrod4}\begin{remark}\rightskip=3em plus2em minus2pt}
\bgroup%\color{Purple4}
\begin{remark}\rightskip=3em plus2em minus2pt}
\def\endRemark{\end{remark}\egroup}

\long\def\READ#1#2{%
\goodbreak
\bgroup
\setlength{\theorempreskipamount}{4pt}%
\setlength{\theorempostskipamount}{2pt}%
%\color{Purple4}%
\color{DarkOrchid3}%
\bigskip\hrule width\textwidth
\vskip5pt\noindent
{\bf Example~\cref{#1}\quad}
%\begin{example}%\label{#1}%
\rm #2
\vskip5pt
\hrule width\textwidth
\goodbreak
%\end{example}%
\egroup
\bigskip
}


\def\Surd#1#2{\overline{#1}\mkern-1.1mu\raise1.9pt\hbox{$\backslash$}\raise4pt\hbox{$\scriptstyle#2$}}

\def\Bin{\text{Bin}}
\def\Pois{\text{Poisson}}
\def\geometric{\text{geometric}}
\def\Unif{\text{Uniform}}
\def\MID{\ensuremath{\,\mid\,}}
\def\INFO{\text{info}}
\def\AND/{\qt{and}\qquad}
\def\bx{\mathbf x}

\def\TeX{T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emX}

\def\ybar{\overline y}
\def\Ybar{\overline Y}

\def\intreal{\int_{-\infty}^{+\infty}}

%\def\Prob[#1|#2]{\PP\(\text{#1} \mid\text{#2}\)}
\def\Prob(#1|#2){\PP\left(\text{#1} \mid\text{#2}\right)}
\def\probtext[#1]{\PP\{\text{#1}\}}
\def\PPtext[#1]{\PP\{\text{#1}\}}

\def\EEtext[#1]{\EE\{\text{#1}\}}
\def\Expect(#1|#2){\EE\left(\text{#1} \mid\text{#2}\right)}


\theoremstyle{DBPrem}
%\theoremindent2em
\theoremseparator{.}
\theoremheaderfont{\normalfont\bfseries}
%\theorembodyfont{\small}
\newtheorem{Defn}{Definition}


\def\mnote#1{\marginpar{\small\itshape #1}}

\def\bullitem{\item[$\bullet$]}
\def\qed{\ifmmode\square\else$\square$\fi}
\def\QED{\ifmmode\hfill{\square}\else\hfill{$\square$}\fi}

\def\corr#1#2{\text{corr}(#1,#2)}
\def\sd{\text{sd}}




\def\state#1{\kern2pt\fbox{#1}\kern2pt}
\def\state#1{\kern2pt\fbox{#1}\hskip3pt plus 1pt minus 0.5pt}
\def\state#1{\fbox{\small#1}}
\def\blab#1{\state{\tiny#1}}
\def\PMwins{P_{\hbox{\small M wins}}}
\def\PRwins{P_{\hbox{\small R wins}}}
\def\One{{\mathbb I}}

\def\Bullet{\llap{$\bullet$\quad}}
\newcommand{\rowstars}{%
\begin{center}
$*************$
\end{center}
}
%\def\HW#1#2{%
%\pagestyle{HW}%
%%\setlength{\marginparwidth}{0.5in}%
%\oddsidemargin = 1in
%\begin{flushleft}%
%\normalsize\textbf
%\coursename\newline
%Homework \# #1\newline
%Due: #2
%\end{flushleft}\small
%}

%\newenvironment{nohide}{}{}
%\let\nohide=\comment
%\newenvironment{nohide}{\bgroup\normalfont}{\egroup}
%\newenvironment{nohide}[0]{\vskip-\lastskip\smallskip\indent\color{black}\normalfont}{\vskip-\lastskip\smallskip}
%\newenvironment{nohide}[0]{\vskip-\lastskip\smallskip\indent\color{black}\normalfont}{\vskip-\lastskip\bigskip}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	Homework
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\fancypagestyle{HW}{%
	\fancyhf{} % clear all header and footer fields
	\renewcommand{\headrulewidth}{0pt}%
	\renewcommand{\footrulewidth}{0pt}%
}

\def\HW#1#2{%
\let\soln=\comment
\pagestyle{HW}%
\gdef\StateProb{\relax}
\gdef\endStateProb{\relax}
%\setlength{\marginparwidth}{0.5in}%
\oddsidemargin = 1in
\begin{flushleft}%
\normalsize\textbf
\coursename\newline
Homework \# #1\newline
Due: #2
\end{flushleft}\small
}

\def\StartSolutionSheet#1#2{%
\let\soln=\nohide
\pagestyle{HW}%
%\setlength{\marginparwidth}{0.5in}%
\oddsidemargin = 1in
\begin{flushleft}%
\normalsize\textbf
\coursename\newline
\bf2011: Solutions to sheet #1  \hfil
\end{flushleft}
%\small
%%\line{\bf Statistics 241/541 \hfil}
%\line{\bf2011: Solutions to sheet #1  \hfil}
\bigskip
\color{DarkOrchid3}\it
}	

\long\def\StateProb{\bgroup\color{DarkOrchid3}\it\small\noindent}
%\def\endStateProb{\smallskip\egroup\par}
\def\endStateProb{\vskip-\lastskip\smallskip\egroup\par}

\let\solveHW=\StartSolutionSheet

\def\bQuote{\begin{quotation}\noindent\itshape}
\def\eQuote{\end{quotation}}



\def\Heading{\begin{center}\scshape\large}
\def\endHeading{\end{center}}
\let\heading=\Heading
\let\endheading=\endHeading

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	Changes of book style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter

\def\Chapter#1#2{%  
%\ifDRAFT
%\thispagestyle{startchap}%
%\fi
	\setcounter{ProbNum}{0}% added7aug14
	\gdef\ChapTitle/{Chapter}%
	\gdef\ChapAbbrev/{Chap}%
	\global\tok@Chap={#1::}% added :: 21 april 2014
	\gdef\runninghead{#2}%   % added15 Aug 2011 for 241
%	\@Chapter{#1}{#2}%
	\gdef\ChapterNumber{\csname \ChapAbbrev/#1\endcsname}%
	\gdef\ChapterName{#2}%
  	\setcounter{chapter}{\ChapterNumber}% for Latex numbering of sections
  	\advance\c@chapter\m@ne
	\chapter{#2}%
%\ifDRAFT
\pagestyle{classnotes}
\thispagestyle{startClass}%
%\fi
}




\fancypagestyle{classnotes}{%
	\normaltrue
	\fancyhf{} % clear all header and footer fields
	\fancyhead[LO]{%
		\ChapterNumber. \runninghead
%		\ifnormal\S\ChapterNumber.\thesection\quad\fi
%		\ifnormal\S\thesection\quad\fi
%		\normalsize\scshape\SectionName
	}%
	\fancyhead[RO]{\thepage}
	\fancyhead[LE]{\thepage}
	\fancyhead[RE]{\scshape \normalsize\ChapterName}
	\fancyfoot[L]{{\setlength{\fboxsep}{1.5mm}	
		\fbox{\itshape\coursename \ \copyright David Pollard, \version}%
	}}
	\renewcommand{\headrulewidth}{0.5pt}
	\renewcommand{\footrulewidth}{0pt}%
}

\fancypagestyle{startClass}{%
	\fancyhf{} % clear all header and footer fields
	\fancyfoot[L]{%
		\vtop to0pt{%
			\small\itshape 
			version: \version\\
			printed: \today%
			\vss
		}}
	%\fancyfoot[C]{\thepage}
	\fancyfoot[L]{{\setlength{\fboxsep}{1.5mm}	
		\fbox{\itshape\coursename \ \copyright David Pollard, \version}%
	}}
	\fancyfoot[R]{\thepage}%
%		\vtop to0pt{%
%			\small\itshape 
%			\bookNAME\\%
%			\copyright \AUTHOR%
%			\vss 
%		}}%
	\renewcommand{\headrulewidth}{0pt}
	\renewcommand{\footrulewidth}{0pt}%
}


\makeatother
