samer@14
|
1 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
samer@14
|
2 \ProvidesPackage{tools}[2007/12/25 v1.1 Samer's general LaTeX tools]
|
samer@14
|
3 \DeclareOption{detbar}{\def\detbar{y}}
|
samer@14
|
4 \DeclareOption{underlinevec}{\def\underlinevec{y}}
|
samer@14
|
5 \DeclareOption{innerparen}{\def\inneropt{paren}}
|
samer@14
|
6 \DeclareOption{innerdot}{\def\inneropt{dot}}
|
samer@14
|
7 \DeclareOption{innermat}{\def\inneropt{mat}}
|
samer@14
|
8 \DeclareOption{expectRomanE}{\def\expectopt{RomanE}}
|
samer@14
|
9 \DeclareOption{expectItalicE}{\def\expectopt{ItalicE}}
|
samer@14
|
10 \DeclareOption{expectBBE}{\def\expectopt{BBE}}
|
samer@14
|
11 \DeclareOption{expectangle}{\def\expectopt{angle}}
|
samer@14
|
12 \DeclareOption{nodesc}{\def\nodesc{y}}
|
samer@14
|
13 \ExecuteOptions{innerparen}
|
samer@14
|
14 \ExecuteOptions{expectRomanE}
|
samer@14
|
15 \ProcessOptions
|
samer@14
|
16
|
samer@14
|
17 \providecommand{\comment}[1] {}
|
samer@14
|
18 \usepackage{xspace,array,amsmath,graphicx}
|
samer@14
|
19 %\usepackage{units}
|
samer@14
|
20 \ifx\ifpdf\undefined
|
samer@14
|
21 \usepackage{ifpdf}
|
samer@14
|
22 \fi
|
samer@14
|
23 \ifpdf
|
samer@14
|
24 \usepackage{epstopdf}
|
samer@14
|
25 \else
|
samer@14
|
26 \fi
|
samer@14
|
27
|
samer@14
|
28 % PSTricks things
|
samer@14
|
29 %\usepackage{pstcol,pstricks,pst-node,pst-plot}
|
samer@14
|
30 %\psset{linewidth=0.4pt,labelsep=3pt,dotsize=1.2mm,%
|
samer@14
|
31 % arrowsize=2pt 2.5,arrowlength=1,arrowinset=0.2,%
|
samer@14
|
32 % gridwidth=0.4pt,griddots=10,subgriddiv=1,gridlabels=7pt,gridcolor=gray}
|
samer@14
|
33
|
samer@14
|
34 \let\oldS=\S
|
samer@14
|
35 \newcommand{\sect}[1] {$\oldS\,#1$}
|
samer@14
|
36 \newcommand{\shim}[2] {\hspace{#1mm plus #2mm}}
|
samer@14
|
37 \newcommand{\ie} {i.e.\@\xspace}
|
samer@14
|
38 \newcommand{\vrs} {vs.\@\xspace}
|
samer@14
|
39 \newcommand{\cf} {cf.\@\xspace}
|
samer@14
|
40 \newcommand{\eg} {e.g.\@\xspace}
|
samer@14
|
41 \newcommand{\etc} {etc.\@\xspace}
|
samer@14
|
42 \newcommand{\latin}[1] {\emph{#1}\xspace}
|
samer@14
|
43 \newcommand{\figrf}[1] {fig.~\ref{f:#1}}
|
samer@14
|
44 \newcommand{\Figrf}[1] {Fig.~\ref{f:#1}}
|
samer@14
|
45 %\newcommand{\eqrf}[1] {eq.~\ref{eq:#1}}
|
samer@14
|
46 \newcommand{\eqrf}[1] {(\ref{eq:#1})}
|
samer@14
|
47 \newcommand{\secrf}[1] {\sect{\ref{s:#1}}}
|
samer@14
|
48 \newcommand{\chaprf}[1] {Chapter~\ref{ch:#1}}
|
samer@14
|
49 \newcommand{\ed}[1] {\texttt{[#1]}}
|
samer@14
|
50 \newcommand{\role} {role\xspace}%{r\^{o}le\xspace}
|
samer@14
|
51 \newcommand{\naive} {na{\"i}ve\xspace}
|
samer@14
|
52 \newcommand{\etal} {\latin{et al}}
|
samer@14
|
53 \newcommand{\german}[1] {\emph{#1}}
|
samer@14
|
54 \newcommand{\degr}[1] {$#1^\circ$}
|
samer@14
|
55 %\newcommand{\nth}[1] {$#1$\hskip 0.1ex th\xspace}
|
samer@14
|
56 \newcommand{\nth}[1] {$#1$\hspace*{0.2ex}\raisebox{0.35em}{\scriptsize th}\xspace}
|
samer@14
|
57 \newcommand{\textnth}[1]{#1\hskip 0.2ex \raisebox{0.35em}{\scriptsize th}\xspace}
|
samer@14
|
58 \newcommand{\const}{\text{const.}}
|
samer@14
|
59 \newcommand{\D}[1] {$#1$-D\xspace}
|
samer@14
|
60 \newcommand{\sh} {$\sharp$}
|
samer@14
|
61 \newcommand{\fl} {$\flat$}
|
samer@14
|
62 \newcommand{\Hmax}{H_\mathrm{max}}
|
samer@14
|
63 \newcommand{\Imax}{I_\mathrm{max}}
|
samer@14
|
64
|
samer@14
|
65 % centred dot with space either side for separating things
|
samer@14
|
66 %\def\nicedot{\hspace{0.7em}\textperiodcentered\hspace{0.7em}}
|
samer@14
|
67 \newlength\nicedotspace
|
samer@14
|
68 \setlength\nicedotspace{0.6em plus 0.1em minus 0.2em}
|
samer@14
|
69 \def\nicedot{\hspace{\nicedotspace}\textperiodcentered\hspace{\nicedotspace}}
|
samer@14
|
70
|
samer@14
|
71 %\newcommand{\margnote}[1] {\marginpar{\raggedright\itshape\small#1}}
|
samer@14
|
72
|
samer@14
|
73 % names
|
samer@14
|
74 \newcommand{\Hyvarinen}{Hyv\"arinen\xspace}
|
samer@14
|
75 \newcommand{\Kohler}{K\"ohler\xspace}
|
samer@14
|
76 \newcommand{\Pragnanz}{Pr\"{a}gnanz\xspace}
|
samer@14
|
77
|
samer@14
|
78 % environments
|
samer@14
|
79 \ifx\nodesc\undefined
|
samer@14
|
80 \renewenvironment{description}
|
samer@14
|
81 {\begin{list}{}{%
|
samer@14
|
82 \setlength{\labelwidth}{1.5em}
|
samer@14
|
83 \setlength{\leftmargin}{1.5em}
|
samer@14
|
84 \let\makelabel\descriptionlabel
|
samer@14
|
85 }}
|
samer@14
|
86 {\end{list}}
|
samer@14
|
87 \fi
|
samer@14
|
88
|
samer@14
|
89 \newenvironment{smallquote}
|
samer@14
|
90 { \begin{quote} \small}
|
samer@14
|
91 { \end{quote}}
|
samer@14
|
92
|
samer@14
|
93 \providecommand{\figplacement}{tbp}
|
samer@14
|
94 \newenvironment{fig}[2][\figplacement]
|
samer@14
|
95 {%
|
samer@14
|
96 \newcommand{\bbfig}[1]{\begin{figure}[##1]}
|
samer@14
|
97 \expandafter\bbfig\expandafter{#1}
|
samer@14
|
98 \def\fglbl{f:#2}
|
samer@14
|
99 \let\ocap=\caption
|
samer@14
|
100 \renewcommand{\caption}[2][]{\ocap[##1]{\small ##2}}
|
samer@14
|
101 \centering\small
|
samer@14
|
102 }{%
|
samer@14
|
103 \label{\fglbl}
|
samer@14
|
104 \end{figure}
|
samer@14
|
105 }
|
samer@14
|
106
|
samer@14
|
107 \newenvironment{fig*}[2][\figplacement]
|
samer@14
|
108 {%
|
samer@14
|
109 \newcommand{\bbfig}[1]{\begin{figure*}[##1]}
|
samer@14
|
110 \expandafter\bbfig\expandafter{#1}
|
samer@14
|
111 \def\figlabel{f:#2}
|
samer@14
|
112 \let\ocap=\caption
|
samer@14
|
113 \renewcommand{\caption}[2][]{\ocap[##1]{\small ##2}}
|
samer@14
|
114 \centering\small
|
samer@14
|
115 }{%
|
samer@14
|
116 \label{\figlabel}
|
samer@14
|
117 \end{figure*}
|
samer@14
|
118 }
|
samer@14
|
119
|
samer@14
|
120 \newenvironment{eq}[1]
|
samer@14
|
121 {\begin{equation}\def\eqlabel{eq:#1}}
|
samer@14
|
122 {\label{\eqlabel}\end{equation}}%
|
samer@14
|
123
|
samer@14
|
124
|
samer@14
|
125
|
samer@14
|
126
|
samer@14
|
127 % ------------- standard mathematics -----------------
|
samer@14
|
128
|
samer@14
|
129 % --- calculus
|
samer@14
|
130 \let\oldint\int \def\int#1\dd{\oldint#1\;\dd}
|
samer@14
|
131 \let\oldiint\iint \def\iint#1\dd#2\dd{\oldiint#1\;\dd#2\;\dd}
|
samer@14
|
132 \let\oldiiint\iiint \def\iiint#1\dd#2\dd#3\dd{\oldiiint#1\;\dd#2\;\dd#3\;\dd}
|
samer@14
|
133 \newcommand{\infint}[2] {\int_{-\infty}^\infty#2\dd#1}
|
samer@14
|
134 \newcommand{\partiald}[2] {\frac{\partial#1}{\partial#2}}
|
samer@14
|
135 \newcommand{\pd}[2] {\dfrac{\partial#1}{\partial#2}}
|
samer@14
|
136 \newcommand{\dd} {\mathrm{d}}
|
samer@14
|
137 \newcommand{\hdbyd}[2][] {\dd{#1}/\dd{#2}}
|
samer@14
|
138 \newcommand{\dbyd}[2][] {\frac{\dd#1}{\dd#2}}
|
samer@14
|
139 \newcommand{\dbydt}[1] {\frac{\dd#1}{\dd t}}
|
samer@14
|
140 \newcommand{\hpd}[2] {{\partial#1}/{\partial#2}}
|
samer@14
|
141 \newcommand{\grad} {\boldsymbol{\nabla}}
|
samer@14
|
142 \newcommand{\hfrac}[2] {#1/#2}
|
samer@14
|
143 \newcommand{\hpfrac}[2] {(#1/#2)}
|
samer@14
|
144
|
samer@14
|
145 % --- statistics
|
samer@14
|
146 \newcommand{\savg}[2][] {%
|
samer@14
|
147 \def\sub{#1} % optional subscript
|
samer@14
|
148 \ifx\sub\empty {\langle #2 \rangle}
|
samer@14
|
149 \else {\langle #2 \rangle}_{#1}
|
samer@14
|
150 \fi}
|
samer@14
|
151
|
samer@14
|
152 \newcommand{\avg}[2][] {%
|
samer@14
|
153 \def\sub{#1} % optional subscript
|
samer@14
|
154 \ifx\sub\empty {\left\langle #2 \right\rangle}
|
samer@14
|
155 \else {\left\langle #2 \right\rangle}_{#1}
|
samer@14
|
156 \fi}
|
samer@14
|
157
|
samer@14
|
158 \def\optRomanE{RomanE}
|
samer@14
|
159 \def\optItalicE{ItalicE}
|
samer@14
|
160 \def\optBBE{BBE}
|
samer@14
|
161 \def\optAngle{angle}
|
samer@14
|
162 \ifx\expectopt\optRomanE
|
samer@14
|
163 \newcommand{\expect}[2][] {%
|
samer@14
|
164 \def\sub{#1} % optional subscript
|
samer@14
|
165 \ifx\sub\empty \operatorname{E} \, #2
|
samer@14
|
166 \else \operatorname{E}_{#1} #2
|
samer@14
|
167 \fi
|
samer@14
|
168 }
|
samer@14
|
169 \fi
|
samer@14
|
170
|
samer@14
|
171 \ifx\expectopt\optItalicE
|
samer@14
|
172 \newcommand{\expect}[2][] {%
|
samer@14
|
173 \def\sub{#1} % optional subscript
|
samer@14
|
174 \ifx\sub\empty E \, #2
|
samer@14
|
175 \else E_{#1} #2
|
samer@14
|
176 \fi
|
samer@14
|
177 }
|
samer@14
|
178 \fi
|
samer@14
|
179
|
samer@14
|
180 \ifx\expectopt\optBBE
|
samer@14
|
181 \newcommand{\expect}[2][] {%
|
samer@14
|
182 \def\sub{#1} % optional subscript
|
samer@14
|
183 \ifx\sub\empty \mathbb{E} \, #2
|
samer@14
|
184 \else \mathbb{E}_{#1} #2
|
samer@14
|
185 \fi
|
samer@14
|
186 }
|
samer@14
|
187 \fi
|
samer@14
|
188
|
samer@14
|
189 \ifx\expectopt\optAngle
|
samer@14
|
190 \newcommand{\expect}[2][] {%
|
samer@14
|
191 \def\sub{#1} % optional subscript
|
samer@14
|
192 \ifx\sub\empty {\left\langle #2 \right\rangle}
|
samer@14
|
193 \else {\left\langle #2 \right\rangle}_{#1}
|
samer@14
|
194 \fi
|
samer@14
|
195 }
|
samer@14
|
196 \fi
|
samer@14
|
197
|
samer@14
|
198 \newcommand{\sqbr}[1] {[\,#1]}
|
samer@14
|
199 \newcommand{\var}[1] {\operatorname{var}\, #1}
|
samer@14
|
200 \newcommand{\cov}[2] {\operatorname{cov}[#1,#2]}
|
samer@14
|
201 \newcommand{\cc}[2] {\operatorname{corr}[#1,#2]}
|
samer@14
|
202 %\newcommand{\KL}[2] {\mathrm{KL}[\, #1 \|\, #2]}
|
samer@14
|
203 \newcommand{\KL}[2] {D(#1 \|\, #2)}
|
samer@14
|
204 \newcommand{\define} {\overset{\text{\tiny def}}{=}}
|
samer@14
|
205 \newcommand{\distr} {\sim}
|
samer@14
|
206
|
samer@14
|
207 % --- sets
|
samer@14
|
208 \newcommand*{\union} {\cup}
|
samer@14
|
209 \newcommand*{\diff} {\backslash}
|
samer@14
|
210 \newcommand*{\intersect} {\cap}
|
samer@14
|
211 \newcommand*{\integers} {\mathbb{Z}}
|
samer@14
|
212 \newcommand*{\reals} {\mathbb{R}}
|
samer@14
|
213 \newcommand*{\complexes} {\mathbb{C}}
|
samer@14
|
214 %\newcommand{\C} {\mathbb{C}}
|
samer@14
|
215 \newcommand*{\naturals} {\mathbb{N}}
|
samer@14
|
216 \newcommand*{\card}[1] {\abs{#1}}
|
samer@14
|
217 %\renewcommand*{\emptyset} {\varnothing}
|
samer@14
|
218
|
samer@14
|
219 % --- misc
|
samer@14
|
220 \def\rowvec(#1,#2){\begin{pmatrix} #1 & #2 \end{pmatrix}}
|
samer@14
|
221 \def\colvec(#1,#2){\begin{pmatrix} #1 \\ #2 \end{pmatrix}}
|
samer@14
|
222
|
samer@14
|
223 \ifx\detbar\undefined\else\def\det#1{|#1|}\fi
|
samer@14
|
224
|
samer@14
|
225 \newcommand{\sqtp}{\sqrt{2 \pi}}
|
samer@14
|
226 \DeclareMathOperator{\sech}{sech}
|
samer@14
|
227 \DeclareMathOperator{\sgn} {sgn}
|
samer@14
|
228 \DeclareMathOperator{\trace} {tr}
|
samer@14
|
229 \newcommand{\repart}{\Re\,}
|
samer@14
|
230 \newcommand{\impart}{\Im\,}
|
samer@14
|
231 \newcommand{\assign} {\leftarrow}
|
samer@14
|
232 \newcommand*\half {\tfrac{1}{2}}
|
samer@14
|
233 \newcommand{\fun}[1] {$#1(\cdot)$\xspace}
|
samer@14
|
234 \newcommand{\ffun}[1] {$#1(\cdot,\cdot)$\xspace}
|
samer@14
|
235 \newcommand{\tends} {\rightarrow}
|
samer@14
|
236 \ifx\underlinevec\undefined%
|
samer@14
|
237 \renewcommand*{\vec}[1] {\mathbf{#1}}
|
samer@14
|
238 \else
|
samer@14
|
239 \renewcommand*{\vec}[1] {\underline{#1}}
|
samer@14
|
240 \fi
|
samer@14
|
241 \providecommand{\abs}[1] {\lvert#1\rvert}
|
samer@14
|
242 \providecommand{\norm}[1] {\lVert#1\rVert}
|
samer@14
|
243
|
samer@14
|
244 \def\optparen{paren}
|
samer@14
|
245 \def\optmat{mat}
|
samer@14
|
246 \def\optdot{dot}
|
samer@14
|
247 \ifx\inneropt\optparen
|
samer@14
|
248 \newcommand{\inner}[2] {(#1,#2)}
|
samer@14
|
249 \fi
|
samer@14
|
250 \ifx\inneropt\optdot
|
samer@14
|
251 \newcommand{\inner}[2] {#1\cdot#2}
|
samer@14
|
252 \fi
|
samer@14
|
253 \ifx\inneropt\optmat
|
samer@14
|
254 \newcommand{\inner}[2] {{#1}^T#2}
|
samer@14
|
255 \fi
|
samer@14
|
256
|
samer@14
|
257 % --- psfig bits
|
samer@14
|
258 \newcommand{\psmath}[2] {\psfrag{#1}{\scriptsize $#2$}}
|
samer@14
|
259 \newcommand{\psmathbig}[2] {\psfrag{#1}{\small $#2$}}
|
samer@14
|
260
|
samer@14
|
261
|
samer@14
|
262 % \linespread{1.1}
|
samer@14
|
263
|
samer@14
|
264
|
samer@14
|
265 % top-aligned boxes
|
samer@14
|
266 \newbox\thehbox
|
samer@14
|
267 \newcommand{\hangbox}[1]{%
|
samer@14
|
268 \savebox{\thehbox}{#1}%
|
samer@14
|
269 \raisebox{-\ht\thehbox}[0pt][\ht\thehbox]{\usebox{\thehbox}}%
|
samer@14
|
270 % \raisebox{-\ht\thehbox}[0pt][-\ht\thehbox]{\usebox{\thehbox}}%
|
samer@14
|
271 }
|
samer@14
|
272
|
samer@14
|
273 \newenvironment{hanging}{%
|
samer@14
|
274 \begingroup
|
samer@14
|
275 \newbox\thebox
|
samer@14
|
276 \begin{lrbox}{\thebox}
|
samer@14
|
277 }{%
|
samer@14
|
278 \end{lrbox}%
|
samer@14
|
279 \raisebox{-\ht\thebox}[0pt][\ht\thebox]{\usebox{\thebox}}%
|
samer@14
|
280 \endgroup
|
samer@14
|
281 }%
|
samer@14
|
282
|
samer@14
|
283 % Hacky indentation - FIXME!
|
samer@14
|
284 \newenvironment{indented}
|
samer@14
|
285 {\vspace{-0.6em}\begin{quote}}
|
samer@14
|
286 {\end{quote}\vspace{-0.6em}}
|
samer@14
|
287
|