
我想知道我是否正確地執行了以下操作。例如,這是呈現方程式發展的最佳方式嗎?
\newcommand{\integral}[2]{\int #1 \, \mathrm{d}#2}
\begin{equation}
\begin{aligned}
\derivative{}{x}\left[uv\right] & = \derivative{u}{x} v & + & u \derivative{v}{x} \\
\integral{\derivative{}{x}\left[uv\right]}{x} & = \integral{\derivative{u}{x} v}{x} & + & \integral{u \derivative{v}{x}}{x} \\
uv & = \integral{v}{u} & + & \integral{u}{v} \\
\integral{v}{u} & = uv & - & \integral{u}{v} \\
& \text{or} & & \\
\integral{u}{v} & = uv & - & \integral{v}{u} \\
\end{aligned}
\end{equation}
我應該如何處理第二個操作的對齊(加號/減號)?我是否需要對該行加號/減號使用 & 符號?或僅用於等號? (見下圖)
另外,「或」文本又如何呢?我該如何處理呢?它應該在等號下還是在正中心,或者其他什麼?
謝謝
答案1
如果你堅持提供兩個對齊點,你應該使用alignat*
環境,而不是align*
環境。但是,正如 @egreg 在評論中已經指出的那樣,這些方程中沒有任何內容需要或至少建議執行跨行對齊。因此,使用gather*
環境可能是最好的。
下面的螢幕截圖說明了這兩種可能性。
\documentclass{article}
\usepackage{amsmath} % for 'gather*' and 'alignat*' environments
\newcommand{\diff}{\mathop{}\!\mathrm{d}} % "differential" operator
\newcommand\deriv[2]{\frac{\diff #1}{\diff #2}}
\newcommand{\integral}[2]{\int \! #1 \diff #2}
\begin{document}
\begin{alignat*}{2}
\deriv{}{x}\left[uv\right]
&= \deriv{u}{x} v &&+ u \deriv{v}{x} \\
\integral{\deriv{}{x}\left[uv\right]}{x}
&= \integral{\deriv{u}{x} v}{x} &&+ \integral{u \deriv{v}{x}}{x} \\
uv &= \integral{v}{u} &&+ \integral{u}{v} \\
\text{hence}\integral{v}{u}
&= uv &&- \integral{u}{v}
\end{alignat*}
\begin{gather*}
\deriv{}{x}[uv]
= \deriv{u}{x} v + u \deriv{v}{x} \\
\integral{\deriv{}{x}[uv]}{x}
= \integral{\deriv{u}{x} v}{x} + \integral{u \deriv{v}{x}}{x} \\
uv = \integral{v}{u} + \integral{u}{v} \\
\text{hence}\quad\integral{v}{u}
= uv - \integral{u}{v}
\end{gather*}
\end{document}