Float Picture - pmdacosta/notes GitHub Wiki

In LaTeX, figures are typically "floated" by default, meaning that LaTeX will decide where to place them based on various factors such as page layout and optimization of space. However, if you want a figure to appear exactly where it's defined in the LaTeX document, you can use the H specifier from the float package or the float package's H option:

  1. Using the float package with the [H] specifier:

    First, include the float package in your LaTeX document's preamble:

    \usepackage{float}
    

    Then, when defining your figure, use the [H] specifier in the \begin{figure} command:

    \begin{figure}[H]
        % Your figure content here
        \caption{Your figure caption}
        \label{fig:yourlabel}
    \end{figure}
    

    This will force LaTeX to place the figure exactly where it's defined in the document.

  2. Using the float package with the H option:

    Alternatively, you can pass the H option to the float package when including it in the preamble:

    \usepackage[H]{float}
    

    With this option enabled, all figures will automatically behave as if they were defined with the [H] specifier.

Using [H] or the H option will prevent LaTeX from floating the figure and will place it precisely where it's defined in the document. However, keep in mind that this might affect the layout of your document, especially if there's limited space. Use this feature judiciously, especially if you're dealing with large figures or many of them, as it might lead to suboptimal page layouts.