我怎样才能将下面的单词“Similarly”与单词“This”左对齐(水平)?

我怎样才能将下面的单词“Similarly”与单词“This”左对齐(水平)?
\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{equation*}
  (a+b)(a+b)=a^{2}+2ab+b^{2}.
\end{equation*}
This may of course be written
\begin{flalign*}
  &&(a+b)^{2}&=a^{2}+2ab+b^{2}&\\
  \makebox[0pt]{Similarly}&&
  (a-b)^{2}&= a^{2}-2ab+b^{2}&\\
  \text{In the case}&&
  (a+b)(a-b)&= a^{2}-b^{2}
\end{flalign*}
\end{document}

答案1

使用\phantom较长文本的版本(\text{In the case})以便正确对齐Similarly

在此处输入图片描述

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{equation*}
  (a+b)(a+b)=a^{2}+2ab+b^{2}.
\end{equation*}
This may of course be written
\begin{flalign*}
  &&(a+b)^{2}&=a^{2}+2ab+b^{2} & \\
  \rlap{Similarly}\phantom{\text{In the case}}&&
  (a-b)^{2}&= a^{2}-2ab+b^{2} & \\
  \text{In the case}&&
  (a+b)(a-b)&= a^{2}-b^{2} &
\end{flalign*}

\end{document}

答案2

您已在使用一个\makebox,因此请使用另一个:

\documentclass{article}
\usepackage{mathtools,showframe}

\begin{document}
\begin{equation*}
  (a+b)(a+b)=a^{2}+2ab+b^{2}.
\end{equation*}
This may of course be written
\begin{flalign*}
  &&(a+b)^{2}&=a^{2}+2ab+b^{2}&\\
  \makebox[0pt][l]{Similarly}&&
  (a-b)^{2}&= a^{2}-2ab+b^{2}&\\
  \makebox[0pt][l]{In the case}&&
  (a+b)(a-b)&= a^{2}-b^{2}
\end{flalign*}
\end{document}

在此处输入图片描述

相关内容