# Re: how to add a caption to a Box inset?

Justin Wood wrote:
> Thanks for the help, Jürgen. I'm not that great with using LaTeX directly,
> but is this on the right track for the boxedminipage style?
> \usepackage{boxedminipage} in the preamble; then
>
>  \begin{boxedminipage}[c]{1\columnwidth}
>
> \label{Box: hydrological cycle}Some text, blah blah\end{boxedminipage}
>
>
> I inserted that as Tex code within LyX. I get a box this way, but I, err,
> can't quite see how to use this with a float and/or get a caption (in the
> Box 1, or Box 1.1 format). Sorry...

* Put the attached module in the layouts folder of your user directory
(About>LyX tells you where the user directory is, if there is no layouts
folder yet, create it)

* Restart LyX

* Go to Documents>Settings...>Modules, select the module "Boxed Float" and hit

You should not be able to select a framed float from Insert>Floats. The float
does not exactly look like you want (the caption is outside the box). If you
want to have the caption inside the box, the following definition in your
document preamble (while using the Boxed Float module) should help:

\usepackage{framed}
\newcommand\flo...@simplerule[2]{{\@f...@cfont #1 #2}\par}
\renewcommand...@boxed{%
\d...@fs@cfont{\bfseries}\l...@fs@capt\flo...@simplerule
\d...@fs@pre{\begin{framed}}%
\d...@fs@post{\end{framed}}%
\d...@fs@mid{\kern8pt}%
\l...@fs@iftopcapt\iftrue}

HTH,
Jürgen

#\DeclareLyXModule{Boxed Float}
#DescriptionBegin
#Defines a new type of (framed) float.
#DescriptionEnd

# Author: Jürgen Spitzmüller <sp...@lyx.org>

Format 11

Float
Type                  boxfloat
GuiName               "Box"
Placement             tbp
Extension             lob
NumberWithin          none
Style                 boxed
ListName              "List of Boxes"
LaTeXBuiltin          false
End