eqnarray 中不同行的对齐方式不同

eqnarray 中不同行的对齐方式不同

请看一下这个。在此处输入图片描述 我希望连续部分(即第 3 行和第 5 行)右对齐。我尝试通过重复使用来实现,\qquad但我确信一定有比这更好的方法。我使用了eqnarray环境,但愿意听取任何建议。这是此部分的代码

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{eqnarray}
        g_s(t,s)    &=& E_s x_t^2+2Ex_t x_{ts}+2F_s x_t y_t+2F\left(x_ty_{ts}+x_{ts}y_t\right)+G_sy_t^2+2Gy_ty_{ts} \notag\\
                    &=& \left(E_xx_s+E_yy_s\right)x_t^2+2\left(F_xx_s+F_yy_s\right)x_ty_t+\left(G_xx_s+G_yy_s\right)y_t^2+  \notag\\
                    &&  \qquad\qquad\qquad\qquad\qquad 2Ex_tx_{ts}+2F\left(x_ty_{ts}+x_{ts}y_t\right)+2Gy_ty_{ts}   \notag\\
                    &=& \left(E_xx_t^2+2F_xx_ty_t+G_xy_t^2\right)x_s+\left(E_yx_t^2+2F_yx_ty_t+G_yy_t^2\right)y^s+  \notag\\
                    &&  \qquad\qquad\qquad\qquad\qquad 2\left(Ex_t+Fy_t\right)x_{ts}+2\left(Fx_t+Gy_t\right)y_{ts}  \notag\\
                    &=& Ax_s+By_s+Cx_{ts}+Dy_{ts}   \quad\text{(say).}  \notag
\end{eqnarray}
\end{document}

答案1

首先:绝不使用eqnarray

我可以提出三种不同的排版方式。第二种似乎是你想要的,但它需要知道哪一行是最长的(在本例中是第一行)。我个人的意见是第三种方式。

我已将 + 移至续行,这更为习惯。

\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}

\subsection*{First way}
\begin{align*}
g_s(t,s)
&=E_s x_t^2+2Ex_t x_{ts}+2F_s x_t y_t+2F(x_ty_{ts}+x_{ts}y_t)+G_sy_t^2+2Gy_ty_{ts}
\\[1ex]
&=\begin{aligned}[t]
  (E_xx_s+E_yy_s)x_t^2+2(F_xx_s+F_yy_s)x_ty_t+(G_xx_s+G_yy_s)y_t^2\\
  {}+2Ex_tx_{ts}+2F\left(x_ty_{ts}+x_{ts}y_t\right)+2Gy_ty_{ts}
  \end{aligned}
\\[1ex]
&=\begin{aligned}[t]
  (E_xx_t^2+2F_xx_ty_t+G_xy_t^2)x_s+(E_yx_t^2+2F_yx_ty_t+G_yy_t^2)y^s \\
  {}+2(Ex_t+Fy_t)x_{ts}+2(Fx_t+Gy_t)y_{ts}
  \end{aligned}
\\[1ex]
&=Ax_s+By_s+Cx_{ts}+Dy_{ts} \quad\text{(say).}
\end{align*}

\subsection*{Second way}
\begin{alignat*}{2}
g_s(t,s)
&=&E_s x_t^2+2Ex_t x_{ts}+2F_s x_t y_t+2F(x_ty_{ts}+x_{ts}y_t)+G_sy_t^2+2Gy_ty_{ts}
\\[1ex]
&=\mathrlap{(E_xx_s+E_yy_s)x_t^2+2(F_xx_s+F_yy_s)x_ty_t+(G_xx_s+G_yy_s)y_t^2}
\\
&&{}+2Ex_tx_{ts}+2F\left(x_ty_{ts}+x_{ts}y_t\right)+2Gy_ty_{ts}
\\[1ex]
&=\mathrlap{(E_xx_t^2+2F_xx_ty_t+G_xy_t^2)x_s+(E_yx_t^2+2F_yx_ty_t+G_yy_t^2)y^s}
\\
&&{}+2(Ex_t+Fy_t)x_{ts}+2(Fx_t+Gy_t)y_{ts}
\\[1ex]
&=\mathrlap{Ax_s+By_s+Cx_{ts}+Dy_{ts} \quad\text{(say).}}
\end{alignat*}

\subsection*{Third way}
\begin{align*}
g_s(t,s)
&=E_s x_t^2+2Ex_t x_{ts}+2F_s x_t y_t+2F(x_ty_{ts}+x_{ts}y_t)+G_sy_t^2+2Gy_ty_{ts}
\\[1ex]
&=(E_xx_s+E_yy_s)x_t^2+2(F_xx_s+F_yy_s)x_ty_t+(G_xx_s+G_yy_s)y_t^2\\
&\qquad{}+2Ex_tx_{ts}+2F\left(x_ty_{ts}+x_{ts}y_t\right)+2Gy_ty_{ts}
\\[1ex]
&=(E_xx_t^2+2F_xx_ty_t+G_xy_t^2)x_s+(E_yx_t^2+2F_yx_ty_t+G_yy_t^2)y^s \\
&\qquad{}+2(Ex_t+Fy_t)x_{ts}+2(Fx_t+Gy_t)y_{ts}
\\[1ex]
&=Ax_s+By_s+Cx_{ts}+Dy_{ts} \quad\text{(say).}
\end{align*}

\end{document}

在此处输入图片描述

相关内容