Math equations #
Math Fonts #
Ref: Mathematical fonts - Overleaf, Online LaTeX Editor
Bold: $\mathbf{RQSZN}$
, $\mathbf{1}$
, $\boldsymbol{\beta}$
\mathbf{X}
\mathbf{1}
\boldsymbol{\beta} % requires amsbsy package % https://tex.stackexchange.com/a/99286
Bold hollow: $\mathbb{RQSZN}$
(for numbers extra packages are needed)
\mathbb{R}
Cursive: $\mathcal{RQSZN}$
\mathcal{N}
Force Non-Display Size #
Compare:
$$ \textstyle{\sum}_{i=1}^{10} i $$
$$ \sum_{i=1}^{10} i $$
\textstyle{\sum}_{i=1}^{10}
\sum_{i=1}^{10}
Combining Symbols #
Above: $x\overset{!}{=}0$
x\overset{!}{=}0
With negative space: $\mkern12mu\not\mkern-24mu\iff$
(credit; another way not supported by KaTeX)
% The first part is for stopping eating into contents before
\mkern12mu\not\mkern-24mu\iff
% or
\usepackage{centernot}
\centernot\iff
Better \bar
#
Ref: stacking symbols - The \bar and \overline commands - TeX - LaTeX Stack Exchange
Gives the middle one:
\usepackage{amsfonts}
\newcommand{\overbar}[1]{\mkern 1.5mu\overline{\mkern-1.5mu#1\mkern-1.5mu}\mkern 1.5mu}
$\overbar{\mathbb{R}}$
Alignment #
Basic aligns & tag position #
Single line equation #
Using \label{eq1}
in any expression, and refer to it as eq1; $\eqref{eq1}$
; $\ref{eq1}$
later
…by typing:
[eq1](#eq1)
$\eqref{eq1}$
$\ref{eq1}$
The latter two are valid in LaTeX as well.
This requires adding macros when importing KaTeX. See Issue #2003 · KaTeX/KaTeX for details.
There is also \htmlId
functionality which is less intuitive to use but do not require adding macros.
Auto tag: (Numbers are continuous during the whole webpage)
$$\begin{equation} x = y \label{eq1} \end{equation} $$
\begin{equation}
x = y \label{eq1}
\end{equation}
Manual tag: (Numbers are not continuous)
$$x = y \tag{1.1}$$
x = y \tag{1.1}
% or
\begin{equation*}
x = y \tag{1.1}
\end{equation*}
No tag:
$$\begin{equation*} x = y \end{equation*}$$
x = y
% or
\begin{equation*}
x = y
\end{equation*}
Multi-line signle equation with aligned
#
Auto tag:
$$ \begin{equation} \begin{aligned} x &= y \\ &= z \end{aligned} \end{equation} $$
\begin{equation}
\begin{aligned}
x &= y \\
&= z
\end{aligned}
\end{equation}
Manual tag: (For no tag, remove the \tag
command.)
$$ \begin{aligned} x &= y \\ &= z \tag{2.1} \end{aligned} $$
\begin{aligned}
x &= y \\
&= z \tag{2.1}
\end{aligned}
Multiple equations with Align
#
Auto tag:
$$ \begin{align} x &= y \\ 2x &= 2z \end{align} $$
\begin{align}
x &= y \\
2x &= 2z
\end{align}
No tag: (For manual tag, add \tag
command.)
$$ \begin{align*} x &= y \\ 2x &= 2z \end{align*} $$
\begin{align*}
x &= y \\
2x &= 2z
\end{align*}
More examples #
Cases:
$$ \begin{cases} x=1 & y=1\\ x=2 & y=2 \end{cases} $$
\begin{cases}
x=1 & y=1\\
x=2 & y=2
\end{cases}
Symbols as equation tag: (Ref)
$$E=mc^2 \tag{$*$}$$
E=mc^2 \tag{$*$}
Spaces in equations:
$$ \begin{aligned} x &= 12345 \\ &\phantom{\ggg} + 67890 \end{aligned} $$
\begin{aligned}
x &= 12345 \\
&\phantom{\ggg} + 67890
\end{aligned}
Braces with multiple lines:
$$ \underbrace{abcdef}_{ \begin{subarray}{l} \text{hello}\\ \text{world} \end{subarray} } $$
\underbrace{abcdef}_{
\begin{subarray}{l}
\text{hello}\\
\text{world}
\end{subarray}
}
Horizontally aligned braces: (Ref)
$$ f(x,z) = \underbrace{\int^a_b x\ dx}_{\text{Things}} +\underbrace{\vphantom{\int_b}2333z}_{\text{More things}} $$
f(x,z) =
\underbrace{\int^a_b x\ dx}_{\text{Things}}
+\underbrace{\vphantom{\int_b}2333z}_{\text{More things}}
More horizontally aligned braces: (Ref)
$$ f(x,z) = \underbrace{\int^a_b x\ dx}_{\text{Things}} +\overbrace{\vphantom{\int^a}42xz^2}^{\mathclap{\text{Longer other things}}} +\underbrace{\vphantom{\int_b}2333z}_{\mathclap{\text{More longer things}}} $$
f(x,z) =
\underbrace{\int^a_b x\ dx}_{\text{Things}}
+\overbrace{\vphantom{\int^a}42xz^2}^{\mathclap{\text{Longer other things}}}
+\underbrace{\vphantom{\int_b}2333z}_{\mathclap{\text{More longer things}}}
Newer and better environment defaults #
Space in braces #
Refs:
- math mode - How to adjust the blank space between the top of the left curly brace and the contents? - TeX - LaTeX Stack Exchange
- Horizontal spacing after cases bracket in equation - TeX - LaTeX Stack Exchange
\usepackage{amsmath}
\makeatletter
\def\env@cases{%
\let\@ifnextchar\new@ifnextchar
\left\lbrace
\def\arraystretch{1.1}%
\array{@{\,}l@{\quad}l@{}}%
}
\makeatother