> 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/zh-cn/wen-da/15-how-can-i-get-my-table-or-figure-to-stay-where-they-are-instead-of-going-to-the-next-page.md).

# 如何让表格或图片停留在当前位置，而不是跑到下一页？

通常与 `\begin{figure}` 或 `\begin{table}` 即 *浮动体*，默认的位置标识符是 `[btp]`，这意味着 LaTeX 允许将图放在 \*\*`b`\*\*页底；\*\*`t`\*\*页顶；或者如果该浮动体相当高（包括标题），则会单独放在一个浮动 \*\*`p`\*\*页，且不含任何文本。这遵循专业排版和出版的惯例（也就是 TeX 的用途），其中诸如图和表之类的“浮动材料”只允许放在这些位置：如果它们被放在页面中间，就会被认为会打断阅读流。

不过，我们仍然可以影响希望图出现的位置。如果你添加 `[hbt!]` 在 `\begin{figure}`，像这样：

```latex
\begin{figure}[hbt!]
```

之后，这会告诉 LaTeX 将图片放在这里（尽可能靠近源代码中的位置）；或者如果这不可能（例如它太大，无法放入当前页面），则放到下一页顶部，或下一页底部。感叹号 **`!`** 很重要：它告诉 LaTeX“请务必在这里尽量尊重我的选择”。

不过，如果你的图很高，而当前页面没有足够空间（例如已经接近当前页末尾），那么该图仍会被移到下一页顶部。在这种情况下，你可以尝试把你的 `\begin{figure}[hbt!]...\end{figure}` 代码往前移动几个段落，放到那时当前页还有更多可用空间的位置。

如果这仍然不行，而你的图/表已经继续向前浮动，出现在下一个 `\section` 标题之后，那么你可能更希望它们仍然出现在当前节的末尾。此时你可以在下一个 `\clearpage` 之前发出一个 `\section` 以插入一个分页符，这也会在下一个 `\section` 标题被打印到新页面之前输出队列中的所有浮动体。

另外，可以看看 [`placeins` 宏包](http://texdoc.net/pkg/placeins)，在其中你可以添加 `\FloatBarrier` 之前发出一个 `\section`——或者通过使用 `section` 包选项来自动化此操作，即写作 `\usepackage[section]{placeins}` 到你的导言区中。


---

# 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/zh-cn/wen-da/15-how-can-i-get-my-table-or-figure-to-stay-where-they-are-instead-of-going-to-the-next-page.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.
