`!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 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.
\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
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.
\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
\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.
\renewcommand\topfraction{.9}
\renewcommand\textfraction{0.35}
\renewcommand\floatpagefraction{0.8}
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Debugging Compilation timeout errors
- How-to guides
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips