原 文:Fractions and Binomials
譯 者:Xovee
翻譯時間:2020年6月24日
Fractions and Binomials
分式和二項式係數是非常常見的數學元素,它們有着一些共同的特點:一個數字位於另外一個數字的上方。本篇文章解釋如何在 LaTeX 中輸入它們。
介紹
在表達式中使用分式和二項式是非常直接的:
The binomial coefficient is defined by the next expression:
\[
\binom{n}{k} = \frac{n!}{k!(n-k)!}
\]
爲了讓這些命令生效,你必須先引入amsmath
包,在文檔的序言部分引入:
\usepackage{amsmath}
分式
分式的樣式取決於它所在的上下文環境:
Fractions can be used alongside the text, for
example \( \frac{1}{2} \), and in a mathematical
display style like the one below:
\[\frac{1}{2}\]
你肯定已經猜到了,\frac{1}{2}
就是輸入分式的命令。在命令的兩個大括號裏,分別是分子和分母。
另外,分式的大小取決於它所在的環境。你可以手動設置這一點:
When displaying fractions in-line, for example \(\frac{3x}{2}\)
you can set a different display style:
\( \displaystyle \frac{3x}{2} \).
This is also true the other way around
\[ f(x)=\frac{P(x)}{Q(x)} \ \ \textrm{and}
\ \ f(x)=\textstyle\frac{P(x)}{Q(x)} \]
命令\displaystyle
會將分式的樣式設置爲展示模式下的樣式。相對地,命令\textstyle
會將分式的樣式設置爲行內模式下的樣式。
連續分式
分式的使用方法非常靈活,它們可以互相嵌套:
The fractions can be nested
\[ \frac{1+\frac{a}{b}}{1+\frac{1}{1+\frac{1}{a}}} \]
Now a wild example
\[
a_0+\cfrac{1}{a_1+\cfrac{1}{a_2+\cfrac{1}{a_3+\cdots}}}
\]
在上一個例子中,我們使用了\cfrac{}{}
命令,這個命令由amsmath
包提供,它可以讓嵌套的分式擁有相同的字體大小。這一點在連續分式中非常有用。
二項式係數
在數學表達式中,二項式係數經常出現。這個命令在 LaTeX 中與分式命令非常類似:
The binomial coefficient is defined by the next expression:
\[
\binom{n}{k} = \frac{n!}{k!(n-k)!}
\]
And of course this command can be included in the normal
text flow \(\binom{n}{k}\).
參考指南
下面展示一個不同的更復雜的連續分式:
Final example
\newcommand*{\contfrac}[2]{%
{
\rlap{$\dfrac{1}{\phantom{#1}}$}%
\genfrac{}{}{0pt}{0}{}{#1+#2}%
}
}
\[
a_0 +
\contfrac{a_1}{
\contfrac{a_2}{
\contfrac{a_3}{
\genfrac{}{}{0pt}{0}{}{\ddots}
}}}
\]
延伸閱讀
更多信息請見: