Skip to content

Instantly share code, notes, and snippets.

@Kashu7100
Forked from yoshipon/math_symbols.tex
Created November 1, 2024 21:06
Show Gist options
  • Save Kashu7100/ac6f2cef1119a12a04285e674614527b to your computer and use it in GitHub Desktop.
Save Kashu7100/ac6f2cef1119a12a04285e674614527b to your computer and use it in GitHub Desktop.
LaTeX macros for writing math symbols
% MIT License
%
% Copyright 2024 Yoshiaki Bando
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included in all
% copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
% SOFTWARE.
\usepackage{array, amsmath, amssymb, amsfonts, bm, mleftright,xargs}
\newcommand{\diag}{\mathrm{diag}}
% argmin, argmax
\newcommand{\argmax}{\operatornamewithlimits{argmax}}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}
% set
\newcommand{\setR}{\mathbb{R}}
\newcommand{\setRp}{\mathbb{R}_+}
\newcommand{\setC}{\mathbb{C}}
\newcommand{\setSp}{\mathbb{S}_+}
% matrix symbols and operators
\newcommand{\eye}{{\bf I}}
\newcommand{\T}{\mathsf{T}}
\newcommand{\adj}{\mathsf{H}}
\newcommand{\trace}{\mathrm{tr}}
% distributions
% \newcommand{\distpoisson}[1]{\mathcal{P}\left({#1}\right)}
\newcommand{\distpoisson}[1]{\mathrm{Poisson}\left({#1}\right)}
\newcommand{\distbernoulli}[1]{\mathrm{Bernoulli}\left({#1}\right)}
\newcommand{\distinvgamma}[2]{\mathrm{InvGamma}\left({#1}, {#2}\right)}
\newcommand{\distgamma}[2]{\mathrm{Gamma}\left({#1}, {#2}\right)}
\newcommand{\distgig}[3]{\mathrm{GIG}\left({#1}, {#2}, {#3}\right)}
\newcommand{\distexponential}[1]{\mathrm{Exponential}\left({#1}\right)}
\newcommand{\distnormal}[2]{\mathcal{N}\left({#1}, {#2}\right)}
\newcommand{\distcmpnormal}[2]{\mathcal{N}_{\mathbb{C}}\left({#1}, {#2}\right)}
\newcommand{\distcmpacg}[1]{\mathcal{ACG}_{\mathbb{C}}\left({#1}\right)}
\newcommand{\distcmpinvwishart}[2]{\mathcal{IW}_{\mathbb{C}}\left({#1}, {#2}\right)}
\newcommand{\distcategorical}[1]{\mathrm{Cat}\left({#1}\right)}
\newcommand{\distdirichlet}[1]{\mathrm{Dir}\left({#1}\right)}
\newcommand{\distbeta}[2]{\mathrm{Beta}\left({#1}, {#2}\right)}
% expectations
\newcommand{\E}{\mathbb{E}}
\newcommand{\KL}{\mathcal{D}_\mathrm{KL}}
\newcommand{\JS}{\mathcal{D}_\mathrm{JS}}
\newcommand{\ave}[1]{\left\langle #1 \right\rangle}
% misc.
\newcommand{\allparams}{\bm{\Theta}}
% variable
\NewDocumentCommand\newletter{m m o m m}{% \x x [^*] ft t
\NewDocumentCommand#1{s t@ o}{%
\IfBooleanTF{##1}{\mathbf{\MakeUppercase{#2}}\IfValueT{#3}{^{#3}}}{%
\IfBooleanTF{##2}{\mathbf{#2}\IfValueT{#3}{^{#3}}_{\IfValueTF{##3}{##3}{#5}}}{%
{#2}\IfValueT{#3}{^{#3}}_{\IfValueTF{##3}{##3}{#4}}%
}}}}
\NewDocumentCommand\newletterbm{m m o m m}{% \x x [^*] ft t
\NewDocumentCommand#1{s t@ o}{%
\IfBooleanTF{##1}{\bm{\MakeUppercase{#2}}\IfValueT{#3}{^{#3}}}{%
\IfBooleanTF{##2}{\bm{#2}\IfValueT{#3}{^{#3}}_{\IfValueTF{##3}{##3}{#5}}}{%
{#2}\IfValueT{#3}{^{#3}}_{\IfValueTF{##3}{##3}{#4}}%
}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment