> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/ja/shu-xue/05-fractions-and-binomials.md).

# 分数と二項式

## はじめに

この記事では、分数と二項係数をどのように組版するかを説明します。以下の例から始めます。これは次のものを使用しています [`amsmath` パッケージ](https://ctan.org/pkg/amsmath?lang=en):

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
二項係数 \(\binom{n}{k}\) は、次の式で定義されます:
\[
    \binom{n}{k} = \frac{n!}{k!(n-k)!}
\]
\end{document}
```

[この例を Overleaf で開く。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Fractions+and+Binomials\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0AThe+binomial+coefficient%2C+%5C%28%5Cbinom%7Bn%7D%7Bk%7D%5C%29%2C+is+defined+by+the+expression%3A%0A%5C%5B%0A++++%5Cbinom%7Bn%7D%7Bk%7D+%3D+%5Cfrac%7Bn%21%7D%7Bk%21%28n-k%29%21%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

この [`amsmath` パッケージ](https://ctan.org/pkg/amsmath?lang=en) は、文書のプレアンブルに次の行を追加することで読み込まれます:

```latex
\usepackage{amsmath}
```

出力結果は次のとおりです:

![二項係数の LaTeX 組版を示す画像](/files/95130fe387d4033ce9e254005e7980630e86b78b)

## 分数の表示

分数の見た目は、インラインで現れるか、段落の一部として現れるか、あるいは単独の行に表示される独立した要素として組版されるかによって変わります。次の例では、その見た目の変化を示します:

```latex
\documentclass{article}
% 幅を縮小するために geometry パッケージを使用
% ヘルプ記事のグラフィックの幅を
\usepackage[textwidth=8cm]{geometry}
\begin{document}
分数は、段落テキスト内でインラインで使用できます。
たとえば \(\frac{1}{2}\) などです。また、単独の行に表示することもできます。
このようなものです：
\[\frac{1}{2}\]
\end{document}
```

[この例を Overleaf で開く。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Inline+and+display+of+fractions+and+binomials\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+to+reduce%0A%25+the+width+of+help+article+graphics%0A%5Cusepackage%5Btextwidth%3D8cm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0AFractions+can+be+used+inline+within+the+paragraph+text%2C+for+%0Aexample+%5C%28%5Cfrac%7B1%7D%7B2%7D%5C%29%2C+or+displayed+on+their+own+line%2C+%0Asuch+as+this%3A%0A%5C%5B%5Cfrac%7B1%7D%7B2%7D%5C%5D%0A%5Cend%7Bdocument%7D)

この例では次の出力が生成されます:

![LaTeX におけるインライン数式モードとディスプレイ数式モードを示す](/files/32f5da509a78bc7c76a763ae4118cf7f277df12b)

* **注**: 数式のインライン版とディスプレイ版の詳細は Overleaf の記事 [数式モードでの表示スタイル](/latex/ja/shu-xue/10-display-style-in-math-mode.md).

例の分数は、次のコマンドを使って組版されています `\frac` コマンド（`\frac{1}{2}`）で、一般的な形式は `\frac{*分子*}{*分母*}`.

## テキスト表記の分数

以下の例では、次の `\text{...}` コマンドを提供する `amsmath` パッケージです。次の `\text{...}` コマンドは、LaTeX がテキストを通常の数式コンテンツとして組版しないようにするために使われます。

```latex
\documentclass{article}
% 幅を縮小するために geometry パッケージを使用
% ヘルプ記事のグラフィックの幅を
\usepackage[textwidth=8cm]{geometry}
\usepackage{amsmath}% \text{...} コマンド用
\begin{document}
私たちは \texttt{amsmath} パッケージのコマンド
\verb|\text{...}| を使ってテキストのみの分数を作成します
次のように:

\[\frac{\text{分子}}{\text{分母}}\]

\verb|\text{...}| コマンドがないと、結果は
次のようになります:

\[\frac{分子}{分母}\]
\end{document}
```

[この例を Overleaf で開く。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Text+fractions\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+to+reduce%0A%25+the+width+of+help+article+graphics%0A%5Cusepackage%5Btextwidth%3D8cm%5D%7Bgeometry%7D%0A%5Cusepackage%7Bamsmath%7D%25+For+the+%5Ctext%7B...%7D+command%0A%5Cbegin%7Bdocument%7D%0AWe+use+the+%5Ctexttt%7Bamsmath%7D+package+command%0A%5Cverb%7C%5Ctext%7B...%7D%7C+to+create+text-only+fractions%0Alike+this%3A%0A%0A%5C%5B%5Cfrac%7B%5Ctext%7Bnumerator%7D%7D%7B%5Ctext%7Bdenominator%7D%7D%5C%5D%0A%0AWithout+the+%5Cverb%7C%5Ctext%7B...%7D%7C+command+the+result+%0Alooks+like+this%3A%0A%0A%5C%5B%5Cfrac%7Bnumerator%7D%7Bdenominator%7D%5C%5D%0A%5Cend%7Bdocument%7D)

この例では次の出力が生成されます:

![テキスト表記の分数](/files/a37e04556522e0f5a2c44b8ba0da3377fff27f66)

## 組版された数式におけるサイズと間隔

LaTeX によって組版される数式のサイズと間隔は [アルゴリズムによって決定されます](https://tug.org/TUGboat/tb27-1/tb86jackowski.pdf) これらは、数式の組版に使用されるフォント内に含まれるサイズおよび配置データを適用します。

場合によっては、LaTeX が選択した既定の数式スタイル—数式要素のサイズと間隔—を上書きする必要がある、あるいは望ましいことがあります。この話題は Overleaf のヘルプ記事で আলোচনাされています [数式モードでの表示スタイル](/latex/ja/shu-xue/10-display-style-in-math-mode.md#overriding-default-mathematical-styles).

要約すると、数式の組版に使用される既定のスタイルは次のコマンドで変更できます:

* `\textstyle`: 段落内で組版される数式に使われるスタイルを適用します;
* `\displaystyle`: 単独の行に表示される数式に使われるスタイルを適用します;
* `\scriptstyle`: 添字や上付き文字に使われるスタイルを適用します;
* `\scriptscriptstyle`: 第二階層の添字や上付き文字に使われるスタイルを適用します;

これらは次の例で示されています。

```latex
\documentclass{article}
% 幅を縮小するために geometry パッケージを使用
% ヘルプ記事のグラフィックの幅を
\usepackage[textwidth=9.5cm]{geometry}
\begin{document}

段落内で組版された分数は通常、\(\frac{3x}{2}\) のように見えます。\LaTeX{} に、\( \displaystyle \frac{3x}{2} \) のようなより大きい表示スタイルを使わせることもでき、これは行間にも影響します。段落内の数式のサイズを小さくすることもできます: \(\scriptstyle \frac{3x}{2}\) または \(\scriptscriptstyle \frac{3x}{2}\)。\verb|\scriptscriptstyle| の例では間隔の縮小に注意してください。文字は \textit{vinculum}（分子と分母を分ける線）により近づけられます。

同様に、通常はディスプレイスタイルで組版される数式のスタイルを変更することもできます:

\[f(x)=\frac{P(x)}{Q(x)}\quad \textrm{と}\quad \textstyle f(x)=\frac{P(x)}{Q(x)}\quad \textrm{と}\quad \scriptstyle f(x)=\frac{P(x)}{Q(x)}\]
\end{document}
```

[Overleaf でこの例を開く](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Changing+default+math+styles\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+to+reduce%0A%25+the+width+of+help+article+graphics%0A%5Cusepackage%5Btextwidth%3D9.5cm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0A%0AFractions+typeset+within+a+paragraph+typically+look+like+this%3A+%5C%28%5Cfrac%7B3x%7D%7B2%7D%5C%29.+You+can+force+%5CLaTeX%7B%7D+to+use+the+larger+display+style%2C+such+as+%5C%28+%5Cdisplaystyle+%5Cfrac%7B3x%7D%7B2%7D+%5C%29%2C+which+also+has+an+effect+on+line+spacing.+The+size+of+maths+in+a+paragraph+can+also+be+reduced%3A+%5C%28%5Cscriptstyle+%5Cfrac%7B3x%7D%7B2%7D%5C%29+or+%5C%28%5Cscriptscriptstyle+%5Cfrac%7B3x%7D%7B2%7D%5C%29.+For+the+%5Cverb%7C%5Cscriptscriptstyle%7C+example+note+the+reduction+in+spacing%3A+characters+are+moved+closer+to+the+%5Ctextit%7Bvinculum%7D+%28the+line+separating+numerator+and+denominator%29.%0A%0AEqually%2C+you+can+change+the+style+of+mathematics+normally+typeset+in+display+style%3A%0A%0A%5C%5Bf%28x%29%3D%5Cfrac%7BP%28x%29%7D%7BQ%28x%29%7D%5Cquad+%5Ctextrm%7Band%7D%5Cquad+%5Ctextstyle+f%28x%29%3D%5Cfrac%7BP%28x%29%7D%7BQ%28x%29%7D%5Cquad+%5Ctextrm%7Band%7D%5Cquad+%5Cscriptstyle+f%28x%29%3D%5Cfrac%7BP%28x%29%7D%7BQ%28x%29%7D%5C%5D%0A%5Cend%7Bdocument%7D)

この例では次の出力が生成されます:

![LaTeX の既定の数式スタイルの変更を示す画像](/files/7a46070a30df0ac3707b959e5e0a46707847108f)

## 連分数

分数を入れ子にすると、より複雑な式を得ることができます。次の例で表示される2組目の分数は、どちらも次の `\cfrac` コマンドを使用しています。これは連分数を生成するために特別に設計されています。\cfrac を使用するには、 `\cfrac` を読み込む必要があります [`amsmath` パッケージ](https://ctan.org/pkg/amsmath?lang=en) を文書のプレアンブルに。

```latex
\documentclass{article}
% 幅を縮小するために geometry パッケージを使用
% ヘルプ記事のグラフィックの幅を
\usepackage[textwidth=9.5cm]{geometry}
% \cfrac{...}{...} コマンドにアクセスするために amsmath を読み込む
\usepackage{amsmath}
\begin{document}
分数は入れ子にできますが、この例では、分母で使われている既定の数式スタイルが理想的な結果を生まないことに注意してください...

\[ \frac{1+\frac{a}{b}}{1+\frac{1}{1+\frac{1}{a}}} \]

\noindent ...そのため、組版を改善するために \verb|\displaystyle| を使います:

\[ \frac{1+\frac{a}{b}} {\displaystyle 1+\frac{1}{1+\frac{1}{a}}} \]

ここに \texttt{amsmath} の \verb|\cfrac| コマンドを使う例があります:

\[
  a_0+\cfrac{1}{a_1+\cfrac{1}{a_2+\cfrac{1}{a_3+\cdots}}}
\]

ここに、\texttt{amsmath} のドキュメントからの別の例があります。これは、左
および右への分子の配置を、\verb|\cfrac[l]| と \verb|\cfrac[r]| をそれぞれ使って示します:
\[
\cfrac[l]{1}{\sqrt{2}+
\cfrac[r]{1}{\sqrt{2}+
\cfrac{1}{\sqrt{2}+\dotsb}}}
\]
\end{document}
```

[この例を Overleaf で開く。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+of+continued+fractions\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+to+reduce%0A%25+the+width+of+help+article+graphics%0A%5Cusepackage%5Btextwidth%3D9.5cm%5D%7Bgeometry%7D%0A%25+Load+amsmath+to+access+the+%5Ccfrac%7B...%7D%7B...%7D+command%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0AFractions+can+be+nested+but%2C+in+this+example%2C+note+how+the+default+math+styles%2C+as+used+in+the+denominator%2C+don%27t+produce+ideal+results...%0A%0A%5C%5B+%5Cfrac%7B1%2B%5Cfrac%7Ba%7D%7Bb%7D%7D%7B1%2B%5Cfrac%7B1%7D%7B1%2B%5Cfrac%7B1%7D%7Ba%7D%7D%7D+%5C%5D%0A%0A%5Cnoindent+...so+we+use+%5Cverb%7C%5Cdisplaystyle%7C+to+improve+typesetting%3A%0A%0A%5C%5B+%5Cfrac%7B1%2B%5Cfrac%7Ba%7D%7Bb%7D%7D+%7B%5Cdisplaystyle+1%2B%5Cfrac%7B1%7D%7B1%2B%5Cfrac%7B1%7D%7Ba%7D%7D%7D+%5C%5D%0A%0AHere+is+an+example+which+uses+the+%5Ctexttt%7Bamsmath%7D+%5Cverb%7C%5Ccfrac%7C+command%3A%0A%0A%5C%5B%0A++a_0%2B%5Ccfrac%7B1%7D%7Ba_1%2B%5Ccfrac%7B1%7D%7Ba_2%2B%5Ccfrac%7B1%7D%7Ba_3%2B%5Ccdots%7D%7D%7D%0A%5C%5D%0A%0AHere+is+another+example%2C+derived+from+the+%5Ctexttt%7Bamsmath%7D+documentation%2C+which+demonstrates+left%0Aand+right+placement+of+the+numerator+using+%5Cverb%7C%5Ccfrac%5Bl%5D%7C+and+%5Cverb%7C%5Ccfrac%5Br%5D%7C+respectively%3A%0A%5C%5B%0A%5Ccfrac%5Bl%5D%7B1%7D%7B%5Csqrt%7B2%7D%2B%0A%5Ccfrac%5Br%5D%7B1%7D%7B%5Csqrt%7B2%7D%2B%0A%5Ccfrac%7B1%7D%7B%5Csqrt%7B2%7D%2B%5Cdotsb%7D%7D%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

この例では次の出力が生成されます:

![LaTeX で組版された、分数が入れ子になった図](/files/9cba6453b0b146f58e993db210299423f935154a)

## 最後の例

この例では、より複雑な連分数を示します:

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\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}
  }}}
\]

\end{document}
```

[この例を Overleaf で開く。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=A+more+complex+continued+fraction\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewcommand%2A%7B%5Ccontfrac%7D%5B2%5D%7B%25%0A%7B%0A++%5Crlap%7B%24%5Cdfrac%7B1%7D%7B%5Cphantom%7B%231%7D%7D%24%7D%25%0A++%5Cgenfrac%7B%7D%7B%7D%7B0pt%7D%7B0%7D%7B%7D%7B%231%2B%232%7D%25%0A%7D%0A%7D%0A%5C%5B%0A++a_0+%2B%0A++%5Ccontfrac%7Ba_1%7D%7B%0A++%5Ccontfrac%7Ba_2%7D%7B%0A++%5Ccontfrac%7Ba_3%7D%7B%0A++%5Cgenfrac%7B%7D%7B%7D%7B0pt%7D%7B0%7D%7B%7D%7B%5Cddots%7D%0A++%7D%7D%7D%0A%5C%5D%0A%0A%5Cend%7Bdocument%7D)

この例では次の出力が生成されます:

![LaTeX によって組版された高度な連分数の画像](/files/79c7b8f6aa262abb0fb8bbb625c5053c1b09a45e)

## さらに読む

詳しくは以下を参照してください：

* [数式](/latex/ja/shu-xue/01-mathematical-expressions.md)
* [下付き文字と上付き文字](/latex/ja/shu-xue/02-subscripts-and-superscripts.md)
* [角括弧と丸括弧](/latex/ja/shu-xue/03-brackets-and-parentheses.md)
* [amsmath を使った方程式の整列](/latex/ja/shu-xue/06-aligning-equations-with-amsmath.md)
* [演算子](/latex/ja/shu-xue/07-operators.md)
* [数学フォント](/latex/ja/shu-xue/12-mathematical-fonts.md)
* [LaTeX2εへのそれほど短くない入門](http://www.ctan.org/tex-archive/info/lshort/)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/ja/shu-xue/05-fractions-and-binomials.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
