Follow me on GitHub

MathJax basic tutorial and quick reference MathJax基本教程和特性参考

标签(空格分隔): latex


1. See 查看命令

To see how any formula was written in any question or answer, including this one, right-click on the expression it and choose “Show Math As > TeX Commands”. (When you do this, the ‘$’ will not display. Make sure you add these. See the next point.)

2. inline formulas and displayed formulas 行内公式和整行公式

For inline formulas, enclose the formula in $...$. For displayed formulas, use \$\$...\$\$. 对于行内公式,写在$…$中。对整行公式,写在$$...$$中。

These render differently. For example, type 它们表现是不一样的。例如,输入

$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$

to show $\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$ (which is inline mode) or type 显示$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$(这是行内方式),若输入

$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$

to show 显示

(which is display mode). (这是整行方式)。

3. Greek letters 希腊字母

For Greek letters, use \alpha, \beta, …, \omega: $\alpha, \beta, …, \omega$.

For uppercase, use \Gamma, \Delta, …, \Omega: $\Gamma, \Delta, …, \Omega$.

4. superscripts and subscripts 上标和下标

For superscripts and subscripts, use ^ and _. For example, x_i^2 : $x_2^i$, \log_2 x : $\log_2 x$.

5. group 集合

Groups. Superscripts, subscripts, and other operations apply only to the next “group”. A “group” is either a single symbol, or any formula surrounded by curly braces {}. If you do 10^10, you will get a surprise: $10^10$. But 10^{10} gives what you probably wanted: $10^{10}$. Use curly braces to delimit a formula to which a superscript or subscript applies: x^5^6 is an error; {x^y}^z is xyz, and x^{y^z} is xyz. Observe the difference between x_i^2 $x_i^2$ and x_{i^2} $x_{i^2}$. 集合。上标,下标和其他操作只适用于下一个集合。一个集合可以是一个符号,也可以是是任何被大括号{}包围的公式。如果你输入10^10,你将会得到一个惊喜:$10^10$。但是10^{10}可以给你想要的结果:$10^{10}$。使用大括号划定上标下标适用的公式:x^5^6是错误的;{x^y}^z是${x^y}^z$,x^{y^z}是$x^{y^z}$。观察x_i^2 $x_i^2$和x_{i^2} $x_{i^2}$的区别

6. parentheses 括号

Parentheses Ordinary symbols ( ) [ ] make parentheses and brackets $(2+3) [4+4]$. Use \{ and \} for curly braces ${ }$. 普通括号符号( ) [ ]形如小括号和中括号$(2+3) [4+4]$。对于大括号${ }$使用 \{\}

These do not scale with the formula in between, so if you write (\frac{\sqrt x}{y^3}) the parentheses will be too small: $(\frac{\sqrt x}{y^3})$. Using \left(\right) will make the sizes adjust automatically to the formula they enclose: \left(\frac{\sqrt x}{y^3}\right) is $\left(\frac{\sqrt x}{y^3}\right)$. 它们不能随着其中公式而缩放,所以如果写(\frac{\sqrt x}{y^3})小括号会太小:$(\frac{\sqrt x}{y^3})$ 。使用 \left(\right) 将随着围起来的公式自动调整其大小:\left(\frac{\sqrt x}{y^3}\right) 显示为 $\left(\frac{\sqrt x}{y^3}\right)$ 。

\left and \right apply to all the following sorts of parentheses: ( and ) $(x)$ , [ and ] $[x]$ , \{ and \} ${x}$ , | $|x|$ , \vert $\vert x\vert$ , \Vert $\Vert x \Vert$ , \langle and \rangle $\langle x \rangle$ , \lceil and \rceil $\lceil x \rceil$ , and \lfloor and \rfloor $\lfloor x \rfloor$. \left 和 \right适用于下面所有种类的括号: () $(x)$ , [] $[x]$ , \{\} ${x}$ , | $|x|$ , \vert $\vert x\vert$ , \Vert $\Vert x \Vert$ , \langle\rangle $\langle x \rangle$ , \lceil\rceil $\lceil x \rceil$ , 和 \lfloor\rfloor $\lfloor x \rfloor$ 。

There are also invisible parentheses, denoted by . : \left.\frac12\right\rbrace is $\left.\frac12\right\rbrace$. 还有不可见括号,记作 . : \left.\frac12\right\rbrace 显示为 $\left.\frac12\right\rbrace$ 。

If manual size adjustments are required : \Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) gives $\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)$. 若要手动调整大小,命令为 : \Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) 得到 $\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)$ 。

7. Sums and integrals 求和与积分

Sums and integrals \sum and \int; the subscript is the lower limit and the superscript is the upper limit, so for example \sum_1^n $\sum_1^n$. Don’t forget {} if the limits are more than a single symbol. For example, \sum_{i=0}^\infty i^2 is $\sum_{i=0}^\infty i^2$ . 求和与积分是\sum\int;用下标表示下限,上标表示上限,例如 \sum_1^n $\sum_1^n$ 。如果上下限超过了一个符号别忘了用 {} 。 例如,\sum_{i=0}^\infty i^2 要写成 $\sum_{i=0}^\infty i^2$ 。

Similarly , \prod $\prod$ , \int $\int$ , \bigcup $\bigcup$ , \bigcap $\bigcap$ , \iint $\iint$. 相同地,

8. Fractions 分数

Fractions There are two ways to make these. \frac ab applies to the next two groups, and produces $\frac ab$ ; for more complicated numerators and denominators use {}: \frac{a+1}{b+1} is $\frac{a+1}{b+1}$ . If the numerator and denominator are complicated, you may prefer \over, which splits up the group that it is in: {a+1\over b+1} is ${a+1\over b+1}$ . 有两种方式可以写出分数。\frac ab 适用于后面两个集合,生成$\frac ab$ ; 对于更复杂的分子和分母使用{}\frac{a+1}{b+1} 写成 $\frac{a+1}{b+1}$ 。 如果分子和分母复杂,你可能更喜欢 \over ,它能把所在的集合分开: {a+1\over b+1}显示为 ${a+1\over b+1}$ 。

9. Fonts 字体

Use \mathbb or \Bbb for “blackboard bold”: $\Bbb{CHNQRZ}$ . 黑板粗体

Use \mathbf for boldface: $\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz}$ . 粗体

Use \mathtt for “typewriter” font: $\mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz}$ . 打字机字体

Use \mathrm for roman font: $\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz}$ . 罗马字体

Use \mathsf for sans-serif font: $\mathsf{abcdefghijklmnopqrstuvwxyz}$ . 无衬线字体

Use \mathcal for “calligraphic” letters: $\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ . 书法字体

Use \mathscr for script letters: $\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ . 脚本字体

Use \mathfrak for “Fraktur” (old German style) letters: $\mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz}$ . 旧德式字母

10. Radical signs 根号

Radical signs Use \sqrt, which adjusts to the size of its argument: \sqrt{x^3} $\sqrt{x^3}$ ; \sqrt[3]{\frac xy} $\sqrt[3]{\frac xy}$ . For complicated expressions, consider using {...}^{1/2} instead. 根号使用 \sqrt , 它会根据内容调整大小: \sqrt{x^3} $\sqrt{x^3}$ ; \sqrt[3]{\frac xy} $\sqrt[3]{\frac xy}$ 。对于复杂表达式,考虑使用 {...}^{1/2} 代替。

11. special functions 特殊函数

Some special functions such as “lim” , “sin” , “max” , “ln” , and so on are normally set in roman font instead of italic font. Use \lim, \sin, etc. to make these: \sin x $\sin x$ , not sin x $sinx$ . 一些特殊函数例如 “lim” , “sin” , “max” , “ln” , 通常设置为罗马字体来代替斜体字体。使用 \lim, \sin等来写它们: \sin x $\sin x$ , 而不是 sin x $sin x$ 。

Use subscripts to attach a notation to \lim : 使用下标将符号附加到 \lim

\lim_{x\to 0}

12. special symbols and notations 特殊符号和符号

There are a very large number of special symbols and notations, too many to list here; see this shorter listing, or this exhaustive listing. Some of the most common include: 有非常多特殊符号和符号,太多了以至于无法在这里完全列出;看这份比较简短的列表,或者这份详尽的列表。最常见的一些包括:

  • \lt \gt \le \ge \neq $\lt \gt \le \ge \neq$. You can use \not to put a slash through almost anything: \not\lt $\not\lt$ but it often looks bad. 你可以使用 \not 来给几乎任何符号加上斜线:\not\lt $\not\lt$ 但是它经常看起来很糟糕。

  • \times \div \pm \mp $\times \div \pm \mp$ . \cdot is a centered dot: $x \cdot y$ .

  • \cup \cap \setminus \subset \subseteq \subsetneq \supset \in \notin \emptyset \varnothing $\cup \cap \setminus \subset \subseteq \subsetneq \supset \in \notin \emptyset \varnothing$

  • {n+1 \choose 2k} or \binom{n+1}{2k} ${n+1 \choose 2k}$

  • \to \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto $\to \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto$

  • \land \lor \lnot \forall \exists \top \bot \vdash \vDash $\land \lor \lnot \forall \exists \top \bot \vdash \vDash$

  • \star \ast \oplus \circ \bullet $\star \ast \oplus \circ \bullet$

  • \approx \sim \simeq \cong \equiv \prec \lhd $\approx \sim \simeq \cong \equiv \prec \lhd$

  • \infty \aleph_0 $\infty \aleph_0$ \nabla \partial $\nabla \partial$ \Im \Re $\Im \Re$

  • For modular equivalence, use \pmod like this: a\equiv b\pmod n $a\equiv b\pmod n$ . 对于恒等与取余,

  • \ldots is the dots in $a_1,a_2,\ldots,a_n$ . \cdots is the dots in $a_1+a_2+\cdots+a_n$ .

  • Some Greek letters have variant forms: \epsilon \varepsilon $\epsilon \varepsilon$ , \phi \varphi $\phi \varphi$ , and others. Script lowercase l is \ell $\ell$ . 一些希腊字母有变体形式: 脚本小写l是

13. Spaces 空间

Spaces MathJax usually decides for itself how to space formulas, using a complex set of rules. Putting extra literal spaces into formulas will not change the amount of space MathJax puts in: a ␣ b and a ␣ ␣ ␣ b are both $ab$. To add more space, use \, for a thin space $a\,b$; \; for a wider space $a\;b$ . \quad and \qquad are large spaces: $a \quad b$ , $a \qquad b$ . 空间。MathJax通常决定如何使用一组复杂的规则来排列公式。在公式中插入额外的字面上的空格并不能改变MathJax输出的空格的数目:a ␣ ba ␣ ␣ ␣ b都是 $ab$ 。想插入更多的空隙,使用 \, 加入一个细的空隙 $a\,b$ ;使用 \; 加入一个中等的空隙 $a\;b$ ;使用 \quad\qquad 加入一个长的空隙 $a \quad b$ , $a \qquad b$ 。

To set plain text, use \text{…}: ${x \in s \mid x \text{ is extra large}}$ . You can nest $…$ inside of \text{…} . 要设置纯文本,使用\text{…}: ${x \in s \mid x \text{ is extra large}}$ 。 你可以将 $…$ 嵌套在 \text{…} 中使用。

14. Accents and diacritical 重音和变音标记

Accents and diacritical marks Use \hat for a single symbol $\hat x$, \widehat for a larger formula $\widehat{xy}$. If you make it too wide, it will look silly. Similarly, there are \bar $\bar x$ and \overline $\overline{xyz}$, and \vec $\vec x$ and \overrightarrow $\overrightarrow{xy}$ and \overleftrightarrow $\overleftrightarrow{xy}$ . For dots, as in $\frac d{dx} x \dot x = \dot x^2 + x \ddot x$ , use \dot and \ddot. 重音和变音标记。对于单个符号,使用\hat $\hat x$ ,对长的公式使用\widehat $\widehat{xy}$ 。如果你使它太宽,它看起来会显得很呆。同样的,使用 …… 对于点

15. Special characters used for MathJax interpreting 被用于MathJax解释的特殊字符

Special characters used for MathJax interpreting can be escaped using the \ character: \$ $$$ , \{ ${$ , \_ $_$ , etc. If you want \ itself, you should use \backslash $\backslash$ , because \\ is for a new line. 被用于MathJax解释的特殊字符可以使用 \ 进行转码:….,等。如果想显示 \ 本身,请使用 \backslash ,因为 \\ 被用作表示新的一行。