我对 TeX 还很陌生。我想让下面等式中的每一行都居中,但我不知道该怎么做。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{split}
a & = \frac{M_{20}}{M_{00}} - x^{2}_{c}, \;\;\;
b = 2(\frac{M_{11}}{M_{00}} - x_{c}y_{c}), \;\;\;
c = \frac{M_{02}}{M_{00}} - y^{2}_{c}, \\
&\quad x_{c} = \frac{M_{10}}{M_{00}}, \;\;\;
y_{c} = \frac{M_{01}}{M_{00}}, \\
&\quad M_{ij} = \displaystyle\sum\limits_{x} \displaystyle\sum\limits_{y} x^i y^j I(x,y)
\end{split}
\end{equation}
\end{document}
另外,如果我能在第一行后面写上“and”那就太棒了;)
提前致谢
答案1
\documentclass{minimal}
\usepackage{amsmath}
\begin{document}
\begin{gather}
a = \frac{M_{20}}{M_{00}} - x^{2}_{c},\quad
b = 2(\frac{M_{11}}{M_{00}} - x_{c}y_{c}),\quad
c = \frac{M_{02}}{M_{00}} - y^{2}_{c},\nonumber\\[1ex]
\text{and}\nonumber\\[1ex]
x_{c} = \frac{M_{10}}{M_{00}},\quad
y_{c} = \frac{M_{01}}{M_{00}}, \nonumber\\
M_{ij} = \displaystyle\sum\limits_{x} \displaystyle\sum\limits_{y} x^i y^j I(x,y)
\end{gather}
\end{document}
答案2
只需将split
环境替换为gathered
,那么您不必抑制虚假的方程数字:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{gathered}
a = \frac{M_{20}}{M_{00}} - x^{2}_{c}, \;\;\;
b = 2(\frac{M_{11}}{M_{00}} - x_{c}y_{c}), \;\;\;
c = \frac{M_{02}}{M_{00}} - y^{2}_{c}, \\
\quad x_{c} = \frac{M_{10}}{M_{00}}, \;\;\;
y_{c} = \frac{M_{01}}{M_{00}}, \\
\quad M_{ij} = \displaystyle\sum\limits_{x} \displaystyle\sum\limits_{y} x^i y^j I(x,y)
\end{gathered}
\end{equation}
\end{document}
答案3
下面的代码并不完全符合您的要求,但它有一些您可能需要考虑的替代方案。
- 使用
\left
和\right
固定括号的大小 - 用于
\intertext
在方程式之间插入单词 - 使用
&
以更好地控制对齐
你提到你是新手。你可能想阅读mathtools 文档。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
a &= \frac {M_{20} } {M_{00} } - x^{2}_{c} , &
b &= 2 \left ( \frac {M_{11} } {M_{00} } - x_{c} y_{c} \right ) , & %NOTE THE \LEFT AND \RIGHT
c &= \frac {M_{02} } {M_{00} } - y^{2}_{c} , \\
\intertext {and} % NOTE THE 'CORRECT' USAGE OF INTERTEXT TO WRITE IN BETWEEN EQUATIONS
&& \quad x_{c} &= \frac {M_{10} } {M_{00} } , & % NOTE THE DOUBLE && TO ALIGN TO THE SECOND COLUMN
y_{c} &= \frac {M_{01} } {M_{00} } , \\
\intertext {Some text}
&& \quad M_{ij} &= \sum \limits_{x} \sum \limits_{y} x^i y^j I( x, y )
\end{align}
\end{document}
答案4
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
a = \frac{M_{20}}{M_{00}} - x^{2}_{c}, \;\;\;
b = 2\left(\frac{M_{11}}{M_{00}} - x_{c}y_{c}\right), \;\;\;
c = \frac{M_{02}}{M_{00}} - y^{2}_{c}, \nonumber\\
x_{c} = \frac{M_{10}}{M_{00}}, \;\;\; y_{c} = \frac{M_{01}}{M_{00}}, \\
M_{ij} = \sum_x\sum_y x^i y^j I(x,y)\nonumber
\end{gather}
\end{document}