码迷,mamicode.com
首页 > 其他好文 > 详细

LaTeX_多行公式对齐居中的同时选择性的加编号

时间:2016-10-20 09:44:07      阅读:1411      评论:0      收藏:0      [点我收藏+]

标签:

【转载请注明出处】http://www.cnblogs.com/mashiqi

2016/10/20

一年多没写博文了。今天写一个短的,记录一下使用LaTeX的一些经验。

 


如何居中多行的公式呢?我试过很多种方法后,觉得下面这个最好用:

1 \begin{flalign*}
2     % In this way (this arrange of &), the equation will in the center and align at the third &. If use this method for ‘split‘, equations will not be centered
3     % However, ‘flalign‘ will give each line a separate number. It cannot number the whole equations in one number.
4     && a & = b & \5     && a & = b & \6     && a & = b & \7     && a & = b &
8 \end{flalign*}

其中的多个&符号是专门安排好的。只用往第二个和第三个&符号后面添加代码就行了,它们就能对齐 并且所有公式作为一个整体进行居中。但这里有个问题,就是编号的问题。这里没有公式的编号。如果把flalign后面的*号去掉的话,那么就有编号了,但是是每一行公式一个编号,有些情况下这不太合适。因此,为了编号,我们要对上述代码做如下更改:

 1 \begin{flalign}
 2     % In this way (this arrange of &), the equation will in the center and align at the third &. If use this method for ‘split‘, equations will not be centered
 3     % However, ‘flalign‘ will give each line a separate number. It cannot number the whole equations in one number.
 4     && a & = b & \nonumber\ 5     && a & = b & \ 6     && a & = b & \nonumber\ 7     && a & = b & \label{eq2}\ 8     && a & = b & \nonumber
 9 \end{flalign}
10 Now we refer equation (\ref{eq2}).

 

现在去掉了flalign后面的*号。同时给不想编号的行的结尾加上“\nonumber”,给想加编号的行的后面“不添加任何东西”或者“加上\label{...}”。当不添加东西时,有编号但不能引用到这个编号;当添加了\label{...}时,可以通过“\ref{...}”来引用这个编号。

下图就是上面两段代码的输出结果:

 技术分享

 

以上就基本解决了:多行公式、居中、对齐、加编号、引用编号这些问题。唯一的小缺点就是编号并不在整个公式的中间。不过这个小缺点可以容忍。

LaTeX_多行公式对齐居中的同时选择性的加编号

标签:

原文地址:http://www.cnblogs.com/mashiqi/p/5979446.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!