0

I start a new section on a new page and want to show an image first. I use the figure-environment because it needs a caption, and the [H] option because otherweise Latex places it god knows where.

Yet, the graphic appears at the bottom of the page, not immediately after the header of the section. How to prevent this?

\subsection{Gefaltetes Netz(cnn)}
\begin{figure}[H]
    \centering
    \includegraphics[width=0.5\linewidth]{pictures/nets/cnn.eps}
    \caption{Netzmodell: Gefaltetes Netz}
    \label{net:cnn}
\end{figure}

image

4
  • use \begin{figure}[h] with lowercase h Commented Jan 26, 2019 at 18:23
  • 1
    With the information you have provided this is not reproducible. Please add a minimal working example (MWE) that illustrates the shown behaviour and enables us to reproduce it.
    – leandriis
    Commented Jan 26, 2019 at 18:24
  • 3
    What follows this figure with the [H] float specifier?
    – Werner
    Commented Jan 26, 2019 at 18:28
  • I presume you have \usepackage{float} at your preamble.
    – jotagah
    Commented Jan 27, 2019 at 11:57

2 Answers 2

2

you have not provided any code to reproduce the problem but [H] means the figure will not move it will be positioned exactly as a letter or box at that position will be positioned.

Presumably you have \flushbottom in effect and the only stretch space on that page is after the section head so it has to stretch that space to put ensure that there is no space at the bottom of the page.

So you could use \raggedbottom or note the reason that latex floats figures is to avoid getting ugly white space at page breaks so by using [H] and disabling floats you shoudl expect to get bad space unless you make manual corrections, for example arranging the following text that you did not show so that it fits on to that page under the figure.

0

Without more information about the document class and the packages used I think that the issue can be fixed by replacing \begin{figure}[H] by \begin{figure}[h] .

\documentclass[]{article}
\usepackage{graphicx}

\begin{document}
\subsection{Gefaltetes Netz(cnn)}
\begin{figure}[h]
    \centering
    \includegraphics[width=0.5\linewidth]{pictures/nets/cnn.eps}
    \caption{Netzmodell: Gefaltetes Netz}
    \label{net:cnn}
\end{figure}
\end{document}

enter image description here

As sugested by @David Carlisle here is the same code in which I have replaced \begion{figure}[h] by \begin{figure}[H].

\documentclass[]{article}
\usepackage{graphicx}

\begin{document}
\subsection{Gefaltetes Netz(cnn)}
\begin{figure}[h]
    \centering
    \includegraphics[width=0.5\linewidth]{pictures/nets/cnn.eps}
    \caption{Netzmodell: Gefaltetes Netz}
    \label{net:cnn}
\end{figure}
\end{document}

the output is totally different

enter image description here


\documentclass[]{book}
\usepackage{graphicx}
\usepackage{float}

\begin{document}
\subsection{Gefaltetes Netz(cnn)}
\begin{figure}[H]
    \centering
    \includegraphics[width=0.5\linewidth]{example-image}
    \caption{Netzmodell: Gefaltetes Netz}
    \label{net:cnn}
\end{figure}

\section{Zzzz}

    \includegraphics[width=0.5\linewidth, height=.7\textheight]{example-image-b}
\end{document}
15
  • This is unlikely to solve the OPs problem as stretching the space means that it is using \flushbottom but this example is using \raggedbottom, and also the implicit \clearpage at \end{document} both of which mean that whte space in the page will not stretch. Commented Jan 26, 2019 at 18:45
  • @DavidCarlisle Thanks for your interest! I don't understand why this is unlikely to solve the problem since it seems to me that what is needed is a figure placed just after the \subsection title Commented Jan 26, 2019 at 20:27
  • take your example, and use [H] after adding the float package and you will see that the [H] float comes exactly as you show with h. You need an example where [H] comes at the bottom of the page and [h]` does not, but that might be hard to find. (Also you should never use [h], LaTeX usually warns about that and changes it to [ht].) Commented Jan 26, 2019 at 22:06
  • Hi@DavidCarlisle I have updated my answer where I followed your suggestion. As you can see the position of the float has changed. Commented Jan 27, 2019 at 6:33
  • But the code example is the same. Doesn't make any sense.
    – Johannes_B
    Commented Jan 27, 2019 at 6:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .