> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-pro.ayaka.space/latex/ja/sononotopikku/50-wrapping-text-around-figures.md).

# 図の周りにテキストを回り込ませる

場合によっては、テキストの流れを崩さないように、フロート（ここでは図）の周りに本文を回り込ませたいことがあります。この作業を実現するための LaTeX パッケージはいくつかありますが、ほとんどの場合、ある程度の手動調整が必要です。

### wrapfig の使用

を使うには *wrapfig*、プリアンブルに次の行を含める必要があります：

```latex
\usepackage{wrapfig}
```

これにより *wrapfigure* 環境が利用可能になり、その中に *\includegraphics* コマンドを入れて、本文が回り込む図を作成できます。以下のように *wrapfigure* 環境に入れます：

```latex
\begin{wrapfigure}[lineheight]{position}{width}
  ...
\end{wrapfigure}
```

次の *position* パラメータには8つの値があります：

|     |   |                             |
| --- | - | --------------------------- |
| r   | R | テキストの右側                     |
| l   | L | テキストの左側                     |
| i   | I | 内側の端—綴じ部に近い側（ *twoside* 文書） |
| または | O | 外側の端—綴じ部から遠い側               |

大文字版では図をフロートさせることができます。小文字版は *まさにこの位置*.

例を示します：

```latex
\begin{wrapfigure}{r}{0.5\textwidth}
  \begin{center}
    \includegraphics[width=0.48\textwidth]{birds}
  \end{center}
  \caption{Birds}
\end{wrapfigure}
```

画像の幅は本文の幅（*\textwidth*）を基準に指定されていたことに注意してください。長さ（高さ、幅など）を定義する際は相対値を使うのが良い考えです。特に *wrapfigure*.

上の例では、図はちょうど本文幅の半分を覆い、実際の画像はそれより少し小さい幅を使っているので、画像と本文の間に心地よい小さな白い余白ができます。画像は常に回り込み領域より小さく（幅が狭く）する必要があります。そうでないと本文にはみ出します。

wrapfigures を追加するときは注意してください *wrapfigures* ページの最上部や最下部のすぐ近くに置くと、解決が難しい、あるいはほぼ不可能な望ましくない影響を招くことがよくあるためです。 *wrapfigures* 数式や節見出しのそばで使うことは勧められません。また、次のようなリスト環境でも使えません： `itemize` と `enumerate` 環境。

[Overleaf で例を開く](https://www.overleaf.com/project/new/template/19663?id=66518064\&templateName=Example+of+positioning+tables+and+figures\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

### 余白のある画像への対処

画像に望ましくない余白がある場合、余分な空白を取り除くために次のいずれかの方法を使えます：

* *trim* を使用するときに空白をトリムする
* 次の *picins* パッケージは *wrapfigure*の代わりに使用できます。これにより、手動調整なしで最初から余分な空白を取り除けます。
* パッケージ *floatflt* も別の代替手段です。
* を使って画像を中央揃えするのは避けてください。 *\begin{center}* を使うと余分な空白が追加されます。代わりに *\centering* を使ってください。
* プログラム *pdfcrop* （ほとんどの TeX インストールに含まれています）は、空白を恒久的に削除するために使用できます。


---

# 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://ayakaleaf-pro.ayaka.space/latex/ja/sononotopikku/50-wrapping-text-around-figures.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.
