MathJax basic tutorial and quick reference

From http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference

  1. For inline formulas, enclose the formula in$...$. For displayed formulas, use$$...$$.

  2. ForGreek letters, use\alpha,\beta, …,\omega:α,β,…ω. For uppercase, use\Gamma,\Delta, …,\Omega:Γ,Δ,…,Ω.

    Formulas

  3. Forsuperscripts and subscripts, use^and_.
    For example,x_i^2:

    x_i^2

  4. 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 do10^10, you will get a surprise:

    10^10
    But10^{10}gives what you probably wanted:
    10^{10}
    Use curly braces to delimit a formula to which a superscript or subscript applies:x^5^6is an error;{x^y}^zis
    {x^y}^z
    andx^{y^z}is
    x^{y^z}
    Observe the difference betweenx_i^2
    x_i^2
    andx_{i^2}
    x_{i^2}

  5. ParenthesesOrdinary symbols()[]make parentheses and brackets(2+3)[4+4]. Use\{and\}for curly braces{}.
    These donotscale 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)
    \leftand \rightapply to all the following sorts of parentheses:(and)(x),[and][x],\{and\}{x},||x|,\langleand\rangle⟨x⟩,\lceiland\rceil⌈x⌉, and\lfloorand\rfloor⌊x⌋. There are also invisible parentheses, denoted by.:\left.\frac12\right\rbraceis
    \left.\frac12\right\rbrace

  6. Sums and integrals\sumand\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^2is
    \sum_{i=0}^\infty i^2
    Similarly,\prod∏,\int∫,\bigcup⋃,\bigcap⋂,\iint∬.

  7. FractionsThere are two ways to make these.\frac abapplies to the next two groups, and produces

    \frac ab
    for more complicated numerators and enominators 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}

  8. Fonts

  • Use\mathbbor\Bbbfor "blackboard bold":
    blackboard bold
  • Use\mathbffor boldface:
    boldface
  • Use\mathttfor "typewriter" font:
    typewriter
  • Use\mathrmfor roman font:
    roman
  • Use\mathsffor sans-serif font:
    sans-serif font
  • Use\mathcalfor "calligraphic" letters:
    calligraphic
  • Use\mathscrfor script letters:
    script
  • Use\mathfrakfor "Fraktur" (old German style) letters:
    Fraktur
  1. Radical signsUsesqrt, 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.

  2. Somespecial functionssuch 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
    notsin x
    sin x
    Use subscripts to attach a notation to\lim:\lim_{x\to 0}
    \lim_{x\to 0}

  3. There are a very large number ofspecial symbols and notations, too many to list here; seethis shorter listing, orthis exhaustive listing. Some of the most common include:

  • \lt \gt \le \ge \neq<>≤≥≠. You can use\notto put a slash through almost anything:\not\lt≮but it often looks bad.
  • \times \div \pm \mp×÷±∓.\cdotis a centered dot:x⋅y
  • \cup \cap \setminus \subset \subseteq \subsetneq \supset \in \notin \emptyset \varnothing∪∩∖⊂⊆⊊⊃∈∉∅∅
  • {n+1 \choose 2k}or\binom{n+1}{2k}
    \binom{n+1}{2k}
  • \to \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto→→←⇒⇐
  • \land \lor \lnot \forall \exists \top \bot \vdash \vDash∧∨¬∀∃⊤⊥⊢⊨
  • \star \ast \oplus \circ \bullet⋆∗⊕∘∙
  • \approx \sim \simeq \cong \equiv \prec≈∼≃≅≡≺
  • \infty \aleph_0∞ℵ0\nabla \partial∇∂\Im \Reℑℜ
  • For modular equivalence, use\pmodlike this:a\equiv b\pmod na≡b (mod n).
  • \ldotsis the dots in
    \ldots
    an\cdotsis the dots in
    \cdots
  • Some Greek letters have variant forms:\epsilon \varepsilonϵε,\phi \varphiϕφ, and others. Script lowercase l is\ellℓ.

Detexifylets you draw a symbol on a web page and then lists theTEXsymbols that seem to resemble it. These are not guaranteed to work in MathJax but are a good place to start. To check that a command is supported, note that MathJax.org maintains alist of currently supportedLATEXcommands, and one can also check Dr. Carol JVF Burns's page of[TEXCommands Available in MathJax(http://www.onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm).

  1. SpacesMathJax 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␣banda␣␣␣␣bare both

    ab
    To add more space, use\,for a thin space
    a b
    \;for a wider space
    a b
    \quadand\qquadare large spaces:
    a b,a b
    To set plain text, use\text{…}:{x∈s∣xis extra large}. You can nest$…$inside of\text{…}.

  2. Accents and diacritical marksUse\hatfor a single symbol

    \hat
    \widehatfor a larger formula
    \widehat
    If you make it too wide, it will look silly. Similarly, there are\bar
    \bar
    and\overline
    \overline
    and\vec
    \vec
    and\overrightarrow
    \overrightarrow
    and\overleftrightarrow
    \overleftrightarrow
    For dots, as in
    \dotand\ddot
    use\dotand\ddot.

  3. Special characters used for MathJax interpreting can be escaped using the\character:\$$,\{{,\__, etc. If you want\itself, you should use\backslash∖, because\\\is for a new line.

Examples

  1. Use$$\begin{matrix}…\end{matrix}$$In between the\beginand\end, put the matrix elements. End each matrix row with\\\, and separate matrix elements with&. For example,
$$
        \begin{matrix}
        1 & x & x^2 \\
        1 & y & y^2 \\
        1 & z & z^2 \\
        \end{matrix}
$$

produces:


example

MathJax will adjust the sizes of the rows and columns so that everything fits.

  1. To add brackets, either use\left…\rightas in section 6 of the tutorial, or replacematrix withpmatrix

    Paste_Image.png
    bmatrix
    Paste_Image.png
    Bmatrix
    Paste_Image.png
    vmatrix
    Paste_Image.png
    Vmatrix
    Paste_Image.png

  2. Use\cdots\ddots\vdots⋮when you want to omit some of the entries:

    Paste_Image.png

  3. For "augmented" matrices, put parentheses or brackets around a suitably-formatted table; seearraysbelow for details. Here is an example:

    Paste_Image.png

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

Thecc|cis the crucial part here; it says that there are three centered columns with a vertical bar between the second and third.

  1. For small inline matrices use\bigl(\begin{smallmatrix} ... end{smallmatrix}\bigr), e.g.


    Paste_Image.png

    is produced by:

$\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)$
  1. Often people want a series of equations where the equals signs are aligned. To get this, use\begin{align}…\end{align}. Each line should end with\, and should contain an ampersand at the point to align at, typically immediately before the equals sign.
    For example,


    Paste_Image.png

    is produced by

\begin{align}
\sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \\
 & = \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \\ 
 & = \sqrt{\frac{73^2}{12^2}}\sqrt{\frac{73^2-1}{73^2}} \\
 & = \frac{73}{12}\sqrt{1 - \frac{1}{73^2}} \\ 
 & \approx \frac{73}{12}\left(1 - \frac{1}{2\cdot73^2}\right)
\end{align}
Paste_Image.png

by writing this:

 f(n) =
\begin{cases}
n/2,  & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}

The brace can be moved to the right:

Paste_Image.png

by writing this:

\left.
\begin{array}{l}
\text{if $n$ is even:}&n/2\\
\text{if $n$ is odd:}&3n+1
\end{array}
\right\}
=f(n)

To get a larger vertical space between cases we can use\\\[2ex]
instead of\\\. For example, you get this:

Paste_Image.png

by writing this:

f(n) =
\begin{cases}
\frac{n}{2},  & \text{if $n$ is even} \\[2ex]
3n+1, & \text{if $n$ is odd}
\end{cases}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,793评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,567评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,342评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,825评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,814评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,680评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,033评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,687评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,175评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,668评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,775评论 1 332
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,419评论 4 321
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,020评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,978评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,206评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,092评论 2 351
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,510评论 2 343

推荐阅读更多精彩内容