I have the following code:
\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
$$ \begin{array}{cl}
f(\hat{x}_n) & =\displaystyle \int_{-1}^{0} \hat{x}_n d t - \int_{0}^{1} \hat{x}_n d t \\
& = \displaystyle \int_{-1}^{-\frac{1}{n+1}} d t +\int_{-\frac{1}{n+1}}^{0} -(n+1)t d t +\int_{0}^{\frac{1}{n+1}} (n+1)t d t +\int_{\frac{1}{n+1}}^{1} d t \\
& =\frac{n}{n+1} +\frac{n}{2n+21} +\frac{n}{2n+2} +\frac{n}{n+1} \\
& = \frac{2n+1}{n+1}
\end{array}
$$
\end{document}
And this very ugly, the size of the fractions is too small, if I change it they overlapse, the same space of the lines is very small for the integrals to look good. How can I improve this?
align
environment.$$
is not latex (use\[..\]
) thearray
environment is designed for arrays/matrices of values not for displayed equations so they are set in textsyle and the spacing is all wrong, which is why you are needing to ty to correct with\displaystyle
but better to use a display environment such asalign
(oraligned
for a term within a larger display)