数学环境中的右对齐文本

数学环境中的右对齐文本

在我的 align* 环境中,我有一堆排列整齐的方程式,但我想在方程式的右侧添加一些步骤说明。目前看起来很糟糕:

\begin{align*}
  P(X_l=x_l,\ldots ,X_{l+k}=x_{l+k}) &= \int_0^1 f(x_l)\cdots f(x_{l+k})dp\\
                    &= \int_0^1 \prod_{i=1}^k p^{1\{x_i=1\}}(1-p)^{1\{x_i=0\}}dp\\
                    &= \int_0^1 p^t(1-p)^{k-t}dp\\
                    &= \int_0^1 p^{t+1-1}(1-p)^{k-t+1-1}dp\\
                    &= \dfrac{\Gamma(k-t+1)\Gamma(t+1)}{\Gamma(k+2)}\int_0^1\dfrac{\Gamma(k+2)}{\Gamma(k-t+1)\Gamma(t+1)} p^{t+1-1}(1-p)^{k-t+1-1}dp\\
                    &= \dfrac{\Gamma(k-t+1)\Gamma(t+1)}{\Gamma(k+2)} \text{ \; term on right is a $\Gamma(t+1,k-t+1)$}\\
                    &= \dfrac{t!(k-t)!}{(k+1)!} \text{ \; Since $k$ is an integer}
\end{align*}

你会如何让这个看起来更好?更具体地说,我认为如果文本全部向右对齐,看起来会更好。

编辑:我怎样才能使 Latex 显现出来?

答案1

在许多情况下,可以通过以下方式添加注释:

\begin{align*}
A &= B && \text{(because pigs fly)} \\
  &= C && \text{(since donkeys are not pigs)} \\
  &= D && \text{(because I say so)}
\end{align*}

这样注释就会(左)对齐。但是,您的情况有所不同:注释只会出现在最后两行,而第五行相当长。第五行使得注释很难突出。

最可行的解决方案可能是将注释推迟到对齐下方的文本中。无论如何,这些都是艰难的决定。那这个呢?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\makebox[2.8em][l]{$\displaystyle P(X_l=x_l,\ldots ,X_{l+k}=x_{l+k})$} \\
  &= \int_0^1 f(x_l)\cdots f(x_{l+k})\,dp\\
  &= \int_0^1 \prod_{i=1}^k p^{1\{x_i=1\}}(1-p)^{1\{x_i=0\}}\,dp\\
  &= \int_0^1 p^t(1-p)^{k-t}dp\\
  &= \int_0^1 p^{t+1-1}(1-p)^{k-t+1-1}\,dp\\
  &= \dfrac{\Gamma(k-t+1)\Gamma(t+1)}{\Gamma(k+2)}\int_0^1\dfrac{\Gamma(k+2)}{\Gamma(k-t+1)\Gamma(t+1)} p^{t+1-1}(1-p)^{k-t+1-1}\,dp\\
  &= \dfrac{\Gamma(k-t+1)\Gamma(t+1)}{\Gamma(k+2)} \\
  &= \dfrac{t!(k-t)!}{(k+1)!}
\end{align*}
Notice that the last integral is $\Gamma(t+1,k-t+1)$ and $k$ is an integer.
\end{document}

在此处输入图片描述

相关内容