<s>[INST] How to write units when multiple terms are involved in a derivation? Say I am going to write down the steps of some calculations to get the final value of $s$ from an equation like this:
$$ s = s_0 + \frac12 gt^2. $$
Let us say $s_0 = 20\,\mathrm{m}$, $g = 10\,\mathrm{ms^{-2}}$, and $t = 2\,\mathrm{s}$. What is the right way to write down the units in every step so that all the formula, LHS, and RHS are always consistent in terms of units?
Alternative 1
\begin{align*}
s &= s_0 + \frac12gt^2 \\
  &= 20\,\mathrm{m} + \frac{1}{2} \cdot 10\,\mathrm{m\,s^{-2}} \cdot (2\,\mathrm{s})^2 \\
  &= 20\,\mathrm{m} + 20\,\mathrm{m} \\
  &= 40\,\mathrm{m}.
\end{align*}
Alternative 2
\begin{align*}
s &= s_0 + \frac12gt^2 \\
  &= 20\,\mathrm{m} + \frac{1}{2} \cdot 10\,\mathrm{m\,s^{-2}} \cdot 2^2\,\mathrm{s^2} \\
  &= 20\,\mathrm{m} + 20\,\mathrm{m} \\
  &= 40\,\mathrm{m}.
\end{align*}
Alternative 2
\begin{align*}
s &= s_0 + \frac12gt^2 \\
  &= 20\,\mathrm{m} + \left(\frac{1}{2} \cdot 10 \cdot 2^2\right)\,\mathrm{m} \\
  &= 20\,\mathrm{m} + 20\,\mathrm{m} \\
  &= 40\,\mathrm{m}.
\end{align*}
Alternate 3
\begin{align*}
s &= s_0 + \frac12gt^2 \\
  &= \left(20 + \frac{1}{2} \cdot 10 \cdot 2^2\right)\,\mathrm{m} \\
  &= 20\,\mathrm{m} + 20\,\mathrm{m} \\
  &= 40\,\mathrm{m}.
\end{align*}
Are all alternatives correct? Is there any alternative above or another alternative that is widely used in literature?
 [/INST] I perfectly agree with garyp: There is no right or wrong way to put the units into the equations. However, in my experience people tend to make mistakes, if they rewrite the equations. That's why I recommend

*

*to convert all units to the standard SI units (no prefixes like nano or kilo),

*do the insertion and calculation of the numbers as a side mark, where we do not include the units, and

*finally just writing the  final result with the SI unit as the solution.

Hence, your calculation would read
$$
s = s_0 + \frac{1}{2}g t ^2 = \fbox{40m}
$$
and the side mark would read
$$
\left(20 + \frac{1}{2} \cdot 10 \cdot 2^2\right)
= 20 + 20 = 40.
$$
</s>