0

I am writing an article for the first time with Latex, I am using Overleaf as an online editor. I want to avoid unecessary spaces in my article which are the result of figures and adjustment. For example:

enter image description here

We can see how there are many vertical space between the figure and the text, for the next page is the output also in this way:

enter image description here

Solution that I've tried:

  • Reduce the size of the image: not optimal because it won't be readable
  • Change the float position of the figure from [H] to [h]: it didn't fix the problem, spaces still persist The code used for the first figure and text is :
    \begin{figure}[H]
    \begin{center}
    \setlength{\belowcaptionskip}{0pt}
    \includegraphics[scale=0.8]{images/comparison2.png}
    \centering
    \caption{ORKG Interface for comparison between contribution}
    \vspace{-1.5em}
    \label{fig18}
    \end{center}
    \end{figure}
\noindent{ORKG allows users to specify the structure of type's composition to describe research contributions. Templates are used to facilitate the organization of data by adding, editing or deleting attributes and their allocated information. For example, \autoref{fig19} highlights the specification of the features of describing a dataset:} 



imnothere
  • 14,215
Anouar
  • 37
  • 2
    Using [H] is explicitly asking for bad spacing. Remove it completly and let the figures float. And replace the center environment by the \centering command, center adds additional space. – Ulrike Fischer Apr 05 '21 at 12:12
  • 2
    Isn't this the result of default spacing in latex documents that tries to use the entire available vertical space? Have you tried adding \raggedbottom? – Markus G. Apr 05 '21 at 12:14
  • @UlrikeFischer thanks for the answer, ok I will try removing the [H], but why I have to use the \centering ? – Anouar Apr 05 '21 at 12:21
  • @MarkusG. thanks for the answer, no I didn't use \raggedbottom, can you explain more please ? where exactly I have to put it ? and why ? – Anouar Apr 05 '21 at 12:25
  • Well, as you can see, latex tries to stretch out the content of a page to the entire available vertical space. This may or not be a desired effect that is caused by the \flushbottom option, if I'm not mistaken. It is the default for a few classes and as in your case can cause weirdly empty pages. Using \raggedbottom the space reserved for the lines is fixed and all pages filled from top to bottom. Which of these you want depends heavily on the use-case. Typically I put \raggedbottom in the line directly after the documentclass. – Markus G. Apr 05 '21 at 12:36
  • TeX tries to "float" the figures where it thinks is best. If you have multiple large figures close together, it can run into problems because it doesn't have any material to put in those vertical spaces. \raggedbottom tells TeX to move everything up, so that the vertical space is below the images and text. What material is coming after the image? What outcome are you wanting? – Teepeemm Apr 05 '21 at 12:38
  • you are using [H] which is a request to get bad spacing (to fix manually) rather than let latex avoid bad spaces. – David Carlisle Apr 05 '21 at 12:43
  • @MarkusG. it is mainly the result of H which by design gives bad spacing,. – David Carlisle Apr 05 '21 at 12:44
  • @all thanks for the support, so if I understood correctly, I have now to delete [H] and use \raggedbottom ? – Anouar Apr 05 '21 at 12:51
  • you should only use \raggedbottom if you want the baselines not to be the same on all pages. It is like using \raggedright rather than the default justified right margin, but in the vertical direction. Unrelated but you should not need \noindent here and never need {...} after \noindent – David Carlisle Apr 05 '21 at 12:56
  • @DavidCarlisle ok I will try that thx ! but shall I keep the [H] ? – Anouar Apr 05 '21 at 13:03
  • No, get rid of all instances of [H]. – Mico Apr 05 '21 at 13:06
  • H disables all attempts by latex to give good spacing and lets you take full manual control, but then you have to move the figures by hand in the source and/or write more words to get better spacing. It is sometimes necessary as a last resort but only if you really want to disable all latex's features and take full control. – David Carlisle Apr 05 '21 at 13:08
  • Just look at the image you have posted. You can not get Figure 5.8, the ORKG paragraph and figure 5.9 on the same page. The reason latex has figure is to specify that the content may be moved to help with page breaking so if you use no option or use [htbp] then the figures will be re-inserted at a better place. [H] disables that so you force latex to give the output you show. – David Carlisle Apr 05 '21 at 13:11
  • Ok Thank you @DavidCarlisle for your big help, if you want, you can put it as answer so I can accept as a solution for future users, thanks :) – Anouar Apr 05 '21 at 13:13
  • oh it's a duplicate:-) – David Carlisle Apr 05 '21 at 13:13
  • see https://tex.stackexchange.com/questions/2651/should-i-use-center-or-centering-for-figures-and-tables for centering or https://tex.stackexchange.com/questions/8625/force-figure-placement-in-text for discussion of H and https://tex.stackexchange.com/questions/10743/why-does-latex-stretch-small-sections-across-the-whole-page-vertically/10747#10747 for vertically stretching – David Carlisle Apr 05 '21 at 13:17
  • @DavidCarlisle ah ok, sorry I didn't see that, although I searched ti moch before I post this question ! – Anouar Apr 05 '21 at 13:51

0 Answers0