# Is there a way to wrap text around subfloats within a custom float?

I am a fairly proficient latex user, but have stumbled across a formatting challenge outside my experience.

I am trying to create a custom "box" float - similar to what one might see in children's science books such as the Dorling Kindersley science books.

I want to include both text and subfloats within this float and would prefer to have the text wrap around the subfloats. Is there a way to do this? I've done' a fair amount of searching online and am coming up empty-handed, so I'm wondering if perhaps there is a fundamentally different way to approach this problem.

Ideally I would like to know:

1. How to individually wrap text around each of the subfigures captioned "Wrap?" in the MWE below.
2. How to wrap around a group of subfigures such as the minipage in the MWE below.

And advice on how to do this or where to look would be welcome.

I've included a MWE using minipages and without any wrapping functionality.

The problem with the approach in this example is:

1. I'd to have the flexibility to not arrange figures in a line
2. If I settle with a lined-up format, as shown, there is a break in the text.

Thanks!

\documentclass{article}

\usepackage{amsmath}

%For use of "\includegraphics"
\usepackage{graphicx}

%For filler text
\usepackage{lipsum}

%For textcolor
\usepackage{xcolor}

%To force figure position and for "\restylefloat"
\usepackage{float}

%To define custom float environments
\usepackage{newfloat}

%For "DeclareCaptionSubtype" below
\usepackage{caption}

%For subfigures
\usepackage{subcaption}

%Wrap text around figures
%\usepackage{wrapfig}

% Set the color of the "shaded" environment

%For use of the "shaded" environment
\usepackage{framed}

%Define the "mybox" environment
\DeclareFloatingEnvironment[
fileext=lob, %An auxiliary file that stores the "list of boxes" (.lob). This abbreviation is user defined and analogous to .lof (list of figures) and .lot (list of tables0.
listname={List of Boxes}, %Title for the TOC list of this type of float
placement={htbp},%All possible placement options
name=Box %Name of float type - to appear in caption
]{mybox} %handle for this float environment

%If you would like the "boxing" float style to be boxed
%Note: \floatstyle applies on all subsequent \newfloat commands
\floatstyle{boxed}
\restylefloat{mybox}

%Announce the "mybox" float type to subcaption and create the subtextbox environment
\DeclareCaptionSubType[alph]{mybox}
\renewcommand\thesubmybox{\alph{submybox}}

%Figure Path
%\newcommand{\FigurePath}{Absolute File Path Here}

%Filler Art
\newcommand{\FillerArt}{example-image}

\begin{document}

\begin{mybox}
\footnotesize
\begin{center} \textbf{This is a Title}\end{center}
\lipsum[1]
\begin{minipage}[t]{.3\textwidth}
\centering
\begin{submybox}{\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{Individual subfloat to wrap.}}
\label{}
\end{submybox}
\end{minipage}
\begin{minipage}[t]{.58\textwidth}
\lipsum[1]
\end{minipage}\\
\begin{minipage}{.3\textwidth}
\begin{submybox}{\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{1 of 2 to wrap as a group.}}
\label{}
\end{submybox}
\begin{submybox}{\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{2 of 2 to wrap as a group.}}
\label{}
\end{submybox}
\end{minipage}
\begin{minipage}[t]{.58\textwidth}
\lipsum[1]
\end{minipage}\\
\begin{minipage}{\textwidth}
\centering
\begin{submybox}{.3\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\begin{submybox}{.3\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\begin{submybox}{.3\textwidth}
\centering
\includegraphics[width=\textwidth]{\FillerArt}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\end{minipage}
\caption{\textbf{Box Test.}}
\label{box:test}
\end{mybox}

\end{document}

• I can't figure out if you are trying to wrap text to the right of the submyboxes or wrap submyboxes around the text. Note that the \caption is mostly for the \listoffigures, You don't actually need them to put text between images. Jul 12 '21 at 16:14
• I essentially want Box 1 to float, but it's contents to behave like a "normal" page. I have two goals: (1) be able to wrap the text within Box 1 around individual "submyboxes" . (2) be able to wrap the text within Box 1 around groups of "submyboxes". And the captions on the individual "submyboxes" are intentional. I will be referencing them within the text. I can see how my caption word choice is confusing. I will edit that. Jul 12 '21 at 17:53

This isn't a solution so much as an executable MWE with a few tweaks.

\documentclass{article}

\usepackage{amsmath}

%For use of "\includegraphics"
\usepackage{graphicx}

%For filler text
\usepackage{lipsum}

%For textcolor
\usepackage{xcolor}

%To force figure position and for "\restylefloat"
\usepackage{float}

%To define custom float environments
\usepackage{newfloat}

%For "DeclareCaptionSubtype" below
\usepackage{caption}

%For subfigures
\usepackage{subcaption}

%Wrap text around figures
%\usepackage{wrapfig}

% Set the color of the "shaded" environment

%For use of the "shaded" environment
\usepackage{framed}

%Define the "mybox" environment
\DeclareFloatingEnvironment[
fileext=lob, %An auxiliary file that stores the "list of boxes" (.lob). This abbreviation is user defined and analogous to .lof (list of figures) and .lot (list of tables0.
listname={List of Boxes}, %Title for the TOC list of this type of float
placement={htbp},%All possible placement options
name=Box %Name of float type - to appear in caption
]{mybox} %handle for this float environment

%If you would like the "boxing" float style to be boxed
%Note: \floatstyle applies on all subsequent \newfloat commands
\floatstyle{boxed}
\restylefloat{mybox}

%Announce the "mybox" float type to subcaption and create the subtextbox environment
\DeclareCaptionSubType[alph]{mybox}
\renewcommand\thesubmybox{\alph{submybox}}

%Figure Path

%Filler Art
%\newcommand{\FillerArt}{\FigurePath Figure File Here}
\newcommand{\FillerArt}{example-image}

\usepackage{blindtext}

\begin{document}

\begin{mybox}
\footnotesize
\begin{center} \textbf{This is a Title}\end{center}
\lipsum[1]
\begin{minipage}[t]{.3\textwidth}
\centering
\begin{submybox}[t]{\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Wrap?}}
\label{}
\end{submybox}
\begin{submybox}[t]{\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Wrap?.}}
\label{}
\end{submybox}
\begin{submybox}[t]{\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Wrap?.}}
\label{}
\end{submybox}
\end{minipage}
\begin{minipage}[t]{.58\textwidth}
\lipsum[1]
\end{minipage}
\begin{minipage}{\textwidth}
\centering
\begin{submybox}{.3\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\begin{submybox}{.3\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\begin{submybox}{.3\textwidth}
\centering
\raisebox{\dimexpr \ht\strutbox-\height}{\includegraphics[width=\textwidth]{\FillerArt}}
\caption{\textbf{Test.}}
\label{}
\end{submybox}
\end{minipage}