Commands
排版大括号
$f(x)=\left{
\begin{aligned}
x & = & \cos(t) \
y & = & \sin(t) \
z & = & \frac {x}{y}
\end{aligned}
\right.$1
2
3
4
5
6
7f(x)=\left\{
\begin{aligned}
x & = & \cos(t) \\
y & = & \sin(t) \\
z & = & \frac xy
\end{aligned}
\right$f(x)=
\begin{cases}
0& \text{x=0}\
1& \text{x!=0}
\end{cases}$1
2
3
4
5
6
7\[f(x)=
\begin{cases}
0& \text{x=0}\\
1& \text{x!=0}
\end{cases}\]
% note cases only support one align operator &
% and they need to stay in a math block
Sections and Chapters: Usually,
\section
is the top-level document command in most documents. However, in reports or books, and similar long documents, this would be\chapter
or\part
. To get an unnumbered chapter / section add an asterisk (*
) at the end of the command, like\section*
.大写字母
- 双写体: $\mathbb{R}$ -
\mathbb{R}
- 粗体: $\mathbf{R}$ -
\mathbf{R}
- 花体: $\mathcal{R}$ -
\mathcal{R}
- 双写体: $\mathbb{R}$ -
Text:
Roman Font:
\textrm{}
Typewriter Font:
\texttt{}
Spacing:
\quad
- equal to the current font size (= 18 math unit): between a mathematical symbol and text in displayed expressions1
\[ E_n(t) \to e^{-t}\quad\text{as }t\to\infty \]
\qquad
- double “quad” (= 36 math unit) : between two separate equations1
\[ x^2 + y^2 = a^2,\qquad x-y=b \]
\,
(= 3 math unit) is the most commonly seen one with the thinnest space.\;
(= 5 math unit) is the spacing I always use.specify how many inches/cm -
\hspace{0.1in}
; you can use\vspace{1cm}
for vertical space~
inserts a non-breaking space, where you tell LaTeX not to insert a linebreak here
Vector: $\vec{p}$ -
\vec{p}
Self-defined operators:
\operatorname*{argmin}
Dot:
- horizontal dots on the line: $\ldots$ -
\ldots
- horizontal dots above the line: $\cdots$ -
\cdots
- single horizontal dot on the line: $\cdot$
\cdot
- vertical dots: $\vdots$ -
\vdots
- diagonal dots: $\ddots$ -
\ddots
- horizontal dots on the line: $\ldots$ -
Matrix: note this needs to be placed inside a math block
$$
\begin{bmatrix}
\sigma_{11} & \cdots & \sigma_{1n} \
\vdots & \ddots & \vdots \
\sigma_{n1} & \cdots & \sigma_{nn}
\end{bmatrix}
$$1
2
3
4
5\begin{bmatrix}
\sigma_{11} & \cdots & \sigma_{1n} \\
\vdots & \ddots & \vdots \\
\sigma_{n1} & \cdots & \sigma_{nn}
\end{bmatrix}proportional to: $\propto$
\propto
tilt / similar to: $\sim$
\sim
Wrap formula with a box
$$
\boxed{h(\mathbf{x}) = \operatorname*{argmax}y ; \hat\pi_y \prod{\alpha=1}^{d} P(x_\alpha | y)}
$$1
\boxed{ h(\mathbf{x}) = \operatorname*{argmax}_y \; \hat\pi_y \prod_{\alpha=1}^{d} P(x_\alpha | y) }
Comment in latex: use
%
Under or above any notation (also can do multiline):
$$
\underset{k\in N}{E}
\overset{wow}{E}
\underset{\substack{i \in N \ j \in N}}{E}
$$1
2
3
4\underset{k\in N}{E}
\overset{wow}{E}
% to write multi-line, use \substack
\underset{\substack{i \in N \\ j \in N}}{E}Under or above with braces: (For how to overlap multi braces, see the original answer)
$$
\underbrace{(x + 2)^3}_\text{text 1} \quad
\overbrace{(x - 3)}^\text{text 2}
$$1
2\underbrace{(x + 2)^3}_\text{text 1}
\overbrace{(x - 3)}^\text{text 2}Multiple lines of subscript / under (There is no known multiple lines of superscript)
$$
\sum_{\substack{a=b \ b=c}}
$$1
\sum_{\substack{a=b \\ b=c}}
Ceiling and floor:
$$
\lfloor x \rfloor \quad \lceil x \rceil
$$1
2\lfloor x \rfloor
\lceil x \rceilMake something to be centered even though its component has a non-zero width
$$
\int_{-\infty}^{\infty} e^{-\frac{(x-\mu)^2}{2\sigma^2}} , dx \
\int_{-\infty}^{\infty} \mathclap{e^{-\frac{(x-\mu)^2}{2\sigma^2}}} , dx
$$1
2\int_{-\infty}^{\infty} e^{-\frac{(x-\mu)^2}{2\sigma^2}} \, dx \\
\int_{-\infty}^{\infty} \mathclap{e^{-\frac{(x-\mu)^2}{2\sigma^2}}} \, dxDifferent types of alignment:
align
: numbers the equation (you can use\nonumber
after a specific line to suppress numbering)align*
: doesn’t number the equationalignat
: doesn’t add space between the columns (rl
pairs), but you have to tell it how many columns you have (It works if you have fewer columns than you specified but doesn’t if otherwise. So in theory you can just set a super big number to it)1
2
3
4
5
6\begin{alignat*}{3}
& m \quad && \text{módulo} \quad && m>0\\
& a \quad && \text{multiplicador} \quad && 0<a<m\\
& c \quad && \text{constante aditiva} \quad && 0\leq c<m\\
& x_0 \quad && \text{valor inicial} \quad && 0\leq x_0 <m
\end{alignat*}$$
\begin{alignat*}{3}
& m \quad && \text{módulo} \quad && m>0\
& a \quad && \text{multiplicador} \quad && 0<a<m\
& c \quad && \text{constante aditiva} \quad && 0\leq c<m\
& x_0 \quad && \text{valor inicial} \quad && 0\leq x_0 <m
\end{alignat*}
$$
Basic Knowledge
align
with &
An align
is a table-like structure, and &
is a column separator. The thing is that the columns in an align
are rlrlrlrlrl...
, that is, every other column is right aligned and left aligned.
So, below the a
is in a right aligned column, while =b
is left aligned
1 | a &= b |
In following, text
will be in a right aligned column,
1 | a &= b & text |
We should note that &&
is just & <no code here> &
, Therefore, if you do the following, text
will be in a left aligned column, as you basically just add an empty column between =b
and text
1 | a &= b && text |
Best Practices
\[ \]
over$$ $$
for display math:$$
is TeX primitive syntax and it’s pretty much deprecated. You should always use\[ \]
. more detailed reasons\( \)
over$ $
for inline math: similarly,$
is old TeX syntax whereas\( \)
is LaTex syntax. People suggest choose at your own preference for this inline math one since the old TeX syntax does provide much more readability. more discussion here