0

I have a Latex section that has text and a bunch of added images. Some text followed by an image is leaving a huge blank space between the text and the image. This happens everytime an image appears for this section.

\usepackage{float} is already added. And I have already tried changing [H] for [h] or [h!] in the following code:

\begin{figure}[h!]
\begin{center}
  \includegraphics[scale=0.5]{van_gogh.jpg}
  \label{fig:VanGogh}
    \caption{Imagen}
 \end{center}
\end{figure}

What can I now do to try to fix this?

This is how it looks: blank space

THANKS

Ofelia y Orquesta
  • 153
  • 1
  • 1
  • 6

2 Answers2

4

You don't have to float an image if you don't want to. Float means "let LaTeX decide where it goes", i.e. the position "floats" and isn't fixed. If you're wanting "H!" or similar, really, you don't want a float (and indeed, afaik, "h!" basically doesn't do anything). Use the caption package, and its captionof command to turn any environment (like the center environment) into a figure.

The figure will now appear exactly where it appears in the text, and the text will flow around it normally. Sounds like LaTeX is putting your figure on a float page right now.

\begin{center}
  \includegraphics[scale=0.5]{van_gogh.jpg}
  \captionof{figure}{Imagen}
  \label{fig:VanGogh}
\end{center}
  • it didn't work :( – Ofelia y Orquesta Mar 15 '21 at 07:28
  • 3
    @OfeliayOrquesta in your question and here you just say "It didn't work" but these commands work as designed. They may not do what you expected, but we do not know what you expect. You need to provide example code that we can run, and say exactly what error you got. – David Carlisle Mar 15 '21 at 08:49
1

Withou a full MWE it is hard to reproduce your problem. So I can not exactly reproduce what you mean with "huge blank space between the text and the image". [h],[H] etc. influence the position of a float not the space beneath it. If you want to reduce the space between a figure and the text below like I in Figure A, you can achieve this with \vspace{value}. I made a new command to reduce the space \newcommand{\redspace}{\vspace{-4.5mm}}. As you can see in figure B.

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\newcommand{\redspace}{\vspace{-4.5mm}} % adjust space value to your needs

\begin{document}

\lipsum[1]
\begin{figure}[h!]
    \begin{center}
        \includegraphics[scale=0.5]{example-image-a}
        \label{fig:VanGogh}
        \caption{Imagen}
    \end{center}
\end{figure}

\lipsum[1]

    \lipsum[1]
\begin{figure}[h!]
    \begin{center}
        \includegraphics[scale=0.5]{example-image-a}
        \label{fig:VanGogh}
        \caption{Imagen}
    \end{center}
\redspace
\end{figure}
\lipsum[1]

\end{document}

enter image description here

Roland
  • 6,655
  • It got fixed only when using \lipsum[1] , but if I remove it and substitute it with \redspace it still leaves a blank space of the size of a paragraph. The space appears before the image: text - space - image, and not after the image. It would be difficult to give a short code for this text which is 80 pages long, but I edited my question. – Ofelia y Orquesta Mar 15 '21 at 07:06
  • 1
    Could you provide a MWE. I cannot reproduce your space problem. When I type for exampe Text -- \vspace{-3mm} or \redspace -- Image -- \vspace{-3mm} or \redspace -- Text. the space is reduced. independent from \lispum[1], it just adds text. – Roland Mar 15 '21 at 07:11
  • yes, \lipsum[1] adds a Lorem Ipsum text, I noticed. Space was removed when adding text in this way, but not without it. If I don't get fix this, I will try to provide a small example reproducing the problem. – Ofelia y Orquesta Mar 15 '21 at 07:18
  • I re edited the question, and copied the packages that I am currently using. As the document is using several images, IDK how would I provide a brief example. Thanx for the suggestion you already did. It helped, becaused it occured to me that that could be a solution, but it wasn't. – Ofelia y Orquesta Mar 15 '21 at 07:41
  • sorry but it absolutely wrong to use a vspace in the main document flow and a figure that is taken out of the document flow to be re-inserted elsewhere. The cspace will be left spacing the paragraphs at that point unless you get accidentally lucky and the figure is inserted next to the space node created by the vspace. – David Carlisle Mar 15 '21 at 08:48