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