我有以下代码:
\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}
这非常丑陋,分数的大小太小,如果我改变它,它们会重叠,线条的相同空间非常小,积分看起来不太好。我该如何改进?
答案1
对于 align
编号行和align*
未编号行:
\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{align}
f(\hat{x}_n) & = \int_{-1}^{0} \hat{x}_n d t - \int_{0}^{1} \hat{x}_n d t \\
& = \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{align}
\begin{align*}
f(\hat{x}_n) & = \int_{-1}^{0} \hat{x}_n d t - \int_{0}^{1} \hat{x}_n d t \\
& = \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{align*}
\end{document}