misc

Latex tips & tricks

Nice looking function definitions

\usepackage{mathtools}
$f \coloneqq \mathbb{N} \mapsto \mathbb{R}$

Set builder notation

\newcommand{setbuilder}[2]{\ensuremath{\{#1 \,|\, #2\}}}
$A = \setbuilder{w \in \mathbb{R}}{w \geq 0}$

Local (chapter or section) label names

\newcommand{chplabel}[1]{\label{\thechapter:#1}}
\newcommand{chpref}[1]{\ref{\thechapter:#1}}
\newcommand{seclabel}[1]{\label{\thesection:#1}}
\newcommand{secref}[1]{\ref{\thesection:#1}}

Log-sum-exp

\newcommand{\lse}{\mathrm{L}\overset{K}{\underset{i=1}{\mathrm{\Sigma}}}\mathrm{E}}

Indicator function

\usepackage{dsfont}
\mathds{1}_{\{ x = y \}}

Mathtools for sums and products

\usepackage{mathtools}
n = \sum_{\mathclap{i \in \mathbb{R} \,|\, i>10}} i^2
n = \sum_{\mathclap{\substack{i \in \mathbb{R} \\ i>10}}} i^2