34

Whenever my figure or table has to move to the next page it is placed exactly at the center of the page, and thus occupies the whole page by itself. I tried all the combination in:

\begin{figure}[htb]

having failed, I tried this one

\usepackage{float}
 .
 .

 \begin{figure}[H]

This kind of work, but again whenever the figure has to be placed on the next page, the previous page has white spaces between the section heading and the paragraphs before and after.

I'm exhausted of plans now. any help?

EDIT

Example:

\documentclass[11pt,a4paper,twoside,openany]{book}


\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[demo]{graphicx}

% privides the H option
\usepackage{float}

% produces random text for testing
\usepackage{blindtext}

\begin{document}

\blindtext[2]

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\end{document}

and this is what I get on page 2:

tex test

5
  • 2
    Please add a minimal working example (MWE) that illustrates your problem.
    – henrique
    Oct 15, 2012 at 23:53
  • What is the size of your image? Could it be wider than \textwidth or taller than \textheight? You can scale it using width=\textwidth or height=.5\textheight.
    – Werner
    Oct 15, 2012 at 23:54
  • You say [htb] but the main effect of that is to disallow page floats as p is not included so the float is not allowed to appear on a page on its own. H prevents the float from floating so makes ugly white space on the preceding page almost inevitable unless you manually position the float in the source file to optimise the page break. Oct 16, 2012 at 0:08
  • A great discussion about floats in LaTeX is at How to influence the position of float environments like figure and table in LaTeX?.
    – Guido
    Oct 16, 2012 at 0:25
  • latex-community.org/forum/viewtopic.php?f=5&t=1279 check this page for removing space after figure caption
    – user42025
    Dec 2, 2013 at 3:59

3 Answers 3

16

I have prepared an example -- do you think that the white space is too big here?

Example: http://www.bipede.de/Downloads/floating.pdf

enter image description here enter image description here

\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[demo]{graphicx}

% privides the H option
\usepackage{float}

% produces random text for testing
\usepackage{blindtext}

\begin{document}

\blindtext[2]

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\begin{figure}[H]
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\end{document}

Hello again. I prepared another example. The result can be found here

http://www.bipede.de/Downloads/floating_2.pdf

enter image description here enter image description here

\documentclass[11pt,a4paper,twoside,openany]{book}


\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[demo]{graphicx}

% privides the H option
\usepackage{float}

% produces random text for testing
\usepackage{blindtext}

% Parameters for floating objects in LaTeX
% An overview can be found in the book
% The Latex Companions Chapter 6.1
% A good start is
% http://robjhyndman.com/researchtips/latex-floats/

\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.8}
\renewcommand{\textfraction}{0.1}
\setlength{\floatsep}{5pt plus 2pt minus 2pt}
\setlength{\textfloatsep}{5pt plus 2pt minus 2pt}
\setlength{\intextsep}{5pt plus 2pt minus 2pt}

\begin{document}

\chapter{Test}

\blindtext[2]

\begin{figure}
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\section{Test}

\blindtext[2]

\begin{figure}
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\begin{figure}
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\section{Test}

\blindtext[2]

\begin{figure}
\centering
\includegraphics[width=0.8\textwidth,height=50mm]{}
\caption{Test Test Test}
\end{figure}

\blindtext[2]

\end{document}

In the example I just used the standard placement option and did not use the H option. You can still use it if necessary. An overview can be found in the book The Latex Companions Chapter 6.1. A good start can also be found here. Also very good - but you have to read a lot - here to be found.

There is also a ! operator: \begin{figure}[!htb]. It is stronger than [htb] but weaker than [H].

In the example I changed some of the parameters:

\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.8}
\renewcommand{\textfraction}{0.1}
\setlength{\floatsep}{5pt plus 2pt minus 2pt}
\setlength{\textfloatsep}{5pt plus 2pt minus 2pt}
\setlength{\intextsep}{5pt plus 2pt minus 2pt}

It is a bit of work to understand what each of these parameters mean. You can use my suggestion as a start.

In general, I would worry about the placement when you are near the end and want to 'tidy up'.

2
  • 1
    Try using \begin{figure}[h] instead of capital H. There are no blank spaces this way.
    – Vivi
    Oct 16, 2012 at 0:48
  • @manuel your example looks perfect. that's basically what I want to see in my document as well. but i'm using the book class. I've added as an edit on my question what I see when I change your example to a book class.
    – rethabile
    Oct 16, 2012 at 8:17
15

As mentioned in comments using [H] makes large white spaces inevitable unless you manually adjust the float positioning and page breaking since the whole point of H is to disable LaTeX's float placement algorithm which normally tries to avoid such bad spaces.

If you replace each [H] by [htp] in your posted example the spacing is much better and as expected.

2
  • At least in my document, I find replacing [H] with [htp] makes the spacing much worse. Any idea why? Oct 21, 2020 at 14:33
  • H by design gives bad spacing. Latex moves floats to get better spacing at page breaks and H just disables floating so will naturally give worse spacing, or rather requires you to manually move or re-write text to achieve a good page break. Of course there will always be some documents where the automatic float positioning is bad and you can get better layout with H, it all depends... Oct 21, 2020 at 20:19
6

PDF figures can have either a transparent background or a white (or other color) background. If you have a white background, all the answers here will not help. The solution would be the clip option of \includegraphics

\includegraphics[trim=left botm right top, width=0.95\textwidth, clip]{...}

The answer is based on: https://tex.stackexchange.com/a/239216/64479

2
  • How do I use this if I have multiple \includegraphics inside minipages inside a figure? Oct 21, 2020 at 14:35
  • you still specify proper trims, e.g. trim=1.5cm 7.3cm 1.5cm 7cm and add , clip at the end. Also, this is only a part of the solution for the case when your figures are PDFs with a lot of whitespace.
    – Ufos
    Oct 22, 2020 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.