Latex公式编辑简易教程

by liupengyuan[at]pku.edu.cn

Latex简介

LaTeX – A document preparation system

  • LaTeX is a high-quality typesetting system;
  • It includes features designed for the production of technical and scientific documentation.
  • LaTeX is the de facto standard for the communication and publication of scientific documents.
  • LaTeX is available as free software.

1. 行内公式与独立公式

$a=c+d$

上式Latex代码:$a=c+d$ $$a=c+d$$ 上式Latex代码:$$a=c+d$$

2. 上标与下标

$n_i$

上式Latex代码:$n_i$

$n^i$

上式Latex代码:$n^i$

$n_{i,j}$

上式Latex代码:$n_{i,j}$

$n^{i+j}$

上式Latex代码:$n^{i+j}$

3. 根号与分数

3.1 根号

$\sqrt2$

上式Latex代码:$\sqrt2$

$\sqrt{x+y}$

上式Latex代码:$\sqrt{x+y$

$\sqrt[5]{x^2+y^2+z^2}$

上式Latex代码:$\sqrt[5]{x^2+y^2+z^2}$

3.2 分数

$\frac a c$

上式Latex代码:$\frac a c$

$\frac {a}{c+d+e}$

上式Latex代码:$\frac {a}{c+d+e}$

$\frac {a}{c+d+\frac e f}$

上式Latex代码:$\frac {a}{c+d+\frac e f}$

4.各类运算符号,字母形式

$\lambda,\xi,\pi,\mu,\Phi,\Omega,\alpha, \beta, \gamma,\Gamma, \Delta, \infty, \to$

上式Latex代码:$\lambda,\xi,\pi,\mu,\Phi,\Omega,\alpha, \beta, \gamma,\Gamma, \Delta, \infty, \to $

$\neq, \geq, \leq, \approx, \cdot, \cdots, \vdots, \ddots$

上式Latex代码:$\neq, \geq, \leq, \approx, \cdot, \cdots, \vdots, \ddots$

$\widetilde x, \widehat x, \overrightarrow A, \overleftarrow{bc}$

上式Latex代码:$\widetilde x, \widehat x, \overrightarrow A, \overleftarrow{bc}$

5. 求和、累积及积分

5.1 求和

$\sum$

上式Latex代码:$\sum$

$\sum_{i=1}^{n}$

上式Latex代码:$\sum_{i=1}^{n}$

$\sum_{i=1}^{n}x_i$

上式Latex代码:$\sum_{i=1}^{n}x_i$

$\sum_{i=1,j=1}^{n,m}{x_i \cdot y_j}$

上式Latex代码:$\sum_{i=1,j=1}^{n,m}{x_i \cdot y_j}$

5.2 累积

$\prod$

上式Latex代码:$\prod$

$\prod_{i=1,j=1}^{n,m}{x_i \cdot y_j}$

上式Latex代码:`$\prod_{i=1,j=1}^{n,m}{x_i \cdot y_j}$

5.3 积分

$\int$

上式Latex代码:$\int$

$\int_0^x{f(x)}$

上式Latex代码:$\int_0^x{f(x)}$

6 矩阵

$\begin{matrix} 1 & 2 & 3 \end{matrix}$

上式Latex代码:$\begin{matrix} 1 & 2 & 3 \end{matrix}$

$\begin{matrix} 1 \\ 2 \\ 3 \end{matrix}$

上式Latex代码:$\begin{matrix} 1 \\ 2 \\ 3 \end{matrix}$

$\begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{matrix}$

上式Latex代码:$\begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{matrix}$

$$\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{pmatrix}$$

上式Latex代码:$$\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{pmatrix}$$

$$\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{pmatrix} \tag3$$

上式Latex代码:$$\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{pmatrix} \tag3$$

$$\begin{pmatrix} 1 & 2 & \cdots & m \\ 1 & 4 & \cdots & m^2 \\ \vdots & \vdots & \ddots & \vdots\\ 1 & 2^n & \cdots & m^n \\ \end{pmatrix}$$

上式Latex代码:

$$\begin{pmatrix} 
1 & 2 & \cdots & m \\ 
1 & 4 & \cdots & m^2 \\
\vdots & \vdots & \ddots & \vdots\\
1 & 2^n & \cdots & m^n \\
\end{pmatrix}$$
$$\begin{array}{cc|c} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array}$$

式Latex代码:

$$\begin{array}{cc|c}
      1 & 2 & 3 \\
      4 & 5 & 6
    \end{array}$$
$$\left[ \begin{array}{cc|c} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array} \right] $$

上式Latex代码:

$$\left[
\begin{array}{cc|c}
      1 & 2 & 3 \\
      4 & 5 & 6
    \end{array}
    \right] $$

7. 空格、括号、绝对值、范数及转义

$x b, x\quad b, x\qquad b$

上式Latex代码:$x b, x\quad b, x\qquad b$

$\left(\frac a b \right), \left[\frac a b \right], \left|\frac a b \right|, \left\| \frac a b \right\|$

上式Latex代码:$\left(\frac a b \right), \left[\frac a b \right], \left|\frac a b \right|, \left\| \frac a b \right\|$

$\{a+b\}$

上式Latex代码:$\{a+b\}$

Latex中一些保留字符如:# $ % ^ & _ { } ~ \可直接用\+上述符号进行转义,即可输出