2

I have two figures. I need to place first figure with width=10cm and then place second figure with same width but it's center must be shifted to right by 9cm and down by 5cm relatively to center of first picture.

I also need the text do not cross with pictures, i.e. I need this construction behaves just like one usual picture.

Is there a way to do that?

2

You can use the overlay environment to place the two images on top of each other. Then adjust the relative position of the second figure with the \offset command.

\useMPlibrary
  [dum]

\setupexternalfigures
  [width=10cm]

\starttext
  \startoverlay
    {\externalfigure}
    {\offset[x=9cm, y=5cm]{\externalfigure}}
  \stopoverlay
\stoptext

result

EDIT: The reason subsequent text overlays the second image is that the \offset command does not adjust the bounding box, which is mostly what is desired. You can visually trace that using the \showboxes command.

To fix this I present two solutions. The first one creates a \vbox using the higher level command \frame with a height of image height + vertical shiftwidth / 2 = 12.5cm which creates a box of the correct height, so subsequent text does not overprint the image.

\setuppapersize
  [A3]

\useMPlibrary
  [dum]

\setupexternalfigures
  [width=10cm]

\defineframed
  [overlayframe]
  [frame=off,
   offset=overlay,
   height=12.5cm,
   align=top]

\starttext
  \overlayframe{%%
    \startoverlay
      {\externalfigure}
      {\offset[x=9cm, y=5cm]{\externalfigure}}
  \stopoverlay}
  \input knuth
\stoptext

result-fix

The second solution inserts vertical space by using a \vskip.

\setuppapersize
  [A3]

\useMPlibrary
  [dum]

\setupexternalfigures
  [width=10cm]

\starttext
  \startoverlay
    {\externalfigure}
    {\offset[x=9cm, y=5cm]{\externalfigure}}
  \stopoverlay

  \godown [\dimexpr 5cm+\lineheight\relax]
  \input knuth
\stoptext

The result is the same as above.

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.