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