0

I'm trying to add a new image to my document but whenever I add an image and there is no enough space for this image I have a white space in the previous text. my code:

Exampel text bla bla bla
\begin{figure}[H]
   \begin{center}
   \includegraphics[width=0.6\textwidth]{image.JPG}
   \caption{Modellierung der Trajektorien \cite{example}}
   \label{fig: example}
   \end{center}
\end{figure}
Bernard
  • 271,350
jon
  • 37
  • 1
    The main idea about the figure environment is that it is allowed to “float” in order to avoid pagination problems. With [H] you're overriding the mechanism. Don't, use [htp]. And no center environment, but rather the \centering declaration. – egreg Apr 04 '21 at 15:09
  • Unrelated: counterintuitively don't use the center env to center inside floats. It add vertical space above and below, as does e.g. the figure env. Replace \begin{center} with \centering and remove \end{center}. Personally I would also recommend not having spaces in labels. – daleif Apr 04 '21 at 15:13
  • I did what @egreg recommended and it worked but now I have a problem that the image instead of positioning itself in the right place it positions itself in the middle of the next page. What should I do – jon Apr 04 '21 at 15:17
  • that because I did use the [htp] – jon Apr 04 '21 at 15:18
  • [H] is an explicit request to get bad white space rather than allow the float to be floated (moved) – David Carlisle Apr 04 '21 at 15:18
  • that is the purpose of using a float environment: to allow the figure to move to a place where it fits. – Ulrike Fischer Apr 04 '21 at 15:19
  • Never rely on a figure being right here. Instead always refer to it by number (hence the \label you place. So use See Figure~\ref{fig: example}. This way the paper is being used most efficiently. – daleif Apr 04 '21 at 15:25
  • @daleif sounds good – jon Apr 04 '21 at 15:27
  • "positioning itself in the right place" Which place is the right place? If you mean just where it is in the source text at any cost, then [H] is exactly what you want, but if the image is too big, there are no other choice that move the figure to the next page. If you want to avoid the huge spaces, is up to you move the figure code to the next page, where are enough space or much easier, just remove [H]. Probably the figure is the middle of the next page because the only content in the last page, but this is not a problem, but the solution. – Fran Apr 05 '21 at 02:44
  • related: https://tex.stackexchange.com/questions/28556/how-to-place-a-float-at-the-top-of-a-floats-only-page – Fran Apr 05 '21 at 02:59

0 Answers0