Skip to content

Instantly share code, notes, and snippets.

@gramian
Created January 9, 2017 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gramian/a5097904758173857a7e3d8fcb77fa9d to your computer and use it in GitHub Desktop.
Save gramian/a5097904758173857a7e3d8fcb77fa9d to your computer and use it in GitHub Desktop.
Useful TeX macros
\usepackage{adjustbox} % \ftitle
\usepackage{bbold} % for \1
% Text
%% Identifiers
\newcommand*{\doi}[1]{DOI \href{http://doi.org/#1}{\texttt{#1}}} % doi command
\newcommand*{\isbn}[1]{ISBN \href{http://www.worldcat.org/search?q=#1}{\texttt{#1}}} % isbn command
%% Colors
\definecolor{lgray}{gray}{0.8} % light gray
\definecolor{dred}{rgb}{0.75, 0.0, 0.0} % dark red
\definecolor{dgreen}{rgb}{0.0, 0.45, 0.0} % dark green
\definecolor{dblue}{rgb}{0.0, 0.0, 0.5} % dark blue
\newcommand{\red}[1]{\textcolor{dred}{#1}} % red text
\newcommand{\green}[1]{\textcolor{dgreen}{#1}} % green text
\newcommand{\blue}{\color{dblue}} % blue field
%% Convenience
\newcommand{\etal}{\textit{et al.}} % et al
%% Pages
\newcommand{\blank}{\newpage\mbox{}}
\newcommand{\clearoddpage}{\clearpage\ifodd\value{page}\else\null\thispagestyle{plain}\clearpage\fi}
%% Beamer
\newcommand{\framenote}[1]{\footnote[frame]{\tiny #1}} % footnotes for beamer slides
\newcommand{\ftitle}[1]{\frametitle{\adjustbox{max width=\textwidth}{#1}} % frametitle that fits
% Math
%% Sets
\DeclareMathOperator{\N}{\mathbb{N}} % natural numbers IN
\DeclareMathOperator{\R}{\mathbb{R}} % real numbers IR
% Constants
\DeclareMathOperator{\1}{\mathbb{1}} % unit matrix
\DeclareMathOperator{\I}{\imath} % imaginary unit
\DeclareMathOperator{\e}{e} % exponential
\DeclareMathOperator{\D}{\mathrm{d}\!} % differential
% Symbol Operators
\DeclareMathOperator{\sigm}{\varsigma} % sigmoid
\DeclareMathOperator{\E}{\mathbb{E}} % expected value
% Text Operators
\DeclareMathOperator{\svd}{\text{SVD}} % singular value decomposition
\DeclareMathOperator{\chol}{\operatorname{chol}} % cholesky decomposition
\DeclareMathOperator{\diag}{\operatorname{diag}} % diagonal
\DeclareMathOperator{\dist}{\operaotrname{dist}} % distance
\DeclareMathOperator{\pca}{PCA} % principal component analysis
\DeclareMathOperator{\Pod}{POD} % proper orthognal decomposition
\DeclareMathOperator{\mean}{mean} % arithmetic mean
\DeclareMathOperator{\avg}{avg} % average
\DeclareMathOperator{\orth}{orth} % orthogonal part
\DeclareMathOperator{\vect}{vec} % vectorization
\DeclareMathOperator{\Var}{Var} % variance
\DeclareMathOperator{\img}{im} % image space
\DeclareMathOperator{\tr}{tr} % trace
\DeclareMathOperator{\real}{Re} % real part
%% Split Operators
\DeclareMathOperator*{\argmax}{arg\,max} % argmax
\DeclareMathOperator*{\argmin}{arg\,min} % argmin
\DeclareMathOperator*{\esssup}{ess\,sup} % essential supremum
% Convenience
\newcommand{\lnorm}[1]{{\operatorname{L}_#1}} % continous Lebesque norm
\newcommand{\lnormh}[1]{{\operatorname{\ell}_#1}} % discrete Lebesque norm
\newcommand{\hnorm}[1]{{\operatorname{\mathcal{H}}_#1}} % Hardy norm
\newcommand{\hanorm}[1]{{\operatorname{H}_#1}} % Hankel norm
\newcommand{\Lnorm}[2]{{\operatorname{L}_#1^#2}} % Multi-dimensional Lebesque norm
\newcommand{\T}{\intercal} % Transposed
% Math Text
\newcommand{\mathsmall}[1]{\text{\footnotesize $#1$}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment