Skip to content

Instantly share code, notes, and snippets.

@arturbekasov
Last active June 7, 2021 13:09
Show Gist options
  • Save arturbekasov/a535f223e4cbd66f4d218f00e2ab77a7 to your computer and use it in GitHub Desktop.
Save arturbekasov/a535f223e4cbd66f4d218f00e2ab77a7 to your computer and use it in GitHub Desktop.
Latex macros
\usepackage{amsmath,amsfonts,amssymb,bm,mathtools}
%\usepackage[usenames,dvipsnames]{xcolor}
\newcommand{\vect}[1]{\mathbf{#1}} % Vector
\newcommand{\mat}[1]{\mathbf{#1}} % Matrix
\newcommand{\vx}{\vect{x}}
\newcommand{\vw}{\vect{w}}
\newcommand{\vv}{\vect{v}}
\newcommand{\vy}{\vect{y}}
\newcommand{\vz}{\vect{z}}
\newcommand{\vzero}{\vect{0}}
\newcommand{\eye}{\mathbb{I}}
\newcommand{\br}[1]{\mathopen{}\left(#1\right)\mathclose{}} % Brackets
\newcommand{\sqbr}[1]{\mathopen{}\left[#1\right]\mathclose{}} % Square brackets
\newcommand{\clrbr}[1]{\mathopen{}\left\{#1\right\}\mathclose{}} % Curly brackets
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\pair}[2]{\br{#1,#2}}
\newcommand{\abs}[1]{\left|#1\right|} % Absolute value
%\newcommand{\norm}[2]{\left\|#1\right\|_#2} % Norm
\newcommand{\norm}[1]{\left\lVert#1\right\rVert} % Norm
\newcommand{\bigo}[1]{\mathcal{O}\br{#1}} % Big O
\newcommand{\expect}[2]{{\mathop{{}\mathbb{E}}}_{#2}\sqbr{#1}} % Expectation
% Calculus
\newcommand{\integral}[2]{\int#1\operatorname{d}\!#2}
\newcommand{\sigm}[1]{\sigma\br{#1}}
\newcommand{\sigminv}[1]{\sigma^{-1}\br{#1}}
\newcommand{\diff}[1]{\operatorname{d}\!{#1}}
\newcommand{\deriv}[2]{\frac{\partial{#1}}{\partial{#2}}}
%\newcommand{\deriv}[2]{\frac{\partial{}}{\partial{#2}}#1}
\newcommand{\grad}[2]{\nabla_{#1}#2}
\newcommand{\tp}[1]{{#1}^\top} % Transpose
\newcommand{\prob}[1]{p\br{#1}} % Probability
\newcommand{\g}{\,|\,} % Given
\newcommand{\kl}[2]{D_{\mathrm{KL}}\br{#1\,\|\,#2}} % KL divergence
\newcommand{\real}{\mathbb{R}}
\newcommand{\sphere}{\mathbb{S}}
\newcommand{\torus}{\mathbb{T}}
% Standard distributions
\newcommand{\gaussian}[2]{\mathcal{N}\br{#1,#2}}
\newcommand{\gaussianx}[3]{\mathcal{N}\br{#1\g #2,#3}}
\newcommand{\uniform}[2]{\mathcal{U}\br{#1,#2}}
\newcommand{\uniformx}[3]{\mathcal{U}\br{#1\g #2,#3}}
% TODOs
%\newcommand{\todo}[1]{\textcolor{red}{\texttt{TODO:} #1}}
\newcommand{\todo}[1]{\textcolor{red}{\textit{#1}}}
\newcommand{\eg}{e.g.\ }
\newcommand{\ie}{i.e.\ }
\newcommand{\st}{s.t.\ }
\newcommand{\etc}{etc.\ }
\newcommand{\sota}{state-of-the-art }
\newcommand{\nb}{N.B.\ }
% Operators
\DeclareMathOperator{\logit}{logit}
\DeclareMathOperator{\softplus}{softplus}
\DeclareMathOperator*{\argmax}{\arg\!\max}
\DeclareMathOperator*{\argmin}{\arg\!\min}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment