> 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/latex-cuo-wu/01-h-float-specifier-changed-to-ht.md).

# 浮动体指定符 !h' 已更改为 !ht'

这是 LaTeX 在将您的浮动体（例如图像或某种图形）放置到您在 [浮动体限定符](/latex/zh-cn/tu-xing-he-biao-ge/02-positioning-images-and-tables.md) 即 **`ht`** .bib 文件中插入一个 % **`\begin{figure}[ht]`** 中指定的位置时出现问题的时候。LaTeX 会尽量以符合正文流动的方式放置图形，以避免出现大段空白或段落过于拥挤。位置限定符参数使我们能够更好地控制图形的放置位置。下面列出了可用的不同放置选项：

| 限定符 | 允许                                                                           |
| --- | ---------------------------------------------------------------------------- |
| h   | 放置浮动体 *此处*，即， *大致* 在它出现在源文本中的同一位置（不过，不 *精确地* 在那个位置）                          |
| t   | 位置于 *顶部* 的页面。                                                                |
| b   | 位置于 *底部* 的页面。                                                                |
| p   | 放到一个专门的 *page* 仅供浮动体使用的页面上。                                                  |
| !   | 覆盖 LaTeX 用于确定“合适”浮动体位置的内部参数。                                                 |
| H   | 将浮动体精确放置在 LaTeX 代码中的该位置。需要 *float* 宏包（*\usepackage{float}*）。这在某种程度上等同于 *h!*. |

虽然 LaTeX 会尽力遵循我们指定的放置方式，但它并不总是能够照做。当 LaTeX 难以将浮动体放在期望的位置时，它可能会改用一个不会打断正文流动的新位置限定符来替代原来的限定符。这种情况发生时，会出现如下所示的错误信息。

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}

\begin{document}

\section{Introduction}
\vspace{10cm}

\begin{figure}[h]
    \centering
    \includegraphics{image.PNG}
\end{figure}

\end{document}
```

这将生成如下所示的错误信息

main.tex，第 12 行

\`h' 浮动体限定符已改为 \`ht'。

浮动体限定符 **`h`** 单独使用通常对 LaTeX 来说过于严格。为了解决这个错误，最好将这一要求放宽为 **`ht`** 即将浮动体放在 *此处* 或放在 *顶部* 页面的。这个要求甚至可以进一步放宽为 **`htbp`** 或 **`!htbp`** （如有必要）。如果您想要覆盖这种替换，并让图形放置在页面中的特定位置，下面列出了一些有用的方法。

**使用 float 宏包：**

如果我们在导言区包含 **`float`** 宏包，那么我们不使用 **`h`** 来指定 *此处* 在浮动体限定符选项中指定，而是可以使用更强大的 **`H`**，这将确保图形保持在原位。

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float}

\begin{document}

\section{Introduction}

\begin{figure}[H]
    \centering
    \includegraphics{image.PNG}
\end{figure}

\end{document}
```

**使用 placeins 宏包：**

使用 **`placeins`** 宏包，我们可以使用 **`\FloatBarrier`** 命令。无论我们在哪里放置一个 **`\FloatBarrier`** 命令，都会设置一道屏障，图形无法穿过。这意味着如果我们在 **`\FloatBarrier`** 命令放在图形的任一侧，它就会被固定在原位

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{placeins}

\begin{document}

\section{Introduction}

\FloatBarrier
\begin{figure}
    \centering
    \includegraphics{image.PNG}
\end{figure}

\FloatBarrier
\end{document}
```

**调整参数：**

为了让 LaTeX 将图形放在正文中，而不是放在章节末尾（默认行为），我们在文档导言区调整“浮动体放置”参数。以下是一些有用的值。

```latex
\renewcommand\topfraction{.9}
\renewcommand\textfraction{0.35}
\renewcommand\floatpagefraction{0.8}
```


---

# 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/latex-cuo-wu/01-h-float-specifier-changed-to-ht.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.
