Allowing all figures to break paragraph

floatsparagraphspositioning

The figures always seem to be inserted between two paragraphs. I want to allow the figures to break a paragraph if its positioning between two paragraphs generates large inter-paragraph spaces. The aim is to optimise the placement of the text so that there are no huge inter-paragraph spaces when I include figures in the text.

In the example below, the figure must be alone on a page. I would like to get rid of the blank on page 2 and have the text continue instead. I was wondering if there is a solution that allows you to do this on all the figures in the document at once.

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{lscape}

\begin{document}

\lipsum[1-7]

\begin{landscape}
\begin{figure}[bp!]
\begin{center}
    \includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
    \caption{Some caption}
\end{center}
\end{figure}
\end{landscape}

\lipsum[1-5]

\end{document}

Here the texte should continue instead of the white space marked in red

Here the texte should continue instead of the white space marked in red

Best Answer

You wrote,

The figures always seem to be inserted between two paragraphs.

That is not correct.

In the case of your sample code, what's causing the huge amount of unused whitespace on page 2 and the page break before the landscape/figure combination is the fact that you're switching mid-page from portrait to landscape orientation.

There are many possible remedies. One would be to load the afterpage package and to encase the existing block in an \afterpage{...} "wrapper":

\afterpage{%
\begin{landscape}
\begin{figure}
\centering
    \includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
    \caption{Some caption}
\end{figure}
\end{landscape}%
} % end of scope of \afterpage directive

Another remedy would be to load the rotating package and to employ a sidewaysfigure environment instead of nested landscape and figure environments:

\begin{sidewaysfigure}
\centering
    \includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
    \caption{Some caption}
\end{sidewaysfigure}

Here's an MWE (minimum working example) that uses both remedies.

\documentclass{article}
\usepackage{graphicx,lipsum,pdflscape}
\usepackage{afterpage,rotating} % <-- new

\begin{document}
\lipsum[1-7]

\afterpage{%
\begin{landscape}
\begin{figure}
\centering
    \includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
    \caption{Some caption}
\end{figure}
\end{landscape}%
} % end of scope of \afterpage directive

\lipsum[1-5]

\begin{sidewaysfigure}
\centering
    \includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
    \caption{Some caption}
\end{sidewaysfigure}

\lipsum[1-9]
\end{document}
Related Question