Skip to content

Instantly share code, notes, and snippets.

@kpsychas
Last active November 22, 2019 06:59
Show Gist options
  • Save kpsychas/3c40e1672af7c67f5804522e7b3954d1 to your computer and use it in GitHub Desktop.
Save kpsychas/3c40e1672af7c67f5804522e7b3954d1 to your computer and use it in GitHub Desktop.
Latex Useful Command Collection
  • bold math

    \mathbf{a}

    \bm{\alpha} // requires: \usepackage{bm}

  • double line font (expectation, probability, real numbers)

\mathds{E},\mathds{P} // requires: \usepackage{dsfont}

  • calligraphic font (set)

\mathcal{A}

  • equation with alignment
\begin{equation}
  \begin{aligned}
  x &= 1 \\
  y &= 2
  \end{aligned}
\end{equation}
  • Conditional function definition (with {)
f(x) = \left\{ 
\begin{array}{ll}
-\delta & x < 0 \\
x -\delta & x \ge 0
\end{array}
\right.
  • argmin, argmax

Use one of the declarations

\DeclareMathOperator*{\argmin}{arg\,min} % thin space, limits underneath in displays
\DeclareMathOperator*{\argmin}{argmin} % no space, limits underneath in displays
\DeclareMathOperator{\argmin}{arg\,min} % thin space, limits on side in displays
\DeclareMathOperator{\argmin}{argmin} % no space, limits on side in displays

// requires: \usepackage{amsmath}

  • numbered subequations
\begin{subequations}\label{eq:main}
    \begin{equation}\label{eq:main_cond1}
    x=1
    \end{equation}
    \begin{equation}\label{eq:main_cond2}
    x=2
    \end{equation}
    \begin{equation}\label{eq:main_cond3}
    x=3
    \end{equation}
\end{subequations}
  • custom numbering // requires: \usepackage{enumitem}
\begin{enumerate}[label=P.\arabic*]
\item\label{item:1}
\end{enumerate}
  • floor and ceiling functions
\documentclass{minimal}
\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\begin{document}
  \begin{equation*}
    \floor*{\frac{x}{2}} < \frac{x}{2} < \ceil*{\frac{x}{2}}
  \end{equation*}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment