將環境與多個單獨的值對齊

將環境與多個單獨的值對齊

我試圖顯示一個分成 3 列的方程,如下圖所示。

在此輸入影像描述

我設法使用令人厭惡的不間斷空格(~)創建了上面的圖像,這顯然在編輯器和文件中看起來都是完全垃圾,因為它們沒有正確對齊。

\begin{align*}
\mathrm{Area~of~\Delta ABD}~~~~~~~~~~~~ &= ~~~~~~~~~~\mathrm{area~of~\Delta ABC}  ~~      &+ ~~~~~~~ \mathrm{area~of~\Delta ACD} \\
\frac{x*z*\sin(\alpha+\beta)}{2}~~~~~~~~~~~~ &= ~~~~~~~~~~~~ \frac{x*y*\sin\alpha}{2} &+ ~~~~~~~~~~~ \frac{z*y*\sin\beta}{2}
\end{align*}

Both sides are multiplied by 2:
\begin{align*}
    x*z*\sin(\alpha+\beta)~~~~~~~~~~ &= ~~~~~~~~~~~~~~~ x*y*\sin\alpha &+ ~~~~~~~~~~ z*y*\sin\beta
\end{align*}

Both sides are divided by $x*z$:
\begin{align*}
    \sin(\alpha+\beta)~~~~~~~~~~~~~~~~ &= ~~~~~~~~~~~~~~~~~~ \frac{y*\sin\alpha}{z} &+ ~~~~~~~~~~~ \frac{y*\sin\beta}{x}
\end{align*}

As $\frac{y}{z}=\cos(\beta)$ and $\frac{y}{x}=\cos(\alpha)$ we get:
\begin{align*}
\sin(\alpha+\beta) ~~~~~~~~~~~~~~~~~~~ &= ~~~~~~~~~~~~~~~ \cos\beta*\sin\alpha &+ ~~~~~~~ \cos\alpha*\sin(\beta)
\end{align*}

我想知道你會如何以不那麼可怕的方式做到這一點?

答案1

如果居中列內容並對齊=和符號對您很重要,我建議您按照以下方式+使用四列環境:array

在此輸入影像描述

\sin除了刪除 和參數周圍不需要的(且適得其反的)花括號對之外\cos,我還刪除了乘法*符號的所有實例,並將一些表達式替換\frac為內聯數學分數等價物。

\documentclass{article} % or some other suitable document class
\usepackage{array} % for "\newcolumntype" macro
\newcolumntype{L}{>{$}l<{$}} % automatic text mode, left-aligned

\begin{document}

\[
\renewcommand\arraystretch{1.667}
\begin{array}{@{} l @{\qquad\qquad} c @{{}={}} c @{{}+{}} c @{}}
& \textnormal{Area of $\Delta\mathit{ABD}$} 
& \textnormal{Area of $\Delta\mathit{ABC}$}
& \textnormal{Area of $\Delta\mathit{ACD}$} \\[0.5ex]
& \frac{1}{2}x z\sin(\alpha+\beta) 
& \frac{1}{2}x y\sin\alpha 
& \frac{1}{2}z y\sin\beta \\
\multicolumn{4}{@{}L}{Multiply both sides by 2:}\\
& xz\sin(\alpha+\beta) 
& xy\sin\alpha 
& zy\sin\beta\\
\multicolumn{4}{@{}L}{Divide both sides by $x z$:}\\
& \sin(\alpha+\beta) 
& (y/z)\sin\alpha 
& (y/x)\sin\beta \\
\multicolumn{4}{@{}L}{As $y/z=\cos\beta$ and $y/x=\cos\alpha$ we get}\\
& \sin(\alpha+\beta)  
& \cos\beta\sin\alpha 
& \cos\alpha\sin\beta\,.
\end{array}
\]

\end{document}

答案2

您可以像這樣對齊,儘管您的第一個「文字」行相當寬,因此對齊的 + 看起來有點間隔。

在此輸入影像描述

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
\text{Area of $\Delta ABD$} &= \text{area of $\Delta ABC$}&&+  \text{area of $\Delta ACD$} \\
\frac{x*z*\sin(\alpha+\beta)}{2} &=  \frac{x*y*\sin\alpha}{2} &&+  \frac{z*y*\sin\beta}{2}\\
\intertext{Both sides are multiplied by $2$:}
    x*z*\sin(\alpha+\beta) &=  x*y*\sin\alpha &&+  z*y*\sin\beta
\intertext{Both sides are divided by $x*z$:}
    \sin(\alpha+\beta) &=  \frac{y*\sin\alpha}{z} &&+  \frac{y*\sin\beta}{x}
\intertext{As $\frac{y}{z}=\cos(\beta)$ and $\frac{y}{x}=\cos(\alpha)$ we get:}
\sin(\alpha+\beta)  &=  \cos\beta*\sin\alpha &&+  \cos\alpha*\sin(\beta)
\end{alignat*}
\end{document}

答案3

我建議三種方法來處理這個問題。第一個與你的方法類似;對於第二個,我使用中間列居中,以盡量減少空白。

在第三種情況下,不尋求任何對齊:每個公式都有三個部分,您的讀者將能夠在各個步驟中匹配它們。

請避免使用 * 來表示乘法。

\documentclass{article} % or some other suitable document class
\usepackage{amsmath,mathtools}
\usepackage{IEEEtrantools}

\newcommand{\IEEEintertext}[1]{\noalign{#1\vspace{1ex}}}

\begin{document}

\section{Your approach}

\begin{alignat*}{2}
\text{Area of $\Delta\mathit{ABD}$} &= \text{Area of $\Delta\mathit{ABC}$}
  &&+ \text{Area of $\Delta\mathit{ACD}$} \\
\frac{x z\sin(\alpha+\beta)}{2} &= \frac{x y\sin\alpha}{2} &&+ \frac{z y\sin\beta}{2} \\
\shortintertext{Multiply both sides by 2:}
xz\sin(\alpha+\beta) &= xy\sin\alpha &&+ zy\sin\beta\\
\shortintertext{Divide both sides by $x z$:}
\sin(\alpha+\beta) &= \frac{y\sin\alpha}{z} &&+ \frac{y\sin\beta}{x} \\
\shortintertext{As $y/z=\cos\beta$ and $y/x=\cos\alpha$ we get}
\sin(\alpha+\beta) &= \cos\beta\sin\alpha &&+ \cos\alpha\sin\beta\,.
\end{alignat*}

\section{With slightly different alignment}

\begin{IEEEeqnarray*}{rCcCl}
\text{Area of $\Delta\mathit{ABD}$} &=& \text{Area of $\Delta\mathit{ABC}$}
  &+& \text{Area of $\Delta\mathit{ACD}$} \\[1ex]
\frac{x z\sin(\alpha+\beta)}{2} &=& \frac{x y\sin\alpha}{2} &+& \frac{z y\sin\beta}{2} \\[1ex]
\IEEEintertext{Multiply both sides by 2:}
xz\sin(\alpha+\beta) &=& xy\sin\alpha &+& zy\sin\beta\\[1ex]
\IEEEintertext{Divide both sides by $x z$:}
\sin(\alpha+\beta) &=& \frac{y\sin\alpha}{z} &+& \frac{y\sin\beta}{x} \\[1ex]
\IEEEintertext{As $y/z=\cos\beta$ and $y/x=\cos\alpha$ we get}
\sin(\alpha+\beta) &=& \cos\beta\sin\alpha &+& \cos\alpha\sin\beta\,.
\end{IEEEeqnarray*}

\section{An altogether different method}

We start from the fact that
\[
\text{Area of $\Delta\mathit{ABD}$} = \text{Area of $\Delta\mathit{ABC}$}
  + \text{Area of $\Delta\mathit{ACD}$}
\]
Writing down the formulas and removing the common denominator $2$ gives
\[
xz\sin(\alpha+\beta) = xy\sin\alpha + zy\sin\beta
\]
Now we can divide both sides by $xz$ to obtain
\[
\sin(\alpha+\beta)=\frac{y}{z}\sin\alpha+\frac{y}{x}\sin\beta
\]
However, by definition, $y/z=\cos\beta$ and $y/x=\cos\alpha$, so we finally get
\[
\sin(\alpha+\beta)=\cos\beta\sin\alpha+\cos\alpha\sin\beta
\]

\end{document}

在此輸入影像描述

相關內容