环境
环境是指 \begin{...} ... \end{...} 这样的东西,环境在真 LaTeX 中不一定要用来打公式,但这里我们只讲跟公式输入有关的常用环境。
多行公式输入环境
最常用的:align 或 align* 或 aligned
第一个会对每行公式自动编号,第二个则不编号,第三个属于“次环境”暂时不介绍(其实是不知怎么说)。
例:如下代码
\begin{align}
f(x) & = ax^2+bx+c\\
& = a(x-x_1)(x-x_2)\\
& = \cdots
\end{align}
将显示
f(x)=ax2+bx+c=a(x−x1)(x−x2)=⋯
注:在 & 处对齐,\\ 为换行,最后一行后面不必再换行。
如果不想某些编号,可以在该行的公式后 \\ 前加 \notag;如果想引用编号,要先在该行公式中加入标签 \label{...} 然后引用时用 \eqref{...},花号里可填任意的英文或数字(冒号什么的好像也可以,但建议不要用别的符号以免出问题)。下面也演示一下:
代码:
\begin{align}
f(x) & = ax^2+bx+c \notag \\
& = a(x-x_1)(x-x_2) \label{asdf01234} \\
& = \cdots
\end{align}
将显示
f(x)=ax2+bx+c=a(x−x1)(x−x2)=⋯
可以看到,第一行没编号了,现在要引用第二行的编号,只要输入 \eqref{asdf01234} 即得 (4)。
这种引用的好处在于那些号码是自动编的,也就是说即使前面突然增加或减少一些公式的编号,编号数字变化时引用也跟着自动变更,不需要手动去改那数字。而且还可以点击跳转,大家不妨试试。
此外,单个行间公式需编号时,可以用 equation 环境,引用方法同上。
\begin{equation}\label{csineq}
\left(\sum_{k=1}^na_kb_k\right)^2\le\left(\sum_{k=1}^na_k^2\right)\left(
\sum_{k=1}^nb_k^2\right).
\end{equation}
显示
(n∑k=1akbk)2≤(n∑k=1a2k)(n∑k=1b2k).
用 \eqref{csineq} 来引用:式 (6) 称为 Cauchy-Schwarz 不等式(不知有没有拼错,我总是不记得这些极难记的英文名字)。
多行公式全部居中:gather 或 gather* 或 gathered
跟 align 基本类似,但是全部居中对齐,所以里面无需用 & 。
例:如下代码
\begin{gather}
f(x) = ax^2+bx+c+00\\
= a(x-x_1)(x-x_2)\\
= \cdots
\end{gather}
将显示
f(x)=ax2+bx+c+00=a(x−x1)(x−x2)=⋯
LATEX 公式输入基础教程(二)
2016年9月01日 23:12
LATEX 公式输入基础教程(一)
2016年9月01日 22:38
温馨提示:
1、带星号*的段落可能不易理解,初学者可以先忽略;
2、由于本贴内容较多,打开本页时可能会卡,最好稍等一下待公式显示完了再看;
首先介绍两个术语——“行内公式”和“行间公式”。
行内公式,亦称为随文模式(inline mode),是将公式镶嵌在普通文段内,就像 c2=a2+b2 这样,跟文字排在一起,谓之“随文”。
行间公式,亦称为展示模式(display mode),是将公式独立并且居中展示,就像下面这个公式这样
c2=a2+b2
行间公式通常用来显示文中相对重点的或者较为复杂的公式,同时还可以使其自动编号,以方便其他地方进行引用,就像下面这样
c2=a2+b2
式 (10) 叫勾股定理。
其实,“随文模式”、“展示模式”这两个名称是更加准确的,只不过一直以来我都叫惯了“行内”、“行间”,所以这里仍然用旧称呼。
下面开始讲具体输入。
1、行内公式的输入格式:
$公式代码$ 或者 \(公式代码\)
通常我们用前者。美元符号 $ 为纯英文输入法状态下按 Shift+4 所得。
例 1.1:$a^2+x_3=C_n^m$ 显示 a2+x3=Cmn
例 1.2:$a_n+1=a_{n+1}+\sqrt{n}+\frac{1}{n}$ 显示 an+1=an+1+√n+1n
例 1.3:$\sum_{k=1}^n\frac{1}{k^2}=\frac{\pi^2}{6}$ 显示 ∑nk=11k2=π26
2、行间公式的输入格式:
\[公式代码\] 或者 $$公式代码$$ *或者使用环境(\begin{...}...\end{...})
我们提倡用前者。反斜杠 \ 在台式机键盘在F11下边,也要在纯英文输入法状态下 输入。使用环境留到后面再详讲。
将上面三例的 $...$ 都换成 \[...\] 得到:
例 2.1:\[a^2+x_3=C_n^m\] 显示 a2+x3=Cmn 例 2.2:\[a_n+1=a_{n+1}+\sqrt{n}+\frac{1}{n}\] 显示 an+1=an+1+√n+1n 例 2.3:\[\sum_{k=1}^n\frac{1}{k^2}=\frac{\pi^2}{6}\] 显示 n∑k=11k2=π26
*最后来一个用环境输入的多行公式,例 2.4:
\begin{align*}
f(x) & = ax^2+bx+c\\
& = a(x-x_1)(x-x_2)\\
& = a\left( x-\frac{-b+\sqrt{b^2-4ac}}{2a} \right)\left( x-\frac{-b-\sqrt{b^2-4ac}}{2a} \right)
\end{align*}
显示
f(x)=ax2+bx+c=a(x−x1)(x−x2)=a(x−−b+√b2−4ac2a)(x−−b−√b2−4ac2a)
3、常用的公式代码表以及需要注意的细节
N年没来了,回来瞧瞧
2016年9月01日 22:31
闲着没事,回来瞧瞧这个博客,有的博文已经过时,删掉,发新的。
以前有篇讲建议自己配置MathJax的,其实是多余的,因为一般用户不必,而有需要的自然自己也会去配置。
那么这里顺便存档一下我现在的MathJax配置方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <script type= "text/x-mathjax-config" > MathJax.Hub.Config({ tex2jax: { inlineMath: [ [ '$' , '$' ], [ "\\(" , "\\)" ] ], processEscapes: true }, TeX: { equationNumbers: { autoNumber: "AMS" }, Macros: { mbb: '\\mathbb' , riff: '\\implies' , liff: '\\impliedby' , abs: [ '\\left\\lvert #1\\right\\rvert' , 1], rmd: '\\mathop{}\\!\\mathrm{d}' , vv: '\\overrightarrow' , sslash: '\\mathrel{/\\mkern-5mu/}' , px: '\\mathrel{/\\mkern-5mu/}' , pqd: '\\stackrel{\\,\\sslash}{\\raise-.5ex{=\\!\\!\\!\\!=}}' , veps: '\\varepsilon' , du: '^\\circ' , bsb: '\\boldsymbol' , bm: '\\boldsymbol' , kongji: '\\varnothing' , buji: '\\complement' , S: [ 'S_{\\triangle #1}' , 1], led: '\\left\\{\\begin{aligned}' , endled: '\\end{aligned}\\right.' , edr: '\\left.\\begin{aligned}' , endedr: '\\end{aligned}\\right\\}' , an: '\\{a_n\\}' , bn: '\\{b_n\\}' , cn: '\\{c_n\\}' , xn: '\\{x_n\\}' , Sn: '\\{S_n\\}' , inR: '\\in\\mbb R' , inN: '\\in\\mbb N' , inZ: '\\in\\mbb Z' , inC: '\\in\\mbb C' , inQ: '\\in\\mbb Q' , Rtt: '\\text{Rt}\\triangle' } }, "HTML-CSS" : { linebreaks: {automatic: true } }, menuSettings: { zoom: "Double-Click" } }); </script> <script type= "text/javascript" </script> |
其实存的主要就是那些自定义命令。
灰常幸运地说,才加入这里两天,就升级支持MathJax了,这东东我熟行
2012年3月21日 11:42
数月前,当我知道有MathJax这一东东之后我就申请了一个免费论坛来试玩,效果还真可以,那时的MathJax还是1.0,现在都2.0了。而前两天搜东西的时候无意中找到这里来,看到说即将支持MathJax,我马上就又注册来玩了,没想到就两天,就真升级了
MathJax的公式输入方法等等的东东在我论坛已经试验过了,具体见:
http://kkkkuingggg.5d6d.com/thread-9-1-1.html
http://kkkkuingggg.5d6d.com/thread-33-1-1.html
等……
上述链接里的东东是在MathJax1.0的时候弄的,现在可能会有一点点不同,不过大致上没分别。
当然了,在这里还是要试试看:a2+b2=c2,a2+b2=c2,x1,2=−b±√4ac−b2⋅i2a
1 | $a^2+b^2=c^2$, \ (a^2+b^2=c^2 \ ), \ [x_{1,2}= \frac {-b \pm \sqrt {4ac-b^2} \cdot i}{2a} \ ] |
直接将我那里的表格复制过来看看:
基本常用符号对应代码表:
winedt的正则表达式系统
2012年3月20日 22:11
汗,看了一下帮助文件,跟一般的那些差别有点大MS,而且对着英文就,还是翻译一下再说……
发上来,再用google在线翻译,再略加修改得
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | > Matches the end of a line. < Matches the beginning of a line. ? Matches any single character. . Matches any single character (possibly none). * Matches any string (including empty) within one line. ** Matches any string (possibly extending over one line). + Matches one or more occurrences of the next expression. @ Matches any number of occurrences of the next expression (including none). | OR ~ NOT ^ NOT + skip the pattern { } Group Braces Group of Expressions. Groups can be nested inside patterns... [-] Range For example, [a-z] (the same as $Lower$). [ ] Set For example, [abc] matches a,b, or c. $ $ Alternative Set Definition Allows set expressions and accepts Filter Sets defined in the Highlighting Dialog. For example: $~Alpha$ $[#0..#31]$ $[ "@+-" ]$ $Alpha+Numeric-[ "0" ]$ $Lower+Upper+[ "1" .. "9" ]$ \ (x \ ) Tagged Expression (x in the range 0..9; 0 is the default) \x Tag (x in the range 0..9) \ ? Matches ?. ? is any char except for (,0..9,),", and # used for tags, ANSI Strings and RegEx prefix, respectively. For example, \ > matches > rather than the end of line. The following characters have a special meaning (as described above) and they have to be escaped (preceded by a backslash) when used as ordinary characters inside a regular expression: \ [ ] { } < > $ ? . * + @ | ~ For example, the string \begin {array} inside a regular expression must be specified as \ \begin \ {array \ }. > 匹配一行的末尾。 < 匹配行的开头。 ? 匹配任何单个字符。 . 匹配任何单个字符(可能没有)。 * 匹配字符串(包括空)内的任何一条线。 ** 匹配任何字符串(可能延长线以上)。 + 匹配一个或多个出现的下一个表达式。 @ 匹配任意数量的表达(包括无)发生。 | 或 ~ 不 ^ 不+跳过模式 { } 集团 表达式括号集团。组可以嵌套模式... [-] 范围 例如,[a-z] (the same as $Lower$) [ ] 设置 例如,[abc] 匹配 a,b,或c。 $ $ 另一套定义 允许集表达式和接受过滤器设置在突出的对话框中定义。例如: $~Alpha$ $[#0..#31]$ $[ "@+-" ]$ $Alpha+Numeric-[ "0" ]$ $Lower+Upper+[ "1" .. "9" ]$ \ (x \ ) 标记的表达(x的取值范围为0 .. 9; 0是默认值) \x 标记(x范围为0 .. 9) \ ? 匹配 ? ? 任何字符(0 .. 9)," 和 # 标签的使用,ANSI字符串和正则表达式的前缀,分别除外。 例如, \ > 匹配 > 而不是匹配行结束。 以下字符有特殊含义(如上所述),他们可以逃脱(前面加一个反斜杠)作为一个正则表达式内的普通字符使用时: \ [ ] { } < > $ ? . * + @ | ~ 例如,字符串 \begin {array} 在一个正则表达式必须指定 \ \begin \ {array \ }。 |