LaTex学习笔记——LaTeX公式换行

ps.  1、“!” 表示其前后字符之间无间隙

       2、暂留

       3、段落中的数学表达式应该置于( 和), $ 和$ 或者begin{math} 和end{math} 之间。

       4、对于较大的数学式子,最好的方法是使用显示式样来排版:将它们放置于[ 和]或begin{displaymath} 和end{displaymath}之间。这样排版出的公式是没有编号的。如果你希望LATEX 对其添加编号的话,可以使用equation环境来达到这一目的。

       5、特殊字符:下面的这些字符是LATEX 的保留字符,它们或在LATEX 中有特定的用处,或不一定包含在所有的字库中。如果你直接在文本中使用它们,通常在排版结果中将不会得到这些字符,而且还会导致LATEX 做一些你不希望发生的事情。
# $ % ^ & _ { } ~         当然,这些字符前面加上反斜线,就可以在文本中得到它们。另外一些符号可以由特殊的命令或作为重音命令得到。反斜线不能够通过在其前添加另外的反斜线来得到,相反的, 是一个用来断行的命令。

       6、命令overline 和underline 在表达式的上、下方画出水平线。
$overline{m+n}$ qquad
$underline{m+n}$

       7、命令overbrace 和underbrace 在表达式的上、下方给出一水平的大括号。
$underbrace{ a+b+cdots+z }_{26}$

       8、向量(Vectors)通常用上方有小箭头(arrow symbols)的变量表示。这可由vec 得到。另两个命令overrightarrow 和overleftarrow
在定义从A 到B 的向量时非常有用。
egin{displaymath}
vec a quad overrightarrow{AB}
end{displaymath}

       9、乘法算式中的圆点符可以省略。然而有时为了帮助读者解读复杂的公式,也有必要用命令cdot 将圆点符表示出来。
egin{displaymath}
v = {sigma}_1 cdot {sigma}_2
{ au}_1 cdot { au}_2
end{displaymath}

       10、函数名通常用罗马字体正体排版,而不是像变量名一样用意大利体排版。因此,LATEX提供下述命令来排版最重要的一些函数名。
arccos cos csc exp ker limsup min
arcsin cosh deg gcd lg ln Pr
arctan cot det hom lim log sec
arg coth dim inf liminf max sin
sinh sup tan tanh

[lim_{x ightarrow 0}
frac{sin x}{x}=1]

       11、排版二项系数或类似的结构可以使用命令{... choose ...} 或{... atop ...}。第二个命令与第一个命令的输出相同,只是没有括
号。
egin{displaymath}
{n choose k}qquad {x atop y+2}
end{displaymath}

       12、积分运算符(integral operator)用int 来生成。求和运算符(sum operator)由sum 生成。乘积运算符(product operator)由prod 生成。上限和下限用^ 和_ 来生成,类似于上标和下标。
egin{displaymath}
sum_{i=1}^{n} qquad
int_{0}^{frac{pi}{2}} qquad
prod_epsilon
end{displaymath}

       13、对于括号(braces)和其它分隔符(delimiters),在TEX中有各种各样的符号(例如[ h k l)。圆括号和方括号可以用相应的键输入。花括号用{。其它的分隔符用专门命令(例如updownarrow)来生成。

       14、将三个圆点(three dots)输入公式可以使用几种命令。ldots 将点排在基线上。cdots 将它们设置为居中。除此之外,可用vdots 命令使其垂直,而用ddots 将得到对角型(diagonal dots)。
egin{displaymath}
x_{1},ldots,x_{n} qquad
x_{1}+cdots+x_{n}
end{displaymath}

       15、如果公式中由TEX选择的的空格不令人满意,可以通过插入特殊的空格命令来进行调节。有几个命令用于小空格: ,对应于3/18 quad ( ),:对应于4/18 quad ( ),;对应于5/18 quad ( )。脱离的空格符号 生成中等大小的空格。quad ( ) 和qquad ( ) 产生大空格。quad 的大小对应于目前字体中字符‘M’ 的宽度。! 命令生成负空格-3/18 quad ( )。
ewcommand{ud}{mathrm{d}}
egin{displaymath}
int!!!int_{D} g(x,y)
, ud x, ud y
end{displaymath}
instead of
egin{displaymath}
intint_{D} g(x,y)ud x ud y
end{displaymath}

       16、排版arrays 使用array 环境来排版矩阵(arrays)。它有些类似于tabular环境,使用 命令来分行。
egin{displaymath}
mathbf{X} =
left( egin{array}{ccc}
x_{11} & x_{12} & ldots
x_{21} & x_{22} & ldots
vdots & vdots & ddots
end{array} ight)
end{displaymath}

array 环境也可以使用“.” 作为隐藏右分隔符来排版只有一个大分隔符的表达式。
egin{displaymath}
y = left{ egin{array}{ll}
a & textrm{if $d>c$}
b+x & textrm{in the morning}
l & textrm{all day long}
end{array} ight.
end{displaymath}
像在tabular 环境中一样,也可以在array 环境中画线。例如分隔矩阵中的元素。
egin{displaymath}
left(egin{array}{c|c}
1 & 2
hline
3 & 4
end{array}right)
end{displaymath}
对于分布于几行的公式或者方程组(equation system),可以使用eqnarray 和eqnarray* 环境来代替equation。在eqnarray 中,每一行都会有一个方程编号。eqnarray* 不对方程进行编号。eqnarray 和eqnarray* 环境类似于{rcl} 形式的三列表格。中间的一列可以用作等号或不等号,或者其它看起来适合的符号。使用 命令分行。
egin{eqnarray}
f(x) & = & cos x
f'(x) & = & -sin x
int_{0}^{x} f(y)dy &
= &sin x
end{eqnarray}

       17、在LATEX中很难得到粗体符号。这也许是故意的,因为业余排版者总是过份使用粗体。字体改变命令mathbf 给出粗体字母,但是这些是罗马字体(竖直的),而数学符号通常是斜体。有一个boldmath 命令,但是这只能用于数学模式之外。对于符号也是如此。
egin{displaymath}
mu, M qquad mathbf{M} qquad
mbox{oldmath $mu, M$}
end{displaymath}
使用工具包中的amsbsy(包括在amsmath 中)和bm 很容易办到这点,因为它们包含boldsymbol命令。
egin{displaymath}
mu, M qquad
oldsymbol{mu}, oldsymbol{M}
end{displaymath}

1)对于一个公式,换行缩进,quad (退一格)和qquad(退两格)

(一)不编号,右对齐

egin{align*}
Pleft( {i,j,k} ight)left[ {i{mu_p} + {lambda_s} + {lambda_p} + j{mu_s}} ight]=(j+1){mu_s}Pleft( {i,j+1,k} ight) \
qquad + (i+1){mu_p}Pleft( {i+1,j,k} ight)+ {lambda_s}left[ {1-delta (j)} ight]Pleft( {i,j-1,k} ight)
end{align*}
加红色的qquad    表示后退两格。quad   表示后退一格

(二)编号,左对齐

egin{align}
&Pleft( {i,j,k} ight)left[ {i{mu_p} + {lambda_s} + {lambda_p} + j{mu_s}} ight]=(j+1){mu_s}Pleft( {i,j+1,k} ight)   onumber \
&quad + (i+1){mu_p}Pleft( {i+1,j,k} ight)+ {lambda_s}left[ {1-delta (j)} ight]Pleft( {i,j-1,k} ight)  onumber  \
&quad + left[ {1-delta (j)} ight]P(i,j-1,k+1) + delta (N-i-j)P(i,j,k+2)
end{align}

2)对于两个公式,只要一个编号(相当于一个公式分两行排列)

解决方案有两种:如果不想要编号,就用displaymath替换equation
(一) split
egin{equation}
egin{split}
(a+b)^2 &=a^2+b^2+2ab\
(a+b+c)^2 &=a^2+b^2+c^2+2ab+2ac+2bc
end{split}
end{equation}
(二) aligned
egin{equation}
egin{aligned}
c^{j-1}_n=sum_{l=0}^{D-1}g_lc_{l+2n}^j \
d^{j-1}_n=sum_{l=0}^{D-1}h_lc_{l+2n}^j
end{aligned}
end{equation}

3)在公式中间空一行

(一)  otag\
egin{align}
c^{j-1}_n=sum_{l=0}^{D-1}g_lc_{l+2n}^j \
  otag\ %空格(注意命令 otag之前是命令符加一空格,
%而不是双斜线)占一行。其中的命令 otag也可以
%换为 onumber
d^{j-1}_n=sum_{l=0}^{D-1}h_lc_{l+2n}^j
end{align}
(二) otag\,并用&对齐
egin{align}
c^{j-1}_n & =sum_{l=0}^{D-1}g_lc_{l+2n}^j \
&  otag\ %即把三个公式中的第二个输入为空,且不参与编号
d^{j-1}_n & =sum_{l=0}^{D-1}h_lc_{l+2n}^j
end{align} 

  

4)The Latex Array Command

Syntax egin{array}{c1 ... cn}
  A(1,1) & ... & A(1,n) \
  ... & ... & ... \
  A(m,1) & ... & A(m,n)
  end{array}
See Also table

XML dependently interpret the array A with j-th column is aligned according to the value of cj where l means align to the left, c means align each to the center, and r means align to the right.

Example
The input 

  egin{array}{clcr}    a+b++c & uv    & x-y & 27     \    a+b    & u+v   & z  & 134    \    a      & 3u+vw & xyz & 2,978   end{array} 

Row Alignment
The first line in the syntax above can have the form 
     egin{array}[
r]{c1 ... cn}
In this case the value of r specifies how each row is aligned where t means align the top, c means align the center, and b means align the bottom. For example, the input 

  egin{array}[t]{cc}    egin{array}{c} a \ b end{array}    &    egin{array}{cc} a & b end{array}   end{array}

 array有时候可能不如align,如:

 egin{equation}
  left{
   egin{array}{c}
   x + y = z,  \
   c+1 + 2 = 3.  \
   end{array}
   ight.
  end{equation}

egin{equation}
  left{
   egin{aligned}
   x + y &= z,  \
   c+1 + 2 &= 3.  \
   end{aligned}
   ight.
end{equation}

5)Latex中的(左边有大括号的)方程组解决方案

(一)大括号下并列的式子, 右边只有一个纵向居中的编号:

egin{equation}
  left{
   egin{array}{c}
   x + y = z,  \
   1 + 2 = 3.  \
   end{array}
   ight.
  end{equation}

或者比较 cases 环境:

egin{equation}
  egin{cases}
    x + y = z,  \
    1 + 2 = 3.  \
  end{cases}
  end{equation}

(二)大括号下并列的式子, 每个都加上编号, 需要调用 cases 宏包: {这是一个宏包! 与 amsmath 宏包中的 cases 环境相区别.}

usepackage{cases}
......
egin{numcases}{}
   x+y=z,\
   1+2=3.
  end{numcases}

为什么 egin{numcases}{} 有一对空的大括号? 因为它的基本用法是这样的:

usepackage{cases}
......
egin{numcases}{|x|=}
   x,  & for $x geq 0$;\
   -x, & for $x < 0$.
  end{numcases}
 
6)frac{分子}{分母}
7)求和 sum 与积分 int
8)上标 ^{角标} 与下标 _{角标}
9)根式
    开平方:sqrt{表达式}
    开n次方:sqrt[n]{表达式}
 
from: http://blog.sina.com.cn/s/blog_5eb8c9aa0100s8wo.html
原文地址:https://www.cnblogs.com/GarfieldEr007/p/5572331.html