Latex公式编辑,适用于MarkDown编辑器 mathjax-basic-tutorial-and-quick-reference

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

好用好用好用

1.      To see how any formula was written inany question or answer, including this one, right-click on the expression itand choose "Show Math As > TeX Commands". (When you do this, the'$' will not display. Make sure you add these. See the next point.)

2.     For inline formulas, enclose the formulain $...$. 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 
ni=0i2=(n2+n)(2n+1)6∑i=0ni2=(n2+n)(2n+1)6 (which isinline mode) or type
$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$
to show

i=0ni2=(n2+n)(2n+1)6∑i=0ni2=(n2+n)(2n+1)6

(which is display mode).

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

4.     For superscripts and subscripts,use ^ and _. For example, x_i^2x2ixi2\log_2 xlog2xlog2x.

5.     Groups. Superscripts,subscripts, and other operations apply only to the next “group”. A “group” iseither a single symbol, or any formula surrounded by curly braces {}. If youdo 10^10, you will get a surprise: 10101010. But 10^{10} gives whatyou probably wanted: 10101010. Use curly braces to delimit a formulato which a superscript or subscript applies: x^5^6 is anerror; {x^y}^z is xyzxyz, and x^{y^z} is xyzxyz. Observe thedifference between x_i^2 x2ixi2 and x_{i^2} xi2xi2.

6.     Parentheses Ordinarysymbols ()[] make parentheses and brackets (2+3)[4+4](2+3)[4+4]. Use \{ and \} for curlybraces {}{}.

These do not scale with the formula in between, so if youwrite (\frac{\sqrt x}{y^3}) the parentheses will be toosmall: (xy3)(xy3). Using \left(\right) will makethe sizes adjust automatically to the formula they enclose: \left(\frac{\sqrtx}{y^3}\right) is (xy3)(xy3).

\left and\right apply toall the following sorts of parentheses: ( and ) (x)(x)[ and ] [x][x]\{ and \} {x}{x}| |x||x|\vert |x||x|\Vert xx\langle and \rangle xx\lceiland \rceil xx, and \lfloor and \rfloor xx. There are alsoinvisible parentheses, denoted by .\left.\frac12\right\rbrace is 12}12}.

7.     Sums and integrals \sum and \int; the subscriptis the lower limit and the superscript is the upper limit, so for example \sum_1^n n1∑1n. Don'tforget {} if the limits are more than a single symbol. For example, \sum_{i=0}^\infty i^2 is i=0i2∑i=0∞i2.Similarly, \prod \int \bigcup \bigcap \iint .

8.     Fractions There aretwo ways to make these. \frac ab applies to the next two groups, and produces abab; for morecomplicated numerators and denominators use {}\frac{a+1}{b+1} is a+1b+1a+1b+1. If thenumerator and denominator are complicated, you may prefer \over, which splitsup the group that it is in: {a+1\over b+1} is a+1b+1a+1b+1.

9.     Fonts

·        Use \mathbb or \Bbb for"blackboard bold": CHNQRZCHNQRZ.

·        Use \mathbf forboldface: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.

·        Use \mathtt for"typewriter" font: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.

·        Use \mathrm for romanfont: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.

·        Use \mathsf forsans-serif font: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz.

·        Use \mathcal for"calligraphic" letters: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ

·        Use \mathscr for scriptletters: ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ

·        Use \mathfrak for"Fraktur" (old German style) letters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.

10.  Radical signs Use sqrt, which adjuststo the size of its argument: \sqrt{x^3} x3−−√x3\sqrt[3]{\frac xy} xy−−3xy3. Forcomplicated expressions, consider using {...}^{1/2} instead.

11.   Some special functions suchas "lim", "sin", "max", "ln", and so onare normally set in roman font instead of italic font. Use \lim\sin, etc. to makethese: \sin x sinxsinx, not sin x sinxsinx. Use subscriptsto attach a notation to \lim\lim_{x\to 0}

limx→0limx0

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

·        \lt \gt \le \ge \neq <>≤≥≠<>≤≥≠. You canuse \not to put a slash through almost anything: \not\lt  but itoften looks bad.

·        \times \div \pm \mp ×÷±×÷±\cdot is acentered dot: xyxy

·        \cup \cap \setminus \subset \subseteq \subsetneq \supset \in \notin\emptyset \varnothing ∖⊂⊆⊊⊃∈∉∅∅∪∩∖⊂⊆⊊⊃∈∉∅

·        {n+1 \choose 2k} or \binom{n+1}{2k} (n+12k)(n+12k)

·        \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 \lhd ∼≃≅,∼≃≅≡≺,.

·        \infty \aleph_0 00 \nabla \partial  \Im \Re IR

·        For modular equivalence, use \pmod likethis: a\equiv b\pmod n ab(modn)ab(modn).

·        \ldots is the dots in a1,a2,…,ana1,a2,…,an \cdots is thedots in a1+a2++ana1+a2++an

·        Some Greek letters have variantforms: \epsilon \varepsilon ϵεϵε\phi \varphi ϕφϕφ, and others.Script lowercase l is \ell .

Detexify lets youdraw a symbol on a web page and then lists the TEXTEX symbolsthat seem to resemble it. These are not guaranteed to work in MathJax but are agood place to start. To check that a command is supported, note thatMathJax.org maintains a list of currentlysupported LATEXLATEX commands, and one can also check Dr. Carol JVFBurns's page of TEXTEXCommands Available in MathJax.

13.  Spaces MathJaxusually 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 spaceMathJax puts in: ab and a␣␣␣␣b are both abab. To add more space, use \, for a thinspace abab\; for awider space abab\quad and \qquad are largespaces: abababab.

To set plaintext, use \text{…}{xsx isextra large}{xsx is extralarge}. You can nest $…$ inside of \text{…}.

14.  Accents and diacritical marks Use \hat for asingle symbol x^x^\widehat for alarger formula xyˆxy^. If you make it too wide, it will looksilly. Similarly, there are \bar x¯ and \overline xyz¯¯¯¯¯¯¯¯xyz¯, and \vec x x and \overrightarrow xy−→xy and \overleftrightarrow xy←→xy. For dots, asin ddxxx˙=x˙2+xx¨ddxxx˙=x˙2+xx¨, use \dot and \ddot.

15.  Special characters used for MathJaxinterpreting can be escaped using the \ character: \$ $$\{ {{\_ __, etc. If youwant \ itself, you should use \backslash , because \\ is for anew line.

 

Matrices

1.      Use $$\begin{matrix}…\end{matrix}$$ In betweenthe \begin and \end, put the matrix elements. End each matrix row with \\, and separatematrix elements with &. For example,

2. $$

3.         \begin{matrix}

4.         1 & x & x^2 \\

5.         1 & y & y^2 \\

6.         1 & z & z^2 \\

7.         \end{matrix}

8. $$

produces:

111xyzx2y2z21xx21yy21zz2

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

9.     To add brackets, either use \left…\right as insection 6 of the tutorial, or replace matrixwith pmatrix (1324)(1234)bmatrix [1324][1234]Bmatrix {1324}{1234}vmatrix ∣∣∣1324∣∣∣|1234|Vmatrix ∥∥∥1324∥∥∥1234.

10.  Use \cdots  \ddots  vdots  when youwant to omit some of the entries:

⎛⎝⎜⎜⎜⎜⎜111a1a2ama21a22a2m⋯⋯⋱⋯an1an2anm⎞⎠⎟⎟⎟⎟⎟(1a1a12a1n1a2a22a2n⋮⋮⋮⋱⋮1amam2amn)

11.   For "augmented" matrices, putparentheses or brackets around a suitably-formatted table; seearrays belowfor details. Here is an example:

[142536][123456]

is produced by:

$$ \left[

    \begin{array}{cc|c}

      1&2&3\\

      4&5&6

    \end{array}

\right] $$

The cc|c is thecrucial part here; it says that there are three centered columns with avertical bar between the second and third.

12.  For small inline matrices use \bigl(\begin{smallmatrix}... \end{smallmatrix}\bigr), e.g.(acbd)(abcd) isproduced by:

13. $\bigl( \begin{smallmatrix} a &b \\ c & d \end{smallmatrix} \bigr)$

 

Aligned equations

Oftenpeople want a series of equations where the equals signs are aligned. To getthis, use \begin{align}…\end{align}. Each lineshould end with \\, and should contain an ampersand atthe point to align at, typically immediately before the equals sign.

For example,

37−−√=732−1122−−−−−−−√=732122⋅732−1732−−−−−−−−−−−√=732122−−−−√732−1732−−−−−−−√=73121−1732−−−−−−−√≈7312(1−12⋅732)37=732−1122=732122⋅732−1732=732122732−1732=73121−1732≈7312(1−12⋅732)

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}

Theusual $$ marksthat delimit the display may be omitted here.

 

 

Definitionsby cases (piecewise functions)

Use \begin{cases}…\end{cases}.End each case with a \\, and use & beforeparts that should be aligned.

For example, you get this:

f(n)={n/2,3n+1,if n isevenif n isoddf(n)={n/2,if n is even3n+1,if n is odd

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 theright:

if n iseven:if n isodd:n/23n+1}=f(n)if n iseven:n/2if n is odd:3n+1}=f(n)

bywriting this:

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

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

f(n)={n2,3n+1,if n isevenif n isoddf(n)={n2,if n is even3n+1,if n is odd

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}

(An‘ex’ is a length equal to the height of the letter x2ex heremeans the space should be two exes high.)

 

 

Arrays

Itis often easier to read tables formatted in MathJax rather than plain text or afixed width font. Arrays and tables are created with the array environment.Just after \begin{array} theformat of each column should be listed, use c fora center aligned column, r forright aligned, l forleft aligned and a | fora vertical line. Just as with matrices, cells are separated with & androws are broken using \\. A horizontal line spanning thearray can be placed before the current line with \hline.

For example,

n123Left0.24−1−20Center11892000Right125−81+10inLeftCenterRight10.2411252−1189−83−2020001+10i

$$
\begin{array}{c|lcr}
n & \text{Left} & \text{Center} & \text{Right} \\
\hline
1 & 0.24 & 1 & 125 \\
2 & -1 & 189 & -8 \\
3 & -20 & 2000 & 1+10i
\end{array}
$$

Arrays can be nested to makean array of tables.

For example,

min012300000101112012230123max012300123111232222333333Δ012300123110122210133210min012300000101112012230123max012300123111232222333333Δ012300123110122210133210

Asthe source for the preceding array is long, please right-click on one of thetables and choose Show Math As  TeX CommandsShow Math As  TeX Commands.

 

Fussyspacing issues

These are issues that won'taffect the correctness of formulas, but might make them look significantlybetter or worse. Beginners should feel free to ignore this advice; someone elsewill correct it for them, or more likely nobody will care.

Don'tuse \frac inexponents or limits of integrals; it looks bad and can be confusing, which iswhy it is rarely done in professional mathematical typesetting. Write thefraction horizontally, with a slash:

Badeiπ2eiπ2∫π2−π2sinxdxBettereiπ/2∫π/2−π/2sinxdxBadBettereiπ2eiπ2eiπ/2∫−π2π2sin⁡xdx∫−π/2π/2sin⁡xdx

The | symbolhas the wrong spacing when it is used as a divider, for example in setcomprehensions. Use \mid instead:

Bad{x|x2∈Z}Better{x∣x2∈Z}BadBetter{x|x2∈Z}{x∣x2∈Z}

Fordouble and triple integrals, don't use \int\int or \int\int\int.Instead use the special forms\iint and \iiint:

Bad∫∫Sf(x)dydx∫∫∫Vf(x)dzdydxBetter∬Sf(x)dydx∭Vf(x)dzdydxBadBetter∫∫Sf(x)dydx∬Sf(x)dydx∫∫∫Vf(x)dzdydx∭Vf(x)dzdydx

Use \, toinsert a thin space before differentials; without this TEXTEX willmash them together:

Bad∭Vf(x)dzdydxBetter∭Vf(x)dzdydx

 

Colors

Named colors arebrowser-dependent; if a browser doesn't know a particular color name, it mayrender the text as black. The following colors are standard in HTML4 and CSS2and should be interpreted the same by most browsers:

\color{black}{text}\color{gray}{text}\color{silver}{text}\color{white}{text}\color{maroon}{text}\color{red}{text}\color{yellow}{text}\color{lime}{text}\color{olive}{text}\color{green}{text}\color{teal}{text}\color{aqua}{text}\color{blue}{text}\color{navy}{text}\color{purple}{text}\color{fuchsia}{text}texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext\color{black}{text}text\color{gray}{text}text\color{silver}{text}text\color{white}{text}text\color{maroon}{text}text\color{red}{text}text\color{yellow}{text}text\color{lime}{text}text\color{olive}{text}text\color{green}{text}text\color{teal}{text}text\color{aqua}{text}text\color{blue}{text}text\color{navy}{text}text\color{purple}{text}text\color{fuchsia}{text}text

HTML5and CSS 3 define anadditional 124 color names that will be supported on many browsers.

Math Stack Exchange's defaultstyle uses a light-colored page background, so avoid using light colors fortext. Stick to darker colors like maroon, green, blue, and purple, and rememberalso that 7–10% of men are color-blind and have difficulty distinguishing redand green.

Thecolor may also have the form #rgb where r,g,br,g,b arein the range or 09af andrepresent the intensity of red, green, and blue on a scale of 0150–15, with a=10, b=11,… f=15.For example:

#000#F00texttext#0F0#FF0texttext#00F#F0Ftexttext#0FF#FFFtexttext#000text#00Ftext#0F0text#0FFtext#F00text#F0Ftext#FF0text#FFFtext

#000#500#A00#F00#080#580#A80#F80#0F0#5F0#AF0#FF0texttexttexttexttexttexttexttexttexttexttexttext#005#505#A05#F05#085#585#A85#F85#0F5#5F5#AF5#FF5texttexttexttexttexttexttexttexttexttexttexttext#00A#50A#A0A#F0A#08A#58A#A8A#F8A#0FA#5FA#AFA#FFAtexttexttexttexttexttexttexttexttexttexttexttext#00F#50F#A0F#F0F#08F#58F#A8F#F8F#0FF#5FF#AFF#FFFtexttexttexttexttexttexttexttexttexttexttexttext

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值