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

# !h' float specifier changed to !ht'

This is when LaTeX has a problem placing your float (such as an image or figure of some kind) in the position you have specified in the [float specifier](/latex/figures-and-tables/02-positioning-images-and-tables.md) i.e. the **`ht`** in **`\begin{figure}[ht]`** . LaTeX tries to place figures in a way that fits in with the flow of the text in order to avoid big gaps and bunched up paragraphs. The placement specifier parameter allows us to have a greater control over where a figure is placed. The different placement options available to us are listed below:

| Specifier | Permission                                                                                                                                              |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| h         | Place the float *here*, i.e., *approximately* at the same point it occurs in the source text (however, not *exactly* at the spot)                       |
| t         | Position at the *top* of the page.                                                                                                                      |
| b         | Position at the *bottom* of the page.                                                                                                                   |
| p         | Put on a special *page* for floats only.                                                                                                                |
| !         | Override internal parameters LaTeX uses for determining "good" float positions.                                                                         |
| H         | Places the float at precisely the location in the LaTeX code. Requires the *float* package (*\usepackage{float}*). This is somewhat equivalent to *h!*. |

While LaTeX will do its best to follow the placement we specify, it may not always be possible for it to adhere to it. When LaTeX has trouble placing our float in the desired location, it may override the placement specifier in favor of a new placement specifier which does not break up the flow of text. When this happens, an error message will appear as shown below.

```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}
```

This will generate an error message which looks like

main.tex, line 12

\`h' float specifier changed to \`ht'.

The float specifier **`h`** by itself is usually too strict of a command for LaTeX. To resolve this error, it is best to relax this demand to **`ht`** i.e. place the float either *here* or at the *top* of the page. The demand can even be relaxed further to **`htbp`** or **`!htbp`** if necessary. If you would like to override this replacement and have the figure placed at a specific location in the page, there are some useful ways of doing this listed below.

**Using the float package:**

If we include the **`float`** package in our preamble, then instead of using **`h`** to specify *here* in our float specifier option, we can use the more powerful **`H`**, which will ensure the figure is kept in place.

```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}
```

**Using the placeins package:**

Using the **`placeins`** package, we can use the **`\FloatBarrier`** command. Wherever we put a **`\FloatBarrier`** command, a barrier will be put in place which figures cannot pass through. This means that if we put a **`\FloatBarrier`** command on either side of our figure, it will be locked in place

```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}
```

**Tweaking the parameters:**

In order to tell LaTeX to place figures within the text and not at the end of a chapter (which is default), we adjust the 'float placement' parameters in the preamble to our document. Here are some useful values.

```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/latex-errors/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.
