# 目次

- Human documentation: [https://docs.univer.ai/ja-JP/guides/docs/features/table-of-contents](https://docs.univer.ai/ja-JP/guides/docs/features/table-of-contents)

- Agent Markdown: [https://docs.univer.ai/ja-JP/guides/docs/features/table-of-contents.md](https://docs.univer.ai/ja-JP/guides/docs/features/table-of-contents.md)

- Requested language: `ja-JP`

- Content language: `ja-JP`

- Documentation version: `1.1.0`

- Source: [docs/features/table-of-contents.ja-JP.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/docs/features/table-of-contents.ja-JP.mdx)

---

目次は見出しの一覧を文書本文に挿入します。アウトラインのナビゲーションとは別の機能です。Docs Core の設定に次のプラグインを追加し、文書作成前に UI ロケールを `locales` にマージして CSS を読み込みます。Core と Advanced プリセットには含まれません。

#### npm

```bash
npm install @univerjs/docs-toc @univerjs/docs-toc-ui
```

#### pnpm

```bash
pnpm add @univerjs/docs-toc @univerjs/docs-toc-ui
```

#### yarn

```bash
yarn add @univerjs/docs-toc @univerjs/docs-toc-ui
```

#### bun

```bash
bun add @univerjs/docs-toc @univerjs/docs-toc-ui
```

```ts
import { UniverDocsTocPlugin } from '@univerjs/docs-toc'
import { UniverDocsTocUIPlugin } from '@univerjs/docs-toc-ui'
import FeatureLocale from '@univerjs/docs-toc-ui/locale/ja-JP'
import { LocaleType } from '@univerjs/core'

import '@univerjs/docs-toc-ui/lib/index.css'

univerAPI.loadLocales(LocaleType.JA_JP, FeatureLocale)

univer.registerPlugin(UniverDocsTocPlugin)
univer.registerPlugin(UniverDocsTocUIPlugin)
```

## 挿入と更新

挿入前に文書内へカーソルを置きます。UI から挿入、全体更新、ページ番号のみの更新、削除を実行できます。`rangeId` を省略すると現在の選択位置の目次を更新します。

```ts
import { InsertTableOfContentsCommand, UpdateTableOfContentsCommand } from '@univerjs/docs-toc'

await univerAPI.executeCommand(InsertTableOfContentsCommand.id, {
  levels: 3,
  showPageNumbers: true,
  rightAlignPageNumbers: true,
})
await univerAPI.executeCommand(UpdateTableOfContentsCommand.id, { mode: 'entireTable' })
```

更新処理はアウトラインレベルの目次命令（`\o`）を評価します。その他の Word スイッチは FIELD メタデータに保持されますが、すべてが計算されるわけではありません。[コマンド引数](https://docs.univer.ai/ja-JP/reference/packages/plugins/univerjs/docs-toc.md)も参照してください。
