3

I want to overlay one picture on another, like this:

——————————————————————————
|                        |
|     img1               |
|                        |
|              ————————  |
|              | img2 |  |
|              ————————  |
——————————————————————————

How do I do that with ConTeXt?

I have no clue where to start. It seems that playing with spaces (e.g., \blank) won't help.

TRiG
  • 213
  • 1
  • 12
  • 3
    Don't know about ConTeXt, but using LaTeX, my answer here might be helpful: http://tex.stackexchange.com/questions/171483/mathematical-formulas-on-a-graph-not-made-by-tex/171486#171486 – Steven B. Segletes Oct 22 '15 at 11:51
  • 1
    I don't use ConTeXt, but it can be done easily with TikZ, and TikZ works with ConTeXt too. So, would it be ok an answer using tikz? – JLDiaz Oct 22 '15 at 14:05
  • @StevenB.Segletes : Might be useful for search's sake indeed, as well as http://tex.stackexchange.com/questions/9559/drawing-on-an-image-with-tikz. BTW, thank to your answer I remember now : aren't such pictures called "insets" ? – Skippy le Grand Gourou Oct 22 '15 at 15:15
  • @JLDiaz : Well, as long as it does work with ConTeXt… Is it already covered in the link in my previous comment ? – Skippy le Grand Gourou Oct 22 '15 at 15:16
  • Yes it is covered. But you can still answer your own question for those who are too busy to figure out why "drawing" implies "insets". – Symbol 1 Oct 22 '15 at 15:23
  • Yes, "inset" is the right word for it. – Steven B. Segletes Oct 22 '15 at 17:52

2 Answers2

2

Loading a huge library such as tikz for such a simple task isn't necessary. You can place your img1 as a background to a frame into which you place your img2. For further adjustments, you can set parameters such as offset or top and bottom (see the documentation). Here's an example:

\startTEXpage

\defineoverlay [mybackground] [{\externalfigure [mill]
  [width=\overlaywidth,height=\overlayheight]}]

\framed [background=mybackground,
     frame=off,
     strut=no,
     width=7cm,
     height=10cm,
     offset=\zeropoint,
     top=\vss,
     bottom=,
     align=flushright]
{\externalfigure [hacker] [height=2cm]}

\stopTEXpage

With the result:

enter image description here

Thomas
  • 1,726
1

As mentioned by JLDiaz, TiKz is compatible with ConTeXt. Then elaborating from this answer the solution is as simple as :

\usemodule[tikz]
\starttext
  \starttikzpicture
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\externalfigure[fig1][width=10cm]};
    \startscope[x={(image.south east)},y={(image.north west)}]
      \node[anchor=south west,inner sep=0] at (0.7,0.2) {\externalfigure[fig2][width=2cm]};
    \stopscope
  \stoptikzpicture
\stoptext

(\startscope and \endscope lines are not needed if you are at ease with absolute coordinates.)

x={(image.south east)} redefines the x unitary vector as going from (0,0) (bottom left of img1) to (image.south east) (i.e. bottom right of img1).