你在这里

怎样输入数学公式

    一、简介

在电脑中输入数学公式, 用任何工具都是比较麻烦的事情, 在网页中输入数学公式更是如此.

本网站用LaTeX的方式来书写数学公式,(所见即所得的工具正在开发中). 用开源的MathJax来作为数学公式显示的方案, MathJax在网页上显示数学公式是很漂亮的,并且不是以图形的方式显示, 甚至可以把公式直接保存到微软的 Office 中直接使用. MathJax显示数学式子使用到了javascript技术, 如果你的网页加载过慢, 刷新一下网页应该就没有问题了.

    二、两种公式显示形式

1.行内显示: 就是公式和你输入的其它文字显示在同一行, 除非你自己换行. 例如: $x+y$,  其实输入的是

$x+y$

只要在两个$输入公式$(美元符号)之间输入你要显示的数学公式就可以在文字的同行中显示数学公式了.

2.单行显示: 输入的数学公式会单独占一行,同一行的前后无法输入文字. 例如: $$x+y$$ 其实输入的是

$$x+y$$

只要在

$$输入公式$$

之间输入你要显示的数学公式, 公式就可以单独占一行.

 

    三、公式和特殊符号的写法

    函数、符号及特殊字符

标准函数  
\sin a \cos b \tan c `\sin a \cos b \tan c`
\sec d \csc e \cot f `\sec d \csc e \cot f`
\arcsin h \arccos i \arctan j `\arcsin h \arccos i \arctan j`
\sinh k \cosh l \tanh m \coth n\! `\sinh k \cosh l \tanh m \coth n\!`

\operatorname{sh}o\,

\operatorname{ch}p\,

\operatorname{th}q\!

`\operatorname{sh}o\,\operatorname{ch}p\,\operatorname{th}q\!`
\operatorname{arsinh}r\,
\operatorname{arcosh}s\,
\operatorname{artanh}t
`\operatorname{arsinh}r\,\operatorname{arcosh}s\,\operatorname{artanh}t  `
\lim u \limsup v \liminf w \min x \max y\! `\lim u \limsup v \liminf w \min x \max y\!`
\inf z \sup a \exp b \ln c \lg d \log e \log_{10} f \ker g\! `\inf z \sup a \exp b \ln c \lg d \log e \log_{10} f \ker g\!`
\deg h \gcd i \Pr j \det k \hom l \arg m \dim n `\deg h \gcd i \Pr j \det k \hom l \arg m \dim n`
模代数  
s_k \equiv 0 \pmod{m} `s_k \equiv 0 \pmod{m}`
a\,\bmod\,b `a\,\bmod\,b`
微分  
\nabla \, \partial x \, dx \, \dot x \, \ddot y\, dy/dx\, \frac{dy}{dx}\, \frac{\partial^2 y}{\partial x_1\,\partial x_2} `\nabla \, \partial x \, dx \, \dot x \, \ddot y\, dy/dx\, \frac{dy}{dx}\, \frac{\partial^2 y}{\partial x_1\,\partial x_2}`
集合  
\forall \exists  \emptyset \varnothing `\forall \exists \emptyset \varnothing`
\in \ni \not \in \notin \subset \subseteq \supset \supseteq `\in \ni \not \in \notin \subset \subseteq \supset \supseteq`
\cap \bigcap \cup \bigcup \biguplus \setminus \smallsetminus `\cap \bigcap \cup \bigcup \biguplus \setminus \smallsetminus`
\sqsubset \sqsubseteq \sqsupset \sqsupseteq \sqcap \sqcup \bigsqcup `\sqsubset \sqsubseteq \sqsupset \sqsupseteq \sqcap \sqcup \bigsqcup`
运算符  
+ \oplus \bigoplus \pm \mp - `+ \oplus \bigoplus \pm \mp -`
\times \otimes \bigotimes \cdot \circ \bullet \bigodot `\times \otimes \bigotimes \cdot \circ \bullet \bigodot`
\star * / \div \frac{1}{2} `\star * / \div \frac{1}{2}`
逻辑符号  
\land  \wedge \bigwedge \bar{q} \to p `\land  \wedge \bigwedge \bar{q} \to p`
\lor \vee \bigvee \lnot \neg q \And `\lor \vee \bigvee \lnot \neg q \And`
根号  
\sqrt{x} \sqrt[n]{x} `\sqrt{x} \sqrt[n]{x}`
关系符号  
\sim \approx \simeq \cong \dot= \overset{\underset{\mathrm{def}}{}}{=} `\sim \approx \simeq \cong \dot= \overset{\underset{\mathrm{def}}{}}{=}`
< \le \ll \gg \ge > \equiv \not\equiv \ne \mbox{or} \neq \propto `< \le \ll \gg \ge > \equiv \not\equiv \ne \mbox{or} \neq \propto`
\lessapprox \lesssim \eqslantless \leqslant \leqq \geqq \geqslant \eqslantgtr \gtrsim \gtrapprox `\lessapprox \lesssim \eqslantless \leqslant \leqq \geqq \geqslant \eqslantgtr \gtrsim \gtrapprox`
几何符号  
\Diamond \Box \triangle \angle \perp \mid \nmid \| 45^\circ `\Diamond \Box \triangle \angle \perp \mid \nmid \| 45^\circ`
箭头  
\leftarrow (or \gets) \rightarrow (or \to) \nleftarrow \nrightarrow \leftrightarrow \nleftrightarrow \longleftarrow \longrightarrow \longleftrightarrow `\leftarrow (or \gets) \rightarrow (or \to) \nleftarrow \nrightarrow \leftrightarrow \nleftrightarrow \longleftarrow \longrightarrow \longleftrightarrow`
\Leftarrow \Rightarrow \nLeftarrow \nRightarrow \Leftrightarrow \nLeftrightarrow \Longleftarrow \Longrightarrow \Longleftrightarrow (or \iff) `\Leftarrow \Rightarrow \nLeftarrow \nRightarrow \Leftrightarrow \nLeftrightarrow \Longleftarrow \Longrightarrow \Longleftrightarrow (or \iff)`
\uparrow \downarrow \updownarrow \Uparrow \Downarrow \Updownarrow \nearrow \searrow \swarrow \nwarrow `\uparrow \downarrow \updownarrow \Uparrow \Downarrow \Updownarrow \nearrow \searrow \swarrow \nwarrow`
\rightharpoonup \rightharpoondown \leftharpoonup \leftharpoondown \upharpoonleft \upharpoonright \downharpoonleft \downharpoonright \rightleftharpoons \leftrightharpoons `\rightharpoonup \rightharpoondown \leftharpoonup \leftharpoondown \upharpoonleft \upharpoonright \downharpoonleft \downharpoonright \rightleftharpoons \leftrightharpoons`
\curvearrowleft \circlearrowleft \Lsh \upuparrows \rightrightarrows \rightleftarrows \Rrightarrow \rightarrowtail \looparrowright `\curvearrowleft \circlearrowleft \Lsh \upuparrows \rightrightarrows \rightleftarrows \Rrightarrow \rightarrowtail \looparrowright`
\curvearrowright \circlearrowright \Rsh \downdownarrows \leftleftarrows \leftrightarrows \Lleftarrow \leftarrowtail \looparrowleft `\curvearrowright \circlearrowright \Rsh \downdownarrows \leftleftarrows \leftrightarrows \Lleftarrow \leftarrowtail \looparrowleft`
\mapsto \longmapsto \hookrightarrow \hookleftarrow \multimap \leftrightsquigarrow \rightsquigarrow `\mapsto \longmapsto \hookrightarrow \hookleftarrow \multimap \leftrightsquigarrow \rightsquigarrow`

    上标, 下标, 积分.......

功能 语法 效果
上标 a^2 `a^2`
下标 a_2 `a_2`
组合 a^{2+2}, a_{i,j} `a^{2+2}, a_{i,j}`
结合上下标 x_2^3 `x_2^3`
前置上下标 {}_1^2\!X_3^4 `{}_1^2\!X_3^4`
导数 x' `x'`
导数点 \dot{x}, \ddot{y} `\dot{x}, \ddot{y}`
矢量 \vec{c},\overleftarrow{a b},\overrightarrow{c d} `\vec{c},\overleftarrow{a b},\overrightarrow{c d}`
上弧 \overset{\frown} {AB} `\overset{\frown} {AB}`
上划线 \overline{h i j} `\overline{h i j}`
下划线 \underline{k l m} `\underline{k l m}`
上括号1 \overbrace{1+2+\cdots+100} `\overbrace{1+2+\cdots+100}`
上括号2
\begin{matrix} 5050 \\ \overbrace{ 1+2+\cdots+100 } \end{matrix}
\begin{matrix} 5050 \\ \overbrace{ 1+2+\cdots+100 } \end{matrix}
下括号1 \underbrace{a+b+\cdots+z} `\underbrace{a+b+\cdots+z}`
下括号2
\begin{matrix} \underbrace{ a+b+\cdots+z } \\ 26 \end{matrix}
\begin{matrix} \underbrace{ a+b+\cdots+z } \\ 26 \end{matrix}
求和1 \sum_{k=1}^N k^2 `\sum_{k=1}^N k^2`
求和2
\begin{matrix} \sum_{k=1}^N k^2 \end{matrix}
\begin{matrix} \sum_{k=1}^N k^2 \end{matrix}
求积1 \prod_{i=1}^N x_i `\prod_{i=1}^N x_i`
求积2
\begin{matrix} \prod_{i=1}^N x_i \end{matrix}
\begin{matrix} \prod_{i=1}^N x_i \end{matrix}
上积1 \coprod_{i=1}^N x_i `\coprod_{i=1}^N x_i`
上积2
\begin{matrix} \coprod_{i=1}^N x_i \end{matrix}
\begin{matrix} \coprod_{i=1}^N x_i \end{matrix}
极限1 \lim_{n \to \infty}x_n `\lim_{n \to \infty}x_n`
极限2
\begin{matrix} \lim_{n \to \infty}x_n \end{matrix}
\begin{matrix} \lim_{n \to \infty}x_n \end{matrix}
积分1 \int_{-N}^{N} e^x\, dx `\int_{-N}^{N} e^x\, dx`
积分2
\begin{matrix} \int_{-N}^{N} e^x\, dx \end{matrix}
\begin{matrix} \int_{-N}^{N} e^x\, dx \end{matrix}
双重积分 \iint_{D}^{W} \, dx\,dy `\iint_{D}^{W} \, dx\,dy`
三重积分 \iiint_{E}^{V} \, dx\,dy\,dz `\iiint_{E}^{V} \, dx\,dy\,dz`
四重积分 \iiiint_{F}^{U} \, dx\,dy\,dz\,dt `\iiiint_{F}^{U} \, dx\,dy\,dz\,dt`
闭合的曲线、曲面积分 \oint_{C} x^3\, dx + 4y^2\, dy `\oint_{C} x^3\, dx + 4y^2\, dy`
交集 \bigcap_1^{n} p `\bigcap_1^{n} p`
并集 \bigcup_1^{k} p `\bigcup_1^{k} p`

    分数, 矩阵, 多行列式.......

功能 语法 效果
分数 \frac{2}{4}=0.5 `\frac{2}{4}=0.5`
小型分数 \tfrac{2}{4} = 0.5 `\tfrac{2}{4} = 0.5`
大型分数(嵌套) \cfrac{2}{c + \cfrac{2}{d + \cfrac{2}{4}}} = a `\cfrac{2}{c + \cfrac{2}{d + \cfrac{2}{4}}} = a`
大型分数(不嵌套) \dfrac{2}{4} = 0.5 \qquad \dfrac{2}{c + \dfrac{2}{d + \dfrac{2}{4}}} = a `\dfrac{2}{4} = 0.5 \qquad \dfrac{2}{c + \dfrac{2}{d + \dfrac{2}{4}}} = a`
二项式系数 \dbinom{n}{r}=\binom{n}{n-r}=C^n_r=C^n_{n-r} `\dbinom{n}{r}=\binom{n}{n-r}=C^n_r=C^n_{n-r}`
小型二项式系数 \tbinom{n}{r}=\tbinom{n}{n-r}=C^n_r=C^n_{n-r} `\tbinom{n}{r}=\tbinom{n}{n-r}=C^n_r=C^n_{n-r}`
大型二项式系数 \binom{n}{r}=\dbinom{n}{n-r}=C^n_r=C^n_{n-r} `\binom{n}{r}=\dbinom{n}{n-r}=C^n_r=C^n_{n-r}`
矩阵1
\begin{matrix} x & y \\ z & v \end{matrix}
\begin{matrix} x & y \\ z & v \end{matrix}
矩阵2
\begin{vmatrix} x & y \\ z & v \end{vmatrix}
\begin{vmatrix} x & y \\ z & v \end{vmatrix}
矩阵3
\begin{Vmatrix} x & y \\ z & v \end{Vmatrix}
\begin{Vmatrix} x & y \\ z & v \end{Vmatrix}
矩阵4
\begin{bmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0 \end{bmatrix}
\begin{bmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0 \end{bmatrix}
矩阵5
\begin{Bmatrix} x & y \\ z & v \end{Bmatrix}
\begin{Bmatrix} x & y \\ z & v \end{Bmatrix}
矩阵6
\begin{pmatrix} x & y \\ z & v \end{pmatrix}
\begin{pmatrix} x & y \\ z & v \end{pmatrix}
矩阵7
\bigl( \begin{smallmatrix} a&b\\ c&d \end{smallmatrix} \bigr)
`\bigl( \begin{smallmatrix} a&b\\ c&d \end{smallmatrix} \bigr)`
条件定义
f(n) = \begin{cases} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{cases}
`f(n) =` \begin{cases} n/2, & \mbox{if }n\mbox{ is even} \\ 3n+1, & \mbox{if }n\mbox{ is odd} \end{cases}
多行等式1
\begin{align} f(x) & = (m+n)^2 \\ & = m^2+2mn+n^2 \\ \end{align}
\begin{align} f(x) & = (m+n)^2 \\ & = m^2+2mn+n^2 \\ \end{align}
多行等式2
\begin{alignat}{2} f(x) & = (m-n)^2 \\ f(x) & = (-m+n)^2 \\ & = m^2-2mn+n^2 \\ \end{alignat}
\begin{alignat}{2} f(x) & = (m-n)^2 \\ f(x) & = (-m+n)^2 \\ & = m^2-2mn+n^2 \\ \end{alignat}
多行等式(左对齐)
\begin{array}{lcl} z & = & a \\ f(x,y,z) & = & x + y + z \end{array}
\begin{array}{lcl} z & = & a \\ f(x,y,z) & = & x + y + z \end{array}
多行等式(右对齐)
\begin{array}{lcr} z & = & a \\ f(x,y,z) & = & x + y + z \end{array}
\begin{array}{lcr} z & = & a \\ f(x,y,z) & = & x + y + z \end{array}
方程组
\begin{cases} 3x + 5y + z \\ 7x - 2y + 4z \\ -6x + 3y + 2z \end{cases}
\begin{cases} 3x + 5y + z \\ 7x - 2y + 4z \\ -6x + 3y + 2z \end{cases}
数组
\begin{array}{|c|c||c|} a & b & S \\ \hline 0&0&1\\ 0&1&1\\ 1&0&1\\ 1&1&0\\ \end{array}
\begin{array}{|c|c||c|} a & b & S \\ \hline 0&0&1\\ 0&1&1\\ 1&0&1\\ 1&1&0\\ \end{array}

    小写希腊字母

功能 语法 效果
小写字母 \alpha \beta \gamma \delta \epsilon \zeta \eta \theta `\alpha \beta \gamma \delta \epsilon \zeta \eta \theta`
  \iota \kappa \lambda \mu \nu \xi \omicron \pi `\iota \kappa \lambda \mu \nu \xi \omicron \pi`
  \rho \sigma \tau \upsilon \phi \chi \psi \omega `\rho \sigma \tau \upsilon \phi \chi \psi \omega`

    括号

功能 语法 效果
短括号 ( \frac{1}{2} ) `( \frac{1}{2} )`
长括号 \left( \frac{1}{2} \right) `\left( \frac{1}{2} \right)`
圆括号,小括号 \left( \frac{a}{b} \right) `\left( \frac{a}{b} \right)`
方括号,中括号 \left[ \frac{a}{b} \right] `\left[ \frac{a}{b} \right]`
花括号,大括号 \left\{ \frac{a}{b} \right\} `\left\{ \frac{a}{b} \right\}`
角括号 \left \langle \frac{a}{b} \right \rangle `\left \langle \frac{a}{b} \right \rangle`
单竖线,绝对值 \left| \frac{a}{b} \right| `\left| \frac{a}{b} \right|`
双竖线,范 \left \| \frac{a}{b} \right \| `\left \| \frac{a}{b} \right \|`
取整函数 \left \lfloor \frac{a}{b} \right \rfloor `\left \lfloor \frac{a}{b} \right \rfloor`
取顶函数 \left \lceil \frac{c}{d} \right \rceil `\left \lceil \frac{c}{d} \right \rceil`
单左括号 \left \{ \frac{a}{b} \right . `\left \{ \frac{a}{b} \right .`
单右括号 \left . \frac{a}{b} \right \} `\left . \frac{a}{b} \right \}`

    特殊符号写法

\And \eth \S \% \dagger \ddagger \ldots \cdots `\And \eth \S \% \dagger \ddagger \ldots \cdots`
\smile \frown \wr \triangleleft \triangleright \infty \bot \top `\smile \frown \wr \triangleleft \triangleright \infty \bot \top`
\vdash \vDash \Vdash \models \lVert \rVert \imath \hbar `\vdash \vDash \Vdash \models \lVert \rVert \imath \hbar`
\ell \mho \Finv \Re \Im \wp \complement `\ell \mho \Finv \Re \Im \wp \complement`
\diamondsuit \heartsuit \clubsuit \spadesuit \Game \flat \natural \sharp `\diamondsuit \heartsuit \clubsuit \spadesuit \Game \flat \natural \sharp`
\vartriangle \triangledown \lozenge \circledS \measuredangle \nexists \Bbbk \backprime \blacktriangle \blacktriangledown `\vartriangle \triangledown \lozenge \circledS \measuredangle \nexists \Bbbk \backprime \blacktriangle \blacktriangledown`
\blacksquare \blacklozenge \bigstar \sphericalangle \diagup \diagdown \dotplus \Cap \Cup \barwedge `\blacksquare \blacklozenge \bigstar \sphericalangle \diagup \diagdown \dotplus \Cap \Cup \barwedge`
\veebar \doublebarwedge \boxminus \boxtimes \boxdot \boxplus \divideontimes \ltimes \rtimes \leftthreetimes `\veebar \doublebarwedge \boxminus \boxtimes \boxdot \boxplus \divideontimes \ltimes \rtimes \leftthreetimes`
\rightthreetimes \curlywedge \curlyvee \circleddash \circledast \circledcirc \centerdot \intercal \leqq \leqslant `\rightthreetimes \curlywedge \curlyvee \circleddash \circledast \circledcirc \centerdot \intercal \leqq \leqslant`
\eqslantless \lessapprox \approxeq \lessdot \lll \lessgtr \lesseqgtr \lesseqqgtr \doteqdot \risingdotseq `\eqslantless \lessapprox \approxeq \lessdot \lll \lessgtr \lesseqgtr \lesseqqgtr \doteqdot \risingdotseq`
\fallingdotseq \backsim \backsimeq \subseteqq \Subset \preccurlyeq \curlyeqprec \precsim \precapprox \vartriangleleft `\fallingdotseq \backsim \backsimeq \subseteqq \Subset \preccurlyeq \curlyeqprec \precsim \precapprox \vartriangleleft`
\Vvdash \bumpeq \Bumpeq \eqsim \gtrdot `\Vvdash \bumpeq \Bumpeq \eqsim \gtrdot`
\ggg \gtrless \gtreqless \gtreqqless \eqcirc \circeq \triangleq \thicksim \thickapprox \supseteqq `\ggg \gtrless \gtreqless \gtreqqless \eqcirc \circeq \triangleq \thicksim \thickapprox \supseteqq`
\Supset \succcurlyeq \curlyeqsucc \succsim \succapprox \vartriangleright \shortmid \between \shortparallel \pitchfork `\Supset \succcurlyeq \curlyeqsucc \succsim \succapprox \vartriangleright \shortmid \between \shortparallel \pitchfork`
\varpropto \blacktriangleleft \therefore \backepsilon \blacktriangleright \because \nleqslant \nleqq \lneq \lneqq `\varpropto \blacktriangleleft \therefore \backepsilon \blacktriangleright \because \nleqslant \nleqq \lneq \lneqq`
\lvertneqq \lnsim \lnapprox \nprec \npreceq \precneqq \precnsim \precnapprox \nsim \nshortmid `\lvertneqq \lnsim \lnapprox \nprec \npreceq \precneqq \precnsim \precnapprox \nsim \nshortmid`
\nvdash \nVdash \ntriangleleft \ntrianglelefteq \nsubseteq \nsubseteqq \varsubsetneq \subsetneqq \varsubsetneqq \ngtr `\nvdash \nVdash \ntriangleleft \ntrianglelefteq \nsubseteq \nsubseteqq \varsubsetneq \subsetneqq \varsubsetneqq \ngtr`
\subsetneq `\subsetneq`
\ngeqslant \ngeqq \gneq \gneqq \gvertneqq \gnsim \gnapprox \nsucc \nsucceq \succneqq `\ngeqslant \ngeqq \gneq \gneqq \gvertneqq \gnsim \gnapprox \nsucc \nsucceq \succneqq`
\succnsim \succnapprox \ncong \nshortparallel \nparallel \nvDash \nVDash \ntriangleright \ntrianglerighteq \nsupseteq `\succnsim \succnapprox \ncong \nshortparallel \nparallel \nvDash \nVDash \ntriangleright \ntrianglerighteq \nsupseteq`
\nsupseteqq \varsupsetneq \supsetneqq \varsupsetneqq `\nsupseteqq \varsupsetneq \supsetneqq \varsupsetneqq`
\jmath \surd \ast \uplus \diamond \bigtriangleup \bigtriangledown \ominus `\jmath \surd \ast \uplus \diamond \bigtriangleup \bigtriangledown \ominus`
\oslash \odot \bigcirc \amalg \prec \succ \preceq \succeq `\oslash \odot \bigcirc \amalg \prec \succ \preceq \succeq`
\dashv \asymp \doteq \parallel `\dashv \asymp \doteq \parallel`
\ulcorner \urcorner \llcorner \lrcorner `\ulcorner \urcorner \llcorner \lrcorner`

更多关于TEX数学公式的写法: 请下载

也可以参考维基百科.