2

The goal is to embed an image into a coloured box with text. I tried with \placefigure and \starthangaround. They work fine outside a frame, but once put inside a frame the text collides with the image.

\useMPlibrary[dum]
\setupcolors[state=start]

\starttext

  \placefigure[right]{}{\externalfigure[placeholder][width=27mm,height=27mm]}
  \input knuth

  \startframedtext[width=broad, background=color, backgroundcolor=green]
    \placefigure[right]{}{\externalfigure[placeholder][width=27mm,height=27mm]}
    \input knuth
  \stopframedtext

  \startframedtext[width=broad, background=color, backgroundcolor=green]
    \starthangaround{\externalfigure[placeholder][width=27mm,height=27mm]}
    \input knuth
    \stophangaround
  \stopframedtext
\stoptext

Is there a way to support floats inside frames? Or is there another object which can provide a background colour that plays nicely with floats?

3

You can use textbackgrounds

\useMPlibrary[dum]
\setupcolors[state=start]

\definetextbackground
  [imagebackground]
  [
    location=paragraph,
    background=color,
    backgroundcolor=green,
    frame=on,
  ]

\starttext

  \startimagebackground
  \placefigure[right,none]{}{\externalfigure[placeholder][width=27mm,height=27mm]}
  \input knuth
  \stopimagebackground

\stoptext

which gives

enter image description here

Unlike frames, textbackgrouds can break across pages. So you might have to add a manual \page to avoid that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.