0

I just encountered a weird issue when forcing an image to display at the current position (using [H] and \usepackage{float}) itemize lists break with huge margins between each \item.

This only happens when the image is too big to be displayed on the current page, inserting a \newpage before the \begin{figure} makes it work again.

Can I somehow fix it so that the margins don't break, even without the \newpage?

Here's a minimal reproducible example:

\documentclass[10pt,a4paper,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{float}
\begin{document}

\section{Testing} Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

\begin{itemize} \item 1 \item 2 \item 3 \item 4 \item 5 \item 6 \item 7 \end{itemize}

\begin{figure}[H] \includegraphics[width=12cm]{16x16cm.png} \end{figure} \end{document}

Heres a screenshot of the minimal reproducible example compiled using XeLaTeX (the figure is on the next page):

A Screenshot of the compiled MWE

With \newpage prepended before \begin{figure} it looks as expected:

A Screenshot of the MWE with newpage

The image I used within the minimal reproducible example is a 16x20cm black square.

  • 2
    latex floats figures to avoid bad space so [H] which just stops floating is an explicit request to get bad space, or more exactly requires the author to position the float by hand to avoid bad space. – David Carlisle Mar 03 '22 at 16:50
  • 1
    in twoside mode article defaults to \flushbottom so latex has to make the last baseline be at the bottom of the page, the only way it can do that since the figure can not move is to stretch the white space. You may prefer \raggedbottom – David Carlisle Mar 03 '22 at 16:52
  • Ah, thank you @DavidCarlisle, \raggedbottom fixed the problem! – 27justin Mar 04 '22 at 08:13

0 Answers0