如何使分子和分母居中,并缩短分数线以便只包含它们两个?

如何使分子和分母居中,并缩短分数线以便只包含它们两个?

在此处输入图片描述

\documentclass{article}


\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}

\usepackage{soul}
\usepackage[dvipsnames]{xcolor}
\newcommand{\mathcolorbox}[2]{\colorbox{#1}{$\displaystyle #2$}}


\begin{document}

    \begin{align*}
        \binom n i p^i ( 1 - p )^{ n - i }
        & = \frac{ n! }{ i! ( n - i )! } \, p^i \, ( 1 - p )^{ n - i } \\
        & = \frac{ n! }{ \mathcolorbox{ProcessBlue}{ i! } ( n - i )! }
            \left ( \frac \lambda n \right )^i
            \left ( 1 - \frac \lambda n \right )^{ n - i } \\
        & = \mathcolorbox{YellowGreen}{ \frac{ n! }{  n^i ( n - i )! } }
            \frac{ \lambda^i }{ \mathcolorbox{ProcessBlue}{ i! } }
            \frac{ \mathcolorbox{Yellow}{ \left ( 1 - \frac \lambda n \right )^n }
            \to e^{ -\lambda } \text{ when } n \to +\infty }{
                \left \{ \left ( 1 - \dfrac \lambda n \right )^i \right \}
                \to 1 \text{ when } n \to +\infty } \\
        & = \mathcolorbox{Yellow}{ e^{ -\lambda } }
            \frac{ \lambda^i }{ i! }
            \mathcolorbox{YellowGreen}{
                \frac{ n ( n - 1 ) \cdots ( n - i + 1 ) }{ n^i } } \to 1
                \text{ when } n \to +\infty \\
        & = \frac{ \lambda^i }{ i! } e^{ -\lambda }
    \end{align*}

\end{document}

-编辑-

首先,颜色并没有什么特别的含义。只有红框内最右边的部分才有意义。

如你所见,分数线也跨越了\to e^{ -\lambda } \text{ when } n \to +\infty\to 1 \text{ when } n \to +\infty注释;相反,我只希望它覆盖\left ( 1 - \frac \lambda n \right )^n\left ( 1 - \frac \lambda n \right )^i

答案1

这是一个带有\overbrace\underbrace指令的解决方案。

在此处输入图片描述

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{mathtools, amssymb}

\begin{document}
\begin{align*}
\binom{n}{i} p^i ( 1-p )^{ n-i }
&= \frac{ n! }{ i! ( n-i )! } \, p^i \, ( 1-p )^{ n-i }\\
&= \frac{ n! }{  i  ( n-i )! }
            \left(   \frac{\lambda}{n}\right)^{\!i}
            \left( 1-\frac{\lambda}{n}\right)^{\!n-i} \\[\jot]
&=  \frac{ n! }{  n^i ( n-i )! } \,
    \frac{ \lambda^i }{  i! } \,
    \frac{ \overbrace{\left( 1 - \frac{\lambda}{n} \right)^{\!\!n}}%
            ^{\mathclap{\to e^{-\lambda} \text{ as } n\to\infty}} 
           }{
           \underbrace{\left( 1 - \frac{\lambda}{n} \right)^{\!\!i}}%
            _{\mathclap{\to 1 \text{ as } n\to\infty}}
                 } \\[\jot]
&=  e^{ -\lambda } \,
    \frac{ \lambda^i }{ i! } \,
    {\underbrace{\frac{ n (n-1) \dotsb(n-i+1) }{ n^i }}%
     _{\to 1\text{ as } n \to \infty}} \\
&= \frac{ \lambda^i }{ i! }\, e^{-\lambda }
\end{align*}

\end{document}

相关内容