I am trying to decorate the floats in my thesis as follows:

  • each float shall have a top/bottom frame in a custom color,
  • the caption and content of each float are supposed to have the same background color.

Basically, what I want it to look like is this:

Float decorated with a frame and background color

So far I've only managed to do this by embedding the float in a framed text like this:

  \placefigure[here][figure:figure label]
    {figure caption}
    {figure content}

This works as long as the float is placed somewhere in the middle of a page. But as soon as they are the first element on a page, caption and content are moved out of the framed text and it looks a bit like this:

Float decorated but content moved out of the frame

I guess this has to do with the special way floats are placed by ConTeXt.

Now, I wonder if there is a way to fix this. One way could be to not use floats at all and setup a custom enumerated environment with labels instead. Any ideas what else I could try? \setupfloats and \setupcaptions do have before=, after= and inbetween= options but I couldn't get them to create the desired decorations for me.

  • This was not possible three years ago. See this thread on the ConteXt mailing list. However, a lot of internals have changed since then. You could try asking on the ConTeXt mailing list again.
    – Aditya
    Commented Aug 11, 2011 at 4:44

2 Answers 2


The following works in MkII (using the pdftex engine), but not in MkIV because \placefloatcaption is not yet implemented in MkIV.


\setupfloats[frame=off,background=color, backgroundcolor=gray, backgroundoffset=3mm] 


\section{A figure with a background} 

  {\placefloatcaption[figure]{A dutch cow}}} 


For MkIV, you can define your own float handler to draw a background. For example:


\installfloatboxbuilder {bottombackground}    \dofloatboxbackgroundbuilder

        \hbox{\hbox               {\box\float_content_box}}%
        \hbox{\locate_side_float  {\box\float_caption_box}}%
        \hbox{\locate_text_float  {\box\float_caption_box}}%

\setupcaption[location={bottombackground},background=color, backgroundcolor=gray, frame=off]

\section{A figure with a background} 

\startplacefigure[title={A dutch cow}]


You put the figure in the frame, but instead you should put the frame in the figure. When your figure is placed "here" it ends up within the frame, but top or bottom placement move it out of the frame. This would place the caption outside of the frame:

  \placefigure[top][figure:figure label]
  {figure caption}
      figure content
  • This makes a lot of sense if only the float/figure content is to be decorated. In this case the caption is supposed to be included in the frame which is not implemented in your proposal. Commented Aug 8, 2011 at 11:54
  • Right. You can define and setup your own float, where you preset the framing. However, i found no option to put the caption into the frame.
    – beza1e1
    Commented Aug 8, 2011 at 12:06

You must log in to answer this question.

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