> 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/wen-shu-gou-zao/03-cross-referencing-sections-equations-and-floats.md).

# 節、数式、浮動体の相互参照

文書内の番号付き要素（数式、節、図など）への相互参照を挿入する必要がある場合、LaTeX にはそれを自動化するコマンドがあります。この記事ではその方法を説明します。

## はじめに

以下に、図のキャプション番号で相互参照された図の簡単な例を示します:

```latex
\section{はじめに} \label{introduction}
これはダミーテキストを含む導入段落です。この節は後で参照されます。

\begin{figure}[h]
\centering
\includegraphics[width=0.3\linewidth]{overleaf-logo}
\caption{この画像は下で参照されます。}
\label{fig:leaf}
\end{figure}

画像を参照できます。たとえば、図 \ref{fig:leaf} では \textit{Overleaf} のロゴが示されています。
```

![CrossReferencesEx1Overleaf.png](/files/0aa61001021840744e84270379e10423245ec830)

コマンド `\label{ }` は、キャプションの後に識別子を設定するために使われ、その後でコマンド `\ref{ }` を使って参照を設定します。

[Overleaf で例を開く](https://www.overleaf.com/project/new/template/19401?id=65465598\&templateName=Cross+referencing+example\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

## 節と章の参照

以下は、節を参照する方法の例です

```latex
\section{はじめに} \label{introduction}
これはダミーテキストを含む導入段落です。この節は後で参照されます。

\begin{figure}[h]
\centering
\includegraphics[width=0.3\linewidth]{overleaf-logo}
\caption{この画像は下で参照されます。}
\label{fig:leaf}
\end{figure}

画像を参照できます。たとえば、図 \ref{fig:leaf} では \textit{Overleaf} のロゴが示されています。
\vspace{0.5cm}

\section{数式の参照} \label{mathrefs}
\ref{introduction} で述べたように、文書内ではさまざまな要素を参照できます。
```

![CrossReferencesEx3Overleaf.png](/files/8b9780d7b7f0db6a80078273e3679b8effe65c88)

繰り返しますが、コマンド `\label` や `\ref` は参照に使われます。次の *label* はその後に設定されます `\section` 文、つまり `\label` コマンドは、節のカウンタ番号が生成された後に追加する必要があります。これは章、小節、さらに小小節でも機能します。参照してください [セクションと章](/latex/ja/wen-shu-gou-zao/01-sections-and-chapters.md).

[Overleaf で例を開く](https://www.overleaf.com/project/new/template/19401?id=65465598\&templateName=Cross+referencing+example\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

## 数式、図、表の参照

その [導入](#introduction) では、画像の参照例を示しましたが、以下では数式の相互参照を紹介します。

```latex
\section{数式の参照} \label{mathrefs}
\ref{introduction} で述べたように、文書内ではさまざまな要素を参照できます。

\subsection{冪級数} \label{subsection}

\begin{equation} \label{eq:1}
\sum_{i=0}^{\infty} a_i x^i
\end{equation}

式 \ref{eq:1} は典型的なべき級数です。
```

![CrossReferencesEx2Overleaf.png](/files/d5e46afbd051c2a3ef16ffbdd455f03c14c21ae1)

ラベルと参照を使った、さらに柔軟な例については、

* [amsmath を使った方程式の整列](/latex/ja/shu-xue/06-aligning-equations-with-amsmath.md)
* [表](/latex/ja/to/01-tables.md)
* [画像の挿入](/latex/ja/sononotopikku/27-inserting-images.md)

[Overleaf で例を開く](https://www.overleaf.com/project/new/template/19401?id=65465598\&templateName=Cross+referencing+example\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

## 要素のページを参照する

要素は通常、それぞれに割り当てられた番号で参照されますが、必要であれば、それらが表示されているページを挿入できます。

```latex
\section{数式の参照} \label{mathrefs}
\ref{introduction} で述べたように、文書内ではさまざまな要素を参照できます。

\subsection{冪級数} \label{subsection}

\begin{equation} \label{eq:1}
\sum_{i=0}^{\infty} a_i x^i
\end{equation}

式 \ref{eq:1} は典型的なべき級数です。
\vspace{0.5cm}

%\Blindtext

\section{最後の節}
ページ \pageref{eq:1} の小節 \ref{subsection} では、冪級数の例が示されました。
```

![CrossReferencesEx4Overleaf.png](/files/0653bd7d889c76a6aa261cdc299b7156208f8b3a)

コマンド `\pageref` は、その要素があるページを挿入します。該当する要素の *label* が使われている場所が表示されます。上の例では式 1 です。このコマンドは、この記事で触れた他のすべての番号付き要素にも使用できます。

[Overleaf で例を開く](https://www.overleaf.com/project/new/template/19401?id=65465598\&templateName=Cross+referencing+example\&latexEngine=\&texImage=texlive-full%3A2020.1\&mainFile=)

## 相互参照付き文書のコンパイル

Overleaf では相互参照はすぐに機能しますが、ローカルの LaTeX 環境で相互参照を正しく機能させるには、文書を 2 回コンパイルする必要があります。また、すべての参照が機能するように自動で処理してくれるコマンドもあります。たとえば、文書が次のように保存されている場合 `main.tex`.

`latexmk -pdf main.tex`

次のファイルを生成します `main.pdf` すべての相互参照が機能する状態で。出力形式を変更するには `-dvi` または `-ps`.

## さらに読む

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

* [LaTeXで文書を作成する](/latex/ja/latexno/01-learn-latex-in-30-minutes.md)
* [数式](/latex/ja/shu-xue/01-mathematical-expressions.md)
* [amsmath を使った方程式の整列](/latex/ja/shu-xue/06-aligning-equations-with-amsmath.md)
* [画像の挿入](/latex/ja/sononotopikku/27-inserting-images.md)
* [画像と表の配置](/latex/ja/to/02-positioning-images-and-tables.md)
* [索引](/latex/ja/wen-shu-gou-zao/04-indices.md)
* [用語集](/latex/ja/wen-shu-gou-zao/05-glossaries.md)
* [目次](/latex/ja/wen-shu-gou-zao/02-table-of-contents.md)
* [大規模プロジェクトでの管理](/latex/ja/wen-shu-gou-zao/07-management-in-a-large-project.md)
* [複数ファイルの LaTeX プロジェクト](/latex/ja/wen-shu-gou-zao/08-multi-file-latex-projects.md)
* [ハイパーリンク](/latex/ja/wen-shu-gou-zao/09-hyperlinks.md)
* [カウンタ](/latex/ja/shu-shi-she-ding/10-counters.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/wen-shu-gou-zao/03-cross-referencing-sections-equations-and-floats.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.
