0

I wanted to wrap text around the big subfigure at the bottom row of the figure. The top row 4 subfigure are ok, the spacing works. But when I wrap text around the big subfigure (e) at the bottom(the name (e) is missing too), the caption splits the paragraph. Also the caption should go to the write under (e).

The MWE:

\begin{figure}
\begin{minipage}{1.0\textwidth}
    \centering
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub1.png}
        \caption{} 
    \end{subfigure}
    \hspace{-0.25cm}
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[height=\linewidth]{Images/SpecificAim3/sub2.png}
        \caption{} 
    \end{subfigure}
    \hspace*{-1.05cm}
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub3.png}
        \caption{} 
    \end{subfigure}
    \hspace*{-0.25cm}
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub4.png}
        \caption{} 
    \end{subfigure}
\end{minipage}
\bigskip
\begin{wrapfigure}{r}{0.4\textwidth}
    \includegraphics[width=\linewidth]{Images/SpecificAim3/sub5.png}
    \caption{} 
\end{wrapfigure}
\lipsum[1]

\caption{Registration visualized. } \end{figure} \lipsum[2]

enter image description here

3
  • I figure out the gap is due to \bigskip so I removed it from MWE.
    – banikr
    Aug 15, 2023 at 22:35
  • 1
    How far to the right? Under the image, or just \raggedleft? Aug 16, 2023 at 3:54
  • @JohnKormylo under the image like typical captions.
    – banikr
    Aug 16, 2023 at 4:52

1 Answer 1

1

This puts the figure caption under the last image & subcaption. Note that some of the text is inside the figure and may float relative to the rest of the text.

Interestingly, when I put \subcaption and \caption in the same group, the \caption turns into another \subcaption.

\documentclass{article}
\usepackage{subcaption}
\usepackage[export, draft]{adjustbox}% for valign
\usepackage{graphicx}


\usepackage{lipsum}

\begin{document}
\begin{figure}
    \centering% not used
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub1.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[height=\linewidth]{Images/SpecificAim3/sub2.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub3.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub4.png}
        \caption{} 
    \end{subfigure}\vspace{\floatsep}
    
    \begin{minipage}[t]{\dimexpr 0.6\textwidth-\columnsep}
      \lipsum[1]
    \end{minipage}\hfill
    \begin{minipage}[t]{0.4\textwidth}% to include figure \caption
      \begin{subfigure}[t]{\linewidth}
        \includegraphics[width=\linewidth, valign=t]{Images/SpecificAim3/sub5.png}
        \caption{}
      \end{subfigure}
      \caption{Registration visualized. }
    \end{minipage}
\end{figure}

\lipsum[2]
\end{document}

This version uses a separate figure and wrapfig with \ContinuedFloat. If the figure floats to the next page, so should the wrapfig, although at the start of a new paragraph instead of the end of the figure.

\documentclass{article}
\usepackage{subcaption}
\usepackage[export, draft]{adjustbox}% for valign
\usepackage{graphicx}
\usepackage{wrapfig}

\usepackage{lipsum}

\begin{document}
\begin{figure}[ht]
    \centering% not used
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub1.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[height=\linewidth]{Images/SpecificAim3/sub2.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub3.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub4.png}
        \caption{} 
    \end{subfigure}
\end{figure}% automatic \textfloatssep
\begin{wrapfigure}{R}{0.4\textwidth}
    \ContinuedFloat
    \vskip-\intextsep
    \vbox{\includegraphics[width=0.4\textwidth]{Images/SpecificAim3/sub5.png}
      \subcaption{}}
    \caption{Registration visualized. }
\end{wrapfigure}
\lipsum[1-2]
\end{document}

This puts everything into one wrapfigure. It deliberately overlaps the left side then adds a gap in the text to match. Note that it is important to not move the first baseline, so the gap is implemented below the baseline.

\documentclass{article}
\usepackage{subcaption}
\usepackage[export, draft]{adjustbox}% for valign
\usepackage{graphicx}
\usepackage{wrapfig}

\usepackage{lipsum}

\newlength{\overlap}

\begin{document}
\begin{wrapfigure}{r}{0.4\textwidth}
  \sbox0{\begin{minipage}{\textwidth}% measure first row
    \centering% not used
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub1.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[height=\linewidth]{Images/SpecificAim3/sub2.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub3.png}
        \caption{} 
    \end{subfigure}\hfil
    \begin{subfigure}{0.25\textwidth}
        \includegraphics[width=\linewidth]{Images/SpecificAim3/sub4.png}
        \caption{} 
    \end{subfigure}
  \end{minipage}}%
  \setlength{\overlap}{\dimexpr \ht0+\dp0+\intextsep-\ht\strutbox}% compute overlap distance
  \global\overlap=\overlap
  \hfill\llap{\usebox0}\par\vskip\floatsep% overlap left side of page
  \vbox{\includegraphics[width=0.4\textwidth]{Images/SpecificAim3/sub5.png}
    \subcaption{}}
  \caption{Registration visualized. }
  \vskip-\overlap
\end{wrapfigure}

\strut\vspace{\overlap}\par% create gap below baseline
\lipsum[1-2]
\end{document}
2
  • The first code moves the figures in different pages. But the second one works perfect. Thanks!
    – banikr
    Aug 16, 2023 at 16:57
  • The first solution uses one figure. It does however move the text. Aug 16, 2023 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .