The question is a follow up of the question posted here how to make adjustbox work correctly .
\documentclass{scrartcl}
\usepackage{adjustbox}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{tikz}
\newenvironment{bluebox}{%
\noindent
\adjustbox{innerenv={varwidth}{\dimexpr\linewidth-2\fboxsep-0.45cm\relax},
margin=\fboxsep+.25cm \fboxsep+.2cm,bgcolor=blue!10,frame,center}\bgroup
}{%
\egroup
}
\begin{document}
\lipsum[3-5]
\begin{wrapfigure}{L}{3.00in}
\begin{bluebox}
{ \bf{Box 1: My caption here}}\\
\tikz \draw[line width=.1cm, red] (0,0) -- (\linewidth,0);
\lipsum[4]
\end{bluebox}
\end{wrapfigure}
\lipsum[3-5]
\end{document}
This is rendered as follows:
If it is not an overkill then is it possible that Box 1 becomes the label and the text following it is the caption.
Best Answer
Since you are constructing a titled colored box, I would suggest to consider the packages
mdframed
ortcolorbox
for your task.The following example code uses
tcolorbox
version3.04 (2014/05/18)
. An automatically numberedbluebox
is contructed which includes thewrapfigure
and takes 4 parameters described in the following code.For easy references, the
cleveref
package is also included which defines the\Cref
macro used in the example.