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

# !h' 浮动体参数被更改为 !ht'

这就是 LaTeX 在将你的浮动体（例如某种图像或图）放置到你在中指定的位置时遇到问题的时候 [浮动体选项](/latex/zh-cn/tu-biao-he-biao-ge/02-positioning-images-and-tables.md) 即 **`ht`** 在 **`\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{引言}
\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{引言}

\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{引言}

\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://overleaf-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.
