> 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/02-table-of-contents.md).

# 目次

LaTeX 文書では、目次を自動生成でき、特定のスタイルに合わせて変更することもできます。この記事ではその方法を説明します

## はじめに

目次を作成するのは簡単で、コマンド `\tableofcontents` がその役割を果たします。セクション、サブセクション、章は目次に含まれます。番号なしセクションなど、項目を手動で追加するには、コマンド `\addcontentsline` を使用します。以下の例に示すように:

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{titlesec}
\title{セクションと章}
\author{グバート・ファーンズワース}
\date{ }
\begin{document}

\maketitle

\tableofcontents

\section{はじめに}

これは最初のセクションです。

\blindtext

\addcontentsline{toc}{section}{番号なしセクション}
\section*{番号なしセクション}

\blindtext

\section{第2セクション}

\blindtext
\end{document}
```

[この例を Overleaf で開く](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Table+of+contents+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cusepackage%7Btitlesec%7D%0A%5Ctitle%7BSections+and+Chapters%7D%0A%5Cauthor%7BGubert+Farnsworth%7D%0A%5Cdate%7B+%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cmaketitle%0A%0A%5Ctableofcontents%0A%0A%5Csection%7BIntroduction%7D%0A%0AThis+is+the+first+section.%0A%0A%5Cblindtext%0A%0A%5Caddcontentsline%7Btoc%7D%7Bsection%7D%7BUnnumbered+Section%7D%0A%5Csection%2A%7BUnnumbered+Section%7D%0A%0A%5Cblindtext%0A%0A%5Csection%7BSecond+Section%7D%0A%0A%5Cblindtext%0A%5Cend%7Bdocument%7D)

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

![LaTeX で生成された目次の例](/files/750d1510b795df64869f48322049c657385eef26)

## 目次のタイトルを変更する

目次の既定タイトルは **Contents**です。次の例が示すように、必要に応じて任意のものに変更できます:

```latex
\documentclass{article}
\title{セクションと章}
\author{グバート・ファーンズワース}
\date{ }
\renewcommand*\contentsname{要約}
\begin{document}
\maketitle
\tableofcontents
\section{はじめに}

これは最初のセクションです。

Lorem  ipsum  dolor  sit  amet,  consectetuer  adipiscing
elit.   Etiam  lobortisfacilisis sem.  Nullam nec mi et
neque pharetra sollicitudin.  Praesent imperdietmi nec ante.
Donec ullamcorper, felis non sodales...

\addcontentsline{toc}{section}{番号なしセクション}
\section*{番号なしセクション}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem.  Nullam nec mi et neque pharetra
sollicitudin.  Praesent imperdiet mi necante...

\section{第2セクション}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem.  Nullam nec mi et neque pharetra
sollicitudin.  Praesent imperdiet mi necante...
\end{document}
```

[この例を Overleaf で開く](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=How+to+change+title+of+table+of+contents\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7BSections+and+Chapters%7D%0A%5Cauthor%7BGubert+Farnsworth%7D%0A%5Cdate%7B+%7D%0A%5Crenewcommand%2A%5Ccontentsname%7BSummary%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Ctableofcontents%0A%5Csection%7BIntroduction%7D%0A+++%0AThis+is+the+first+section.%0A++++++%0ALorem++ipsum++dolor++sit++amet%2C++consectetuer++adipiscing++%0Aelit.+++Etiam++lobortisfacilisis+sem.++Nullam+nec+mi+et+%0Aneque+pharetra+sollicitudin.++Praesent+imperdietmi+nec+ante.+%0ADonec+ullamcorper%2C+felis+non+sodales...%0A+++++++%0A%5Caddcontentsline%7Btoc%7D%7Bsection%7D%7BUnnumbered+Section%7D%0A%5Csection%2A%7BUnnumbered+Section%7D%0A%0ALorem+ipsum+dolor+sit+amet%2C+consectetuer+adipiscing+elit.++%0AEtiam+lobortis+facilisissem.++Nullam+nec+mi+et+neque+pharetra+%0Asollicitudin.++Praesent+imperdiet+mi+necante...%0A%0A%5Csection%7BSecond+Section%7D%0A+++++++%0ALorem+ipsum+dolor+sit+amet%2C+consectetuer+adipiscing+elit.++%0AEtiam+lobortis+facilisissem.++Nullam+nec+mi+et+neque+pharetra+%0Asollicitudin.++Praesent+imperdiet+mi+necante...%0A%5Cend%7Bdocument%7D)

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

![LaTeX での目次名の変更](/files/1e4fb4a08abf6be2c515599f94adb74c835d04b3)

この行 `\renewcommand*\contentsname{要約}` では、既定値の代わりに "Summary" が書き込まれます。パッケージ *babel* を [国際言語サポート](/latex/ja/yan-yu/03-international-language-support.md)に使用している場合、前述のコマンドは

```latex
\addto\captionsenglish{ }
```

の中括弧内に置かなければなりません。 `\captionenglish` の English の代わりに、babel で設定した言語名を記入してください。

## さらに読む

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

* [LaTeX で文書を作成する](/latex/ja/latexno/01-learn-latex-in-30-minutes.md)
* [太字、斜体、下線](/latex/ja/latexno/03-bold-italics-and-underlining.md)
* [国際言語サポート](/latex/ja/yan-yu/03-international-language-support.md)
* [セクションと数式の相互参照](/latex/ja/wen-shu-gou-zao/03-cross-referencing-sections-equations-and-floats.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/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/03-page-numbering.md)
* [片面印刷と両面印刷の文書](/latex/ja/shu-shi-she-ding/08-single-sided-and-double-sided-documents.md)
* [複数列](/latex/ja/shu-shi-she-ding/09-multiple-columns.md)
* [カウンタ](/latex/ja/shu-shi-she-ding/10-counters.md)
* [フォントサイズ、書体、スタイル](/latex/ja/fonto/01-font-sizes-families-and-styles.md)


---

# 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/02-table-of-contents.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.
