# How to wrap text around part of a figure

I am looking for wrapping some text around part of a figure in the following way:

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aenean quis mi ut elit interdum imperdiet quis non ante.
+---------------------------+ +-------------------------+
|                           | |                         |
|                           | |                         |
|                           | |                         |
+---------------------------+ +-------------------------|
(a) subfigure a              (b) subfigure b
+------------------------+
Sed imperdiet, sapien quis    |                        |
viverra rhoncus, tellus dui   |                        |
dictum nisl, at porta purus   |                        |
ipsum ac turpis. Fusce auctor |         FIGURE         |
ullamcorper adipiscing. Nunc  |          HERE          |
non quam ac orci egestas con- |                        |
sequat ut eget quam. Cras     +------------------------+
blandit condimentum ornare.         (c) subfigure c
Curabitur aliquam, nulla sit
amet iaculis tristique, mi        Figure 1: demo
nulla auctor magna, sit amet imperdiet ante arcu a libero.


The example here How to wrap text around a subfigure? has it only for equal-sized subfigures (which, I usually do simply by putting subfloat in my wrapfigure). Is there any way to do what I am suggesting. I am on Fedora 29 which has the texlive distribution. Thanks in advance for any suggestions or pointers.

The suggestion given works, but not for the subfig package (which uses subfloat that I thought was recommended over subfigure.)

Here is the example text:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{wrapfig}
\usepackage{verbatim,subfig}
\begin{document}
\lipsum[1]
\begin{figure}[h]\centering\ContinuedFloat*
\mbox{  \subfloat[]{\label{a}\includegraphics[draft,width=0.5\textwidth]{foo.png}}
\subfloat[]{\label{b}\includegraphics[draft,width=0.5\textwidth]{foo.png}}}
\end{figure}
\begin{wrapfigure}{r}{0.5\textwidth}\centering\ContinuedFloat
\subfloat[]{\label{c}\includegraphics[draft,width=0.5\textwidth]{foo.png}}
\caption{Demo}
\label{fig}
\end{wrapfigure}
\lipsum[2]
\end{document}


The counter deprecates every time ContinuedFloats in used.

I could perhaps add to the figure counter everytime continuedFloats is used but that does not seem kosher to me. I like clean solutions if available.

• Regarding a comparison of the subfig package (used in your question) and the subcaption package (used in the answer), see for example here: tex.stackexchange.com/a/13778/134144 Feb 3, 2019 at 19:07
• This link: tex.stackexchange.com/questions/144782/… says that subfigure is deprecated, hence I switched to subfig. Is that not true? The remainder of my document uses subfloat so this would be painful. Feb 3, 2019 at 19:12
• There are three different packages, subfigure, subfig and subcaption. The first of them is deprecated. (The second one also introduces an environment called subfigure). Feb 3, 2019 at 19:41
• I thought that subfig introduces subfloat. Did not realize that it also did subfigure, but that does not address my question of the counter changing. Feb 3, 2019 at 21:05

Have you considered making use of \ContinuedFloat from the caption package (without defining a different label format for continued floats)?

Code

\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{lipsum}
\usepackage{wrapfig}

\begin{document}
\lipsum[1]
\begin{figure}[h]\centering\ContinuedFloat*
\begin{subfigure}[b]{0.5\textwidth}\centering
\includegraphics[draft]{foo.png}
\caption{}
\label{a}
\end{subfigure}%
\begin{subfigure}[b]{0.5\textwidth}\centering
\includegraphics[draft]{foo.png}
\caption{}
\label{b}
\end{subfigure}
\end{figure}
\begin{wrapfigure}{r}{0.5\textwidth}\centering\ContinuedFloat
\begin{subfigure}{0.5\textwidth}\centering
\includegraphics[draft]{foo.png}
\caption{}
\label{c}
\end{subfigure}
\caption{Demo}
\label{fig}
\end{wrapfigure}
\lipsum[2]
\end{document}


Output:

More info on \ContinuedFloat in the LaTeX Wikibook: 8 Figures in multiple parts.

Edit: User wants a working example using the subfig package.

The problem with your current example is that the first figure environment has no caption. The \phantomcaption command may be used to create a hidden caption which should clear up your issue:

\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{wrapfig}
\usepackage{subfig}

\begin{document}
\lipsum[1]
\begin{figure}[h]\centering
% \ContinuedFloat* % Remove this.
\subfloat[][]{\includegraphics[draft]{foo.png}}
\subfloat[][]{\includegraphics[draft]{foo.png}}
\phantomcaption
\end{figure}
\begin{wrapfigure}{r}{0.5\textwidth}\ContinuedFloat\centering
\subfloat[][]{\includegraphics[draft]{foo.png}}
\caption{Demo}
\label{fig}
\end{wrapfigure}
\lipsum[2]
\end{document}


(also, remove the \ContinuedFloat*` in the figure environment - it appears subfig does not use this - see section 2.2.3 of the subfig documentation).

Relevant 8 year old question: numbering - ContinuedFloat, and Subfloat

• Very interesting: I had no idea of this approach. This is a cool answer. I will wait to see if there are better answers before checking, but this does address my problem. Feb 3, 2019 at 17:03