無法在 flalign 環境中對齊文本

無法在 flalign 環境中對齊文本

我有一個帶有文字註釋的推導,其中註釋需要向左齊平,並且方程式中的第一個等號全部居中。這是我正在使用的程式碼。原則上它應該有效,但我無法找出問題所在。 & 符號位於行尾,& 符號位於對齊等號上。有什麼建議嗎?

\documentclass[12pt]{article}

\usepackage{mathtools,amssymb}

\begin{document}

\begin{flalign*}
\text{Let } \quad \sqrt{x} + \sqrt{y} &= \sqrt{7 + 4 \sqrt{3}}. \quad (1)&\\
%
\text{Then, by Theorem 5,} \quad \sqrt{x}-\sqrt{y} &= \sqrt{7 - 4 \sqrt{3}}. \quad (2)&\\
%
\text{Multiply (1) by (2)}, \quad x-y &=\sqrt{49-48}.&\\
%
\text{Square (1), then by Theorem 4,} \quad x + y &= 7.&\\
%
\therefore\ x &= 4, \text { and } y = 3.&\\
%
\therefore\ \sqrt{x}+\sqrt{y} &= \sqrt{4}+\sqrt{3}.&\\
%
\therefore\ \sqrt{7+4 \sqrt{3}} &= 2+\sqrt{3}.
\end{flalign*}

\end{document}

我得到的是

在此輸入影像描述

答案1

您需要在註釋之前以及每個方程式的左側之前添加 & 符號。另外,我在 \quad (2) 之前添加了另一個 & 符號,使其與 \quad (1) 齊平。

試試這個程式碼:

\documentclass[12pt]{article}

\usepackage{mathtools,amssymb}

\begin{document}

\begin{flalign*}
&\text{Let } &\quad \sqrt{x} + \sqrt{y} &= \sqrt{7 + 4 \sqrt{3}}. &\quad (1)\\
%
&\text{Then, by Theorem 5,} &\quad \sqrt{x}-\sqrt{y} &= \sqrt{7 - 4 \sqrt{3}}. &\quad (2)\\
%
&\text{Multiply (1) by (2)}, &\quad x-y &=\sqrt{49-48}.\\
%
&\text{Square (1), then by Theorem 4,} &\quad x + y &= 7.\\
%
&&\therefore\ x &= 4, \text { and } y = 3.\\
%
&&\therefore\ \sqrt{x}+\sqrt{y} &= \sqrt{4}+\sqrt{3}.\\
%
&&\therefore\ \sqrt{7+4 \sqrt{3}} &= 2+\sqrt{3}.
\end{flalign*}

\end{document}

在此輸入影像描述

相關內容