# Allowing figures to break paragraphs

As it seems, the placement option [!htb] only allows the figure to be placed between paragraphs. But what if the best placement is "inside" a paragraph? See, for instance:

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

\begin{document}

\lipsum[1]

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

\end{document}


On the left side of the figure above I show the output of the minimal example above. As you can see, I'm left with an undesirable blank space. In my view, the optimal placement would be the one on the right side, but currently my code don't see breaking the text as an option. Why not? Is there a way to make it happen? Of course it'd work if I manually broke the paragraph, but I want LaTeX to automatically recognize this placement situation.

PS: I tried to use the wrapfig package, but apparently it only works for cases where the figure "coexists" with the text on the same line.

• figures can be placed mid-paragraph, or mid-sentence, but you have placed it at the end of the docuemnt, so it isn't clear what other outcome you expect in this case. – David Carlisle Feb 2 at 21:57

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

\begin{document}

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

\lipsum[1]

\end{document}


Note I used ! here as the figure takes up more space than normally allowed on text pages. You had omitted p which makes it much harder to place the figure.

• Thanks, but I don't understand... Shouldn't LaTeX search for the best placement regardless of the position in which I put the figure in the code? Why simply putting the figure below the text in the code would make such a mess? – Pericles Carvalho Feb 2 at 22:13
• @PericlesCarvalho LaTeX does not have the whole document in memory once a page break decision is made it can not go back – David Carlisle Feb 2 at 22:22
• @PericlesCarvalho in fact as you prevented p and placed it too late in the document for h, t or b the figure wasn't placed at all until it was flushed out into a forced float page by the implicit \clearpage at \end{document} – David Carlisle Feb 2 at 22:26

If you place your figure early enough in your text, it can be placed within the paragraph

• if the available space permits this (your figure seems to be very tall, this might conflict with the allowed fraction of floats per page...)

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

\begin{document}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique
senectus et netus et malesuada fames ac turpis egestas. Mauris ut
\begin{figure}[hb!]
\includegraphics[width=\textwidth,height=0.8\textheight]{example-image-a}
\caption{Some caption}
\end{figure}
leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Cur- abitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.

\end{document}