[Tex/LaTex] How to create a beautifully aligned solution for exercises

alignhorizontal alignment

Basically, I'm writing solution for the exercises on the textbook. And I want something like this:

As you can see, sub-problems are aligned after the problem number and the formulas are aligned after each sub-problems.

I've tried \tabular but I can't get what I wanted. Any suggestion?

To accomplish a result that is nicely aligned it is easy to use the align environment, which is part of the amsmath package.

You can accomplish this with the following code:

\documentclass{article}
\usepackage[fleqn]{mathtools}
\begin{document}
\begin{align*}
\intertext{2.4-14}
\intertext{(a)}
f(x) &= \begin{dcases}
\frac{125}{216} & x = -1,\\
\frac{75}{216} & x = 1,\\
\frac{15}{216} & x = 2,\\
\frac{1}{216} & x = 3;
\end{dcases} \\
\intertext{(b)}
\mu &= (-1) \cdot \frac{125}{216} + (1) \cdot \frac{75}{216} + (2) \cdot \frac{15}{216} + (3) \cdot \frac{1}{216} = -\frac{17}{216};\\
\sigma^2 &= E(X^2) - \mu^2 = \frac{269}{216} - \left( -\frac{17}{216} \right) = 1.2392;\\
\sigma &= 1.11; \\
\intertext{(c)}
&  \text{See Figure 2.4-14.} \\
\intertext{(d)}
\overline{x} &= \frac{-1}{100} = -0.01;  \\
s^2 &= \frac{100(129)-(-1)^2}{100(99)} = 1.30.29; \\
s &= 1.14.
\end{align*}
\end{document}


The mathtools package is used, because it is needed for the dcases environment in the answer for (a). The mathtools package automatically loads the amsmath package that you also need.

The result looks like this: