# Typesetting aligned equation

I'd like to know whether I am doing the following properly. As in, is this the best way to present the development of the equation?

\newcommand{\integral}[2]{\int #1 \, \mathrm{d}#2}
\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}


What should I do about the second operations' alignment (the plus/minus sign)? Do I need to use ampersand for that line of plus/minus symbols? or only for the equal sign? (see image below)

Also what about the 'or' text? How should I deal with that? Should it be under the equal sign or in dead center, or something else?

Thanks

• I’d use either centering or left alignment. The relation and operation symbols are not really strictly related so as to require alignment. To be honest, I’d omit the last line, which is exactly the same as the previous one, mathematically. Sep 20, 2020 at 14:57
• Welcome to TeX.SE.
– Mico
Sep 20, 2020 at 15:22
• Thanks for the suggestion @egreg, I also thought it shouldn't be necessary, but I'm new to TeX, and wanted to know others opinion. Sep 21, 2020 at 4:58

If you insist on providing two alignments points, you should use an alignat* environment, not an align* environment. But, as @egreg has already remarked in a comment, there's nothing in these equations that requires or at least recommends performing alignment across rows. Hence, using a gather* environment may be best.

Both possibilities are illustrated in the following screenshot.

\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} \\