Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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