
hekeus@51: \NeedsTeXFormat{LaTeX2e}[1995/12/01]
hekeus@51: \ProvidesPackage{tools}[2007/12/25 v1.1 Samer's general LaTeX tools]
hekeus@51: \DeclareOption{detbar}{\def\detbar{y}}
hekeus@51: \DeclareOption{innerparen}{\def\inneropt{paren}}
hekeus@51: \DeclareOption{innerdot}{\def\inneropt{dot}}
hekeus@51: \DeclareOption{innermat}{\def\inneropt{mat}}
hekeus@51: \DeclareOption{nodesc}{\def\nodesc{y}}
hekeus@51: \ExecuteOptions{innerparen}
hekeus@51: \ProcessOptions
hekeus@51: 
hekeus@51: \providecommand{\comment}[1] {}
hekeus@51: \usepackage{xspace,units,array,amsmath,graphicx}
hekeus@51: \ifx\ifpdf\undefined
hekeus@51: 	\usepackage{ifpdf}
hekeus@51: \fi
hekeus@51: \ifpdf
hekeus@51: 	\usepackage{epstopdf}
hekeus@51: \else
hekeus@51: \fi
hekeus@51: 
hekeus@51: % PSTricks things
hekeus@51: %\usepackage{pstcol,pstricks,pst-node,pst-plot}
hekeus@51: %\psset{linewidth=0.4pt,labelsep=3pt,dotsize=1.2mm,%
hekeus@51: %	arrowsize=2pt 2.5,arrowlength=1,arrowinset=0.2,%
hekeus@51: %	gridwidth=0.4pt,griddots=10,subgriddiv=1,gridlabels=7pt,gridcolor=gray}
hekeus@51: 
hekeus@51: \let\oldS=\S
hekeus@51: \newcommand{\sect}[1]	{$\oldS\,#1$}
hekeus@51: \newcommand{\shim}[2]	{\hspace{#1mm plus #2mm}}
hekeus@51: \newcommand{\ie}			{i.e.\@\xspace}
hekeus@51: \newcommand{\vrs}		{vs.\@\xspace}
hekeus@51: \newcommand{\eg}			{e.g.\@\xspace}
hekeus@51: \newcommand{\etc}		{etc.\@\xspace}
hekeus@51: \newcommand{\latin}[1]	{\emph{#1}\xspace}
hekeus@51: \newcommand{\figrf}[1]	{fig.~\ref{f:#1}}
hekeus@51: \newcommand{\Figrf}[1]	{Fig.~\ref{f:#1}}
hekeus@51: %\newcommand{\eqrf}[1]	{eq.~\ref{eq:#1}}
hekeus@51: \newcommand{\eqrf}[1]	{(\ref{eq:#1})}
hekeus@51: \newcommand{\secrf}[1]	{\sect{\ref{s:#1}}}
hekeus@51: \newcommand{\chaprf}[1]	{Chapter~\ref{ch:#1}}
hekeus@51: \newcommand{\ed}[1]		{\texttt{[#1]}}
hekeus@51: \newcommand{\role}		{role\xspace}%{r\^{o}le\xspace}
hekeus@51: \newcommand{\naive}		{naive\xspace}
hekeus@51: \newcommand{\german}[1]	{\emph{#1}}
hekeus@51: \newcommand{\degr}[1]	{$#1^\circ$}
hekeus@51: %\newcommand{\nth}[1]		{$#1$\hskip 0.1ex th\xspace}
hekeus@51: \newcommand{\nth}[1]		{$#1$\hspace*{0.2ex}\raisebox{0.35em}{\scriptsize th}\xspace}
hekeus@51: \newcommand{\textnth}[1]{#1\hskip 0.2ex \raisebox{0.35em}{\scriptsize th}\xspace}
hekeus@51: \newcommand{\const}{\text{const.}}
hekeus@51: \newcommand{\D}[1] {$#1$-D\xspace}
hekeus@51: \newcommand{\sh} {$\sharp$}
hekeus@51: \newcommand{\fl} {$\flat$}
hekeus@51: \newcommand{\Hmax}{H_\mathrm{max}}
hekeus@51: \newcommand{\Imax}{I_\mathrm{max}}
hekeus@51: 
hekeus@51: % centred dot with space either side for separating things
hekeus@51: %\def\nicedot{\hspace{0.7em}\textperiodcentered\hspace{0.7em}}
hekeus@51: \newlength\nicedotspace
hekeus@51: \setlength\nicedotspace{0.6em plus 0.1em minus 0.2em}
hekeus@51: \def\nicedot{\hspace{\nicedotspace}\textperiodcentered\hspace{\nicedotspace}}
hekeus@51: 
hekeus@51: %\newcommand{\margnote}[1]	{\marginpar{\raggedright\itshape\small#1}}
hekeus@51: 
hekeus@51: % names
hekeus@51: \newcommand{\Hyvarinen}{Hyv\"arinen\xspace}
hekeus@51: \newcommand{\Kohler}{K\"ohler\xspace}
hekeus@51: \newcommand{\Pragnanz}{Pr\"{a}gnanz\xspace}
hekeus@51: 
hekeus@51: % environments
hekeus@51: \ifx\nodesc\undefined
hekeus@51: 	\renewenvironment{description}
hekeus@51: 		{\begin{list}{}{%
hekeus@51: 			\setlength{\labelwidth}{1.5em}
hekeus@51: 			\setlength{\leftmargin}{1.5em}
hekeus@51: 			\let\makelabel\descriptionlabel
hekeus@51: 		}}
hekeus@51: 		{\end{list}}
hekeus@51: \fi
hekeus@51: 
hekeus@51: \newenvironment{smallquote}
hekeus@51: 	{ \begin{quote}	\small}
hekeus@51: 	{ \end{quote}}
hekeus@51: 
hekeus@51: \providecommand{\figplacement}{tbp}
hekeus@51: \newenvironment{fig}[2][\figplacement]
hekeus@51: 	{%
hekeus@51: 		\newcommand{\bbfig}[1]{\begin{figure}[##1]}
hekeus@51: 		\expandafter\bbfig\expandafter{#1}
hekeus@51: 		\def\fglbl{f:#2}
hekeus@51: 		\let\ocap=\caption
hekeus@51: 		\renewcommand{\caption}[2][]{\ocap[##1]{\small ##2}}
hekeus@51: 		\centering\small
hekeus@51: 	}{%
hekeus@51: 		\label{\fglbl}
hekeus@51: 		\end{figure}
hekeus@51: 	}
hekeus@51: 
hekeus@51: \newenvironment{fig*}[2][\figplacement]
hekeus@51: 	{%
hekeus@51: 		\newcommand{\bbfig}[1]{\begin{figure*}[##1]}
hekeus@51: 		\expandafter\bbfig\expandafter{#1}
hekeus@51: 		\def\figlabel{f:#2}
hekeus@51: 		\let\ocap=\caption
hekeus@51: 		\renewcommand{\caption}[2][]{\ocap[##1]{\small ##2}}
hekeus@51: 		\centering\small
hekeus@51: 	}{%
hekeus@51: 		\label{\figlabel}
hekeus@51: 		\end{figure*}
hekeus@51: 	}
hekeus@51: 
hekeus@51: \newenvironment{eq}[1]
hekeus@51: 	{\begin{equation}\def\eqlabel{eq:#1}}
hekeus@51: 	{\label{\eqlabel}\end{equation}}%
hekeus@51: 
hekeus@51: 
hekeus@51: 
hekeus@51: 
hekeus@51: % ------------- standard mathematics -----------------
hekeus@51: 
hekeus@51: % --- calculus
hekeus@51: \let\oldint\int 		\def\int#1\dd{\oldint#1\;\dd}
hekeus@51: \let\oldiint\iint		\def\iint#1\dd#2\dd{\oldiint#1\;\dd#2\;\dd}
hekeus@51: \let\oldiiint\iiint	\def\iiint#1\dd#2\dd#3\dd{\oldiiint#1\;\dd#2\;\dd#3\;\dd}
hekeus@51: \newcommand{\infint}[2] 		{\int_{-\infty}^\infty#2\dd#1}
hekeus@51: \newcommand{\partiald}[2]		{\frac{\partial#1}{\partial#2}}
hekeus@51: \newcommand{\pd}[2]			{\dfrac{\partial#1}{\partial#2}}
hekeus@51: \newcommand{\dd}				{\mathrm{d}}
hekeus@51: \newcommand{\hdbyd}[2][]	{\dd{#1}/\dd{#2}}
hekeus@51: \newcommand{\dbyd}[2][]		{\frac{\dd#1}{\dd#2}}
hekeus@51: \newcommand{\dbydt}[1]		{\frac{\dd#1}{\dd t}}
hekeus@51: \newcommand{\hpd}[2]		{{\partial#1}/{\partial#2}}
hekeus@51: \newcommand{\grad}			{\boldsymbol{\nabla}}
hekeus@51: \newcommand{\hfrac}[2] {#1/#2}
hekeus@51: \newcommand{\hpfrac}[2] {(#1/#2)}
hekeus@51: 
hekeus@51: % --- statistics
hekeus@51: \newcommand{\savg}[2][] {%
hekeus@51: 	\def\sub{#1} % optional subscript
hekeus@51: 	\ifx\sub\empty	{\langle #2 \rangle}
hekeus@51: 	\else 			{\langle #2 \rangle}_{#1}
hekeus@51: 	\fi}
hekeus@51: 	
hekeus@51: \newcommand{\avg}[2][] {%
hekeus@51: 	\def\sub{#1} % optional subscript
hekeus@51: 	\ifx\sub\empty	{\left\langle #2 \right\rangle}
hekeus@51: 	\else 			{\left\langle #2 \right\rangle}_{#1}
hekeus@51: 	\fi}
hekeus@51: 	
hekeus@51: \newcommand{\expect}[2][]	{%
hekeus@51: 	\def\sub{#1} % optional subscript
hekeus@51: 	\ifx\sub\empty	\operatorname{E} \, #2
hekeus@51: 	\else 			\operatorname{E}_{#1}  #2
hekeus@51: 	\fi
hekeus@51: }
hekeus@51: \newcommand{\sqbr}[1]	{[\,#1]}
hekeus@51: \newcommand{\var}[1]		{\operatorname{var}\, #1}
hekeus@51: \newcommand{\cov}[2]		{\operatorname{cov}[#1,#2]}
hekeus@51: \newcommand{\cc}[2]		{\operatorname{corr}[#1,#2]}
hekeus@51: %\newcommand{\KL}[2] 		{\mathrm{KL}[\, #1 \|\, #2]}
hekeus@51: \newcommand{\KL}[2] 		{D(#1 \|\, #2)}
hekeus@51: \newcommand{\define}		{\overset{\text{\tiny def}}{=}}
hekeus@51: \newcommand{\distr}     {\sim}
hekeus@51: 
hekeus@51: % --- sets
hekeus@51: \newcommand{\union}		{\cup}
hekeus@51: \newcommand{\diff}		{\backslash}
hekeus@51: \newcommand{\intersect}	{\cap}
hekeus@51: \newcommand{\integers} 	{\mathbb{Z}}
hekeus@51: \newcommand{\reals} 		{\mathbb{R}}
hekeus@51: \newcommand{\complexes}	{\mathbb{C}}
hekeus@51: %\newcommand{\C} 			{\mathbb{C}}
hekeus@51: \newcommand{\naturals} 	{\mathbb{N}}
hekeus@51: %\renewcommand*{\emptyset}	{\varnothing}
hekeus@51: 
hekeus@51: % --- misc
hekeus@51: \def\rowvec(#1,#2){\begin{pmatrix} #1 & #2 \end{pmatrix}}
hekeus@51: \def\colvec(#1,#2){\begin{pmatrix} #1 \\ #2 \end{pmatrix}}
hekeus@51: 
hekeus@51: \ifx\detbar\undefined\else\def\det#1{|#1|}\fi
hekeus@51: 
hekeus@51: \newcommand{\sqtp}{\sqrt{2 \pi}}
hekeus@51: \DeclareMathOperator{\sech}{sech}
hekeus@51: \DeclareMathOperator{\sgn} {sgn}
hekeus@51: \DeclareMathOperator{\trace} {tr}
hekeus@51: \newcommand{\repart}{\Re\,}
hekeus@51: \newcommand{\impart}{\Im\,}
hekeus@51: \newcommand{\assign}	{\leftarrow}
hekeus@51: \newcommand*\half			{\tfrac{1}{2}}
hekeus@51: \newcommand{\fun}[1] 		{$#1(\cdot)$\xspace}
hekeus@51: \newcommand{\ffun}[1] 		{$#1(\cdot,\cdot)$\xspace}
hekeus@51: \newcommand{\tends}			{\rightarrow}
hekeus@51: \renewcommand*{\vec}[1]		{\mathbf{#1}}
hekeus@51: \providecommand{\abs}[1]		{\lvert#1\rvert}
hekeus@51: \providecommand{\norm}[1]	{\lVert#1\rVert}
hekeus@51: \if\inneropt{paren}
hekeus@51: 	\newcommand{\inner}[2]		{(#1,#2)}
hekeus@51: \fi
hekeus@51: \if\inneropt{dot}
hekeus@51: 	\newcommand{\inner}[2]		{#1\cdot#2}
hekeus@51: \else
hekeus@51: 	\newcommand{\inner}[2]		{{#1}^T#2}
hekeus@51: \fi
hekeus@51: 	
hekeus@51: % --- psfig bits
hekeus@51: \newcommand{\psmath}[2]	{\psfrag{#1}{\scriptsize $#2$}}
hekeus@51: \newcommand{\psmathbig}[2]	{\psfrag{#1}{\small $#2$}}
hekeus@51: 
hekeus@51: 
hekeus@51: % \linespread{1.1}
hekeus@51: 
hekeus@51: 
hekeus@51: % top-aligned boxes
hekeus@51: \newbox\thehbox
hekeus@51: \newcommand{\hangbox}[1]{%
hekeus@51: 	\savebox{\thehbox}{#1}%
hekeus@51: 	\raisebox{-\ht\thehbox}[0pt][\ht\thehbox]{\usebox{\thehbox}}%
hekeus@51: 	%  \raisebox{-\ht\thehbox}[0pt][-\ht\thehbox]{\usebox{\thehbox}}%
hekeus@51: }
hekeus@51: 		
hekeus@51: \newenvironment{hanging}{%
hekeus@51: 	\begingroup
hekeus@51: 	\newbox\thebox
hekeus@51: 	\begin{lrbox}{\thebox}
hekeus@51: }{%
hekeus@51: 	\end{lrbox}%
hekeus@51: 	\raisebox{-\ht\thebox}[0pt][\ht\thebox]{\usebox{\thebox}}%
hekeus@51: 	\endgroup
hekeus@51: }%
hekeus@51: 
hekeus@51: % Hacky indentation - FIXME!
hekeus@51: \newenvironment{indented}
hekeus@51: 	{\vspace{-0.6em}\begin{quote}}
hekeus@51: 	{\end{quote}\vspace{-0.6em}}
hekeus@51: 




