如何才能将多行方程中除第一行之外的各行向右对齐?

如何才能将多行方程中除第一行之外的各行向右对齐?

我一直试图实现这一点,但尝试了几次之后,我决定跳过这一步,集中精力写作而不是解决它。

我正在使用align环境并尝试将多行方程式(第一行除外)对齐到右侧。如果某些方程式标记对齐,效果会更好。例如:

\begin{align*}
  x &= a + b \\
    + c + d \\ % this line should be aligned to the right
  y &= a + b \\
    + c + d + e % this should be aligned right too
\end{align*} % equals signs should be aligned as well

它看起来应该是这样的: 除第一个外右对齐

答案1

类似这样的事?

\documentclass{article}
\usepackage{amsmath}
\usepackage{fourier}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
  x &= a + b &\\[-1ex]
    & & {} + c + d & \\ % this line should be aligned to the right
  y &= a + b \\[-1ex]
    & & \mathllap{{}+ c + d + e} & % this should be aligned right too
\end{alignat*}

\end{document}

在此处输入图片描述

答案2

我建议使用简单的命令\hspace{xcm}\hspace当把命令放在等式前面时,它会将等式进一步向右推,而移位基本上由用户在中定义cm。我还没有尝试过左移,但我猜括号内的负值可以完成工作。

此外,为了对齐方程式,可以使用“与”符号来表示对齐的起点

\begin{align*} x =& a + b \\ &\hspace{1cm}+ c + d \\ % this line should be aligned to the right y =& a + b \\ &\hspace{0.5cm}+ c + d + e % this should be aligned right too \end{align*} % equals signs should be aligned as well

更新后的代码运行良好。试试看。我只是懒得再贴图了 ;)

在此处输入图片描述

相关内容