TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.