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

# 「!h'」浮動體指定符號變更為「!ht'」

這就是 LaTeX 在將你的浮動體（例如圖片或某種圖形）放置到你在以下內容中指定的位置時遇到問題的時候 [浮動體位置指定符](/latex/zh-tw/tu-biao-yu-biao-ge/02-positioning-images-and-tables.md) 也就是 **`ht`** 中插入一個 **`\begin{figure}[ht]`** . LaTeX 會盡量以符合文字流動的方式來放置圖形，以避免出現大空白和段落擠在一起的情況。位置指定參數讓我們能更精確地控制圖形的放置位置。可用的不同放置選項如下：

| 指定符    | 允許                                                                          |
| ------ | --------------------------------------------------------------------------- |
| h      | 放置浮動體 *這裡*，也就是， *大約* 在其出現在原始文字中的同一位置（不過，並非 *精確地* 就在該位置）                     |
| 的區域變數中 | 位置於 *頂端* 頁面頂端。                                                              |
| 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-tw/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.
