How do I remove white space before or after the figures and tables?

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'.


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.


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