%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% miscellaneous macros, fonts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\newcommand\xbar{\overline x}


\makeatletter

\newif\ifshowlabels	% added 11 sep 2012
\def\showlabels{%
	\showlabelstrue	% added 11 sep 2012
	\usepackage[notcite,notref,color]{showkeys}%
	\definecolor{labelkey}{cmyk}{0.25,0.2,1,0}%
	\renewcommand\showkeyslabelformat[1]{%
	\fbox{\normalfont\footnotesize\ttfamily##1}%
	}%

	\hoffset.8in
	\reversemarginpar%	6 jan 2013

	\setlength{\marginparwidth}{1.5in}%
	\setlength{\marginparsep}{.8in}%
}

%\newcommand{\cid}{\rightsquigarrow}
\def\cid{\rightsquigarrow}
%\newcommand{\cidfidi}{\underset{fidi}{\rightsquigarrow}}
%\newcommand{\cidfidi}{\rightsquigarrow_{fidi}}
\def\cidfidi{\rightsquigarrow_{fidi}}

%\def\Framenote#1{\bigskip\framepara\hsize{#1}\bigskip}

\def\Norm#1{\left\Vert#1\right\Vert}
\def\bignorm#1{\left\Vert#1\right\Vert}
\def\norm#1{\left\lVert#1\right\rVert}
%\newcommand{\normT}[1]{\bigl\|#1\bigr\|_T}
\def\psinorm#1{\norm{#1}_\psi}
\def\Psinorm#1{\Norm{#1}_\Psi}
\def\normTV#1{\norm{#1}_{\rm TV}}
\def\normBL#1{\norm{#1}_{\rm BL}}
\def\normLip#1{\norm{#1}_{\rm Lip}}

\def\FrameNote#1{\begin{boxedminipage}{4in}#1\end{boxedminipage}}

\let\citeNP=\citealt
\let\citeN=\citet
%%%\let\Label=\label

%from:  http://en.wikibooks.org/wiki/LaTeX/Mathematics#Roots
% New definition of square root:
% it renames \  as \oldsqrt
\let\oldsqrt\sqrt
% it defines the new \sqrt in terms of the old one
\def\Sqrt{\mathpalette\DHLhksqrt}
\def\DHLhksqrt#1#2{%
\setbox0=\hbox{$#1\oldsqrt{#2\,}$}\dimen0=\ht0
\advance\dimen0-0.2\ht0
\setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
{\box0\lower0.4pt\box2}}

%\newcommand{\DSqrt}[1]{\displaystyle\Sqrt{#1}}
\def\DSqrt#1{\displaystyle\Sqrt{#1}}
%\def\half{1/2}
\def\Pover#1#2{\left(\frac{#1}{#2}\right)}

% Slashed fraction: see Knuth Exercise 11.6
\def\Sfrac#1#2{\kern.1em\raise.5ex\hbox{\the\scriptfont0 #1}\unskip
\kern-.1em/\kern-.15em\lower.25ex\hbox{\the\scriptfont0 #2}}

\def\half{\Sfrac12}
\def\third{\Sfrac13}
\def\quarter{\Sfrac14}
\def\fifth{\Sfrac15}

\def\dbyd#1#2{\frac{\partial#1}{\partial #2}}

\def\text#1{\hbox{\rm#1}}
\def\qt#1{\qquad\text{#1}}
\def\argmin{\mathop{\rm argmin}\limits}
\def\argmin{\mathop{\rm argmin}}
\def\argmax{\mathop{\rm argmax}}

\def\NL{\nolimits}
\def\MAX{\max\nolimits}
\def\ARGMAX{\argmax\nolimits}
\def\MIN{\min\nolimits}
\def\ARGMIN{\argmin\nolimits}
\def\SUP{\sup\nolimits}
\def\CUP{\cup\nolimits}
\def\INF{\inf\nolimits}
\def\LIMSUP{\limsup\nolimits}
\def\LIMINF{\liminf\nolimits}
\def\SUM{\sum\nolimits}
\def\PROD{\prod\nolimits}
\def\BIGCUP{\bigcup\nolimits}
\def\BIGCAP{\bigcap\nolimits}

\def\siln{\sum\NL_{i\le n}}
\def\sumnl{\sum\nolimits}
\def\prodnl{\prod\nolimits}
\def\maxnl{\max\nolimits}
\def\minnl{\min\nolimits}

\def\and/{\qquad\text{\scshape and}\qquad}
\def\AND/{\quad\text{\scshape and}\quad}
\def\cov{\text{cov}}
\def\diag{\text{diag}}
\newcommand{\diam}{\text{diam}}
\newcommand{\rad}{\text{rad}}
\def\osc{\text{\scshape osc}}
\def\ucts{\text{\scshape U\kern-1.5pt C}}
\def\ucts{\text{\scshape u\kern-1.5pt c}}
\newcommand{\co}{\text{co}}	% convex hull
\def\inner#1#2{\langle#1,#2\rangle}


\newcommand{\irootn}{{1/\sqrt{n}}}
\newcommand{\rootn}{{\sqrt{n}}}


\def\trace{\text{trace}}
\def\var{\text{var}}
\def\vol{\text{vol}}
\newcommand{\hamming}{\text{hamm}}
\newcommand{\hamm}{{\mathfrak h}}
\newcommand{\Hamm}{{\mathfrak H}}
\def\bsl{\backslash}

\def\wrt/{with respect to}
\def\Hrule{\bigskip\hrule\bigskip}
\newcommand\Cdot{\,\cdot\,}

\def\Unif{\mathrm{Unif}}
\def\Wolog/{Without loss of generality}
\def\wolog/{without loss of generality} % changed to avoid clash with Latex and BoxedEPS.tex, 
	%BoxedEPS.tex, line 67:  \let\wlog@ld\wlog 
	%BoxedEPS.tex, line 68:  \def\wlog#1{\relax} 
	%BoxedEPS.tex, line 772:  \let\wlog\wlog@ld %%restore logging 

\def\LIST{\showboxdepth=40\showboxbreadth=45\showlists}

\def\today{\number\day \space \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\year}

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

\def\Ber{\textrm{Ber}}
\def\Binom{\text{Bin}}
\def\Poisson{\text{Poisson}}
\def\barPhi{\bar\Phi}   % normal tails
\newcommand{\Psii}{\Psi^{-1}}
\newcommand{\Psitwonorm}[1]{\norm{#1}_{\Psi_2}}

%\def\mnote#1{\marginpar{#1}}
\def\mnote#1{\marginpar{\par\tiny#1}}

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

\def\framemath#1{\setbox0=\hbox{$\displaystyle#1$}\fbox{\box0}}

\let\frameword=\fbox

\def\Heading{\begin{center}\scshape\large}
\def\endHeading{\end{center}}

\def\subheading#1{\par\noindent{\bf #1}\newline}
\def\subheading#1{\par\bigskip\noindent{\bf #1}\newline}
\def\outdentsubheading#1{\par\bigskip\noindent{\kern-2em\bf #1}\newline}
\def\SCsubheading#1{\par\bigskip\noindent{\scshape #1}\newline}
%\renewcommand{\subheading}{\@startsection
%						 {subheading}%     the name
%						 {10}%	the level
%						 {\z@}%	the indent
%                         {-\baselineskip}%	the beforeskip
%                         {0.5\baselineskip}%	the afterskip
%                         {\normalfont\normalsize\bfseries}}%		the style
%

\def\subsubheading#1{\par\noindent{\bf #1}}

\def\bubble#1{\raise8pt\hbox to 0pt{$\mkern6mu\scriptscriptstyle\circ$\hss}#1}
\def\bdot{\bullet}

\def\UGMTP#1{{\small\sc UGMTP~\S#1}}
\def\ugmtp#1{{\small\sc UGMTP~#1}}

\chardef\slashedO="1F
\chardef\slashedo="1C
\chardef\eszet="19

%%%%%%%% blackboard bold
\def\AA{{\mathbb A}}\def\BB{{\mathbb B}}\def\CC{{\mathbb C}}
\def\DD{{\mathbb D}}\def\EE{{\mathbb E}}\def\FF{{\mathbb F}}
\def\GG{{\mathbb G}}\def\HH{{\mathbb H}}\def\II{{\mathbb I}}
\def\JJ{{\mathbb J}}\def\KK{{\mathbb K}}\def\LL{{\mathbb L}}
\def\MM{{\mathbb M}}\def\NN{{\mathbb N}}\def\OO{{\mathbb O}}
\def\PP{{\mathbb P}}\def\QQ{{\mathbb Q}}\def\RR{{\mathbb R}}
\def\SSS{{\mathbb S}}\def\TT{{\mathbb T}}\def\UU{{\mathbb U}}
\def\VV{{\mathbb V}}\def\WW{{\mathbb W}}\def\XX{{\mathbb X}}
\def\YY{{\mathbb Y}}\def\ZZ{{\mathbb Z}}


% Note: hyperref redefines \ss and \ss

\def\NNbar{\overline\NN}
\def\RRbar{\overline\RR}
\def\PPbar{\overline\PP}
\def\barR{{\overline\RR}}
\def\barT{\overline T}
\def\xbar{\overline x}
\newcommand{\pbar}{\overline p}
\newcommand{\wbar}{\overline w}
\newcommand{\Zbar}{\overline Z}
\newcommand{\Lambar}{\overline \Lambda}
\newcommand{\ttheta}{\widetilde \theta}

\newcommand\tf{\widetilde f}
\newcommand\tF{\widetilde F}
%\newcommand\xbar{\overline x}
%\newcommand{\wbar}{\overline w}
%\newcommand{\ttheta}{\widetilde \theta}


%%%%%%%% caligraphic
%\usepackage{eufrak}
\usepackage{euscript}
\let\Cal=\EuScript
\let\muchmore=\gg
\let\muchless=\ll
\let\typewriter=\tt  % for turning on the font
\let\eszett=\ss


\def\aa{{\Cal A}}\def\bb{{\Cal B}}\def\cc{{\Cal C}}\def\dd{{\Cal D}}
\def\ee{{\Cal E}}\def\ff{{\Cal F}}\def\gg{{\Cal G}}\def\hh{{\Cal H}}
\def\ii{{\Cal I}}\def\jj{{\Cal J}}\def\kk{{\Cal K}}\def\ll{{\Cal L}}
\def\mm{{\Cal M}}\def\nn{{\Cal N}}\def\oo{{\Cal O}}\def\pp{{\Cal P}}
\def\qq{{\Cal Q}}\def\rr{{\Cal R}}\def\sss{{\Cal S}}\def\tt{{\Cal T}}
\def\uu{{\Cal U}}\def\vv{{\Cal V}}\def\ww{{\Cal W}}\def\xx{{\Cal X}}
\def\yy{{\Cal Y}}\def\zz{{\Cal Z}}

% note: \ss is redefined by hyperref to the eszet char
%%%%%%%% Greek
\def\a{\alpha}
%\def\b{\beta}  % clashes with hyperref
\def\gam{\gamma}	\def\Gam{\Gamma}
\def\del{\delta}	\def\Del{\Delta}
\def\eps{\epsilon}
\def\k{\kappa}
\def\lam{\lambda}	\def\Lam{\Lambda} \def\Lambdab{\mathbf\Lambda}
\def\om{\omega}		\def\Om{\Omega}
\def\sig{\sigma}
%\def\th{\theta}		% clashes with hyperref
\def\Th{\Theta}

\def\alphab{\boldsymbol\alpha}
\def\betab{\boldsymbol{\beta}}
\def\thetab{\boldsymbol\theta}
\def\lambdab{\boldsymbol\lambda}
\def\mub{\boldsymbol\mu}
\def\pib{\boldsymbol\pi}
\def\sigb{\boldsymbol\sigma}
\def\taub{\boldsymbol\tau}
\def\deltab{\boldsymbol\delta}
\def\Deltab{\boldsymbol\Delta}
\newcommand{\grad}{\nabla}
%%%%	abbreviations

\def\Matrix{\begin{matrix}}
\def\endMatrix{\end{matrix}}

\def\bMatrix{\begin{bmatrix}}
\def\endbMatrix{\end{bmatrix}}

\def\pMatrix{\begin{pmatrix}}
\def\endpMatrix{\end{pmatrix}}


\newcommand{\beq}{\begin{equation}}  % expects a label
\newcommand{\eeq}{\end{equation}}

\newcommand{\beqN}{\begin{equation*}}  %no label, same as $$ .... $$ except for alignment
\newcommand{\eeqN}{\end{equation*}}



\newcommand{\bea}{\begin{eqnarray*}}
\newcommand{\eea}{\end{eqnarray*}}
\newcommand{\bean}{\begin{eqnarray}}
\newcommand{\eean}{\end{eqnarray}}
\newcommand{\bear}{\begin{array}}
\newcommand{\eear}{\end{array}}

%Note:  With \Showlabels the labels must be \Labels
%\def\bAlignL#1\eAlignL{\begin{align}#1\end{align}}  % Labels
\def\bAlign#1\eAlign{\begin{align*}#1\end{align*}}	% no labels

%\def\bAlignL#1\eAlignL{%
%	\let\tagform@=\old@tagform@
%	\begin{align}#1\end{align}%
%	\let\tagform@=\new@tagform@
%	\showmarginlabels    %does nothing if no Showlabels	
%}% end bAlignL

\def\bAlignL#1\eAlignL{\begin{align}#1\end{align}}
%\def\eAlignL{\end{align}}

\def\bxAlignat#1#2\exAlignat{%
	\let\tagform@=\old@tagform@
	\begin{xalignat}{#1}#2\end{xalignat}%
	\let\tagform@=\new@tagform@
	\showmarginlabels   %does nothing if no Showlabels		
}%

\def\NT{\notag\\}  


\newcommand{\STARS}{\begin{center}***\end{center}}
\def\cases@#1{\left\{\,\vcenter{\normalbaselines\m@th
    \ialign{$##$\hfil&\quad##\hfil\crcr#1\crcr}}\right.}

\def\Cases#1\endCases{\let\\=\cr\cases@{#1}}



\def\sc#1{{\scshape#1}}
\renewcommand{\theenumi}{(\roman{enumi})}
\renewcommand{\labelenumi}{(\roman{enumi})}

\let\majm=\mu
\def\hangbdot{\noindent\llap{$\bdot$\quad}}



% 20 April 2016
\newenvironment{little}{\bigskip\bgroup\tiny}{\egroup\bigskip}
%\newcommand{\xlogx}{\psi_{\rm \tiny ent}}

%\def\framemath#1{\fboxsep=0pt\fbox{\vbox{#1}}}
%\def\framemath#1{\vskip2pt\fboxsep=0pt\fbox{\vbox{#1}}}



%\newcommand{\link}{\ell}% might be changed

\makeatother
