[NTG-context] Problem with MkIV and TikZ picture remembering

Aditya Mahajan adityam at umich.edu
Tue Mar 3 18:12:38 CET 2015


On Tue, 3 Mar 2015, Jörg Weger wrote:

> In the minimal working example below inside of a text two words should 
> be printed inside of rounded TikZ rectangles and should be connected by 
> an TikZ arrow pointing from the first word to the other.
>
> TikZ offers the remember picture/overlay option for that.
>
> I have seen a solution similar to what I want to achieve in the METAFUN 
> manual but I don’t have a clue how to get that METAPOST alternative working.

Here is how to get the metafun alternative working.

1. I don't understand why I need to manually input the mp-abck file; that 
should be input automatically.

2. The metafun alternative is a bit inconvenient. Suppose you want to draw 
a bunch of such graphics (words connected by arrows). Then, you will need 
to ensure that node names are unique. (Is there a way to get around that?)

3. I did not bother to set the style of the boxes and arrows. So it looks 
a bit dry.

\startMPdefinitions
   % I don't know why this does not get loaded automatically.
   input mp-abck.mpiv;
\stopMPdefinitions

\defineoverlay[highlight] [\positionoverlay{highlightoverlay}]

\startpositionoverlay{highlightoverlay}
   \setMPpositiongraphic{n1}{highlightgraphic}{from=n1,to=n2}
\stoppositionoverlay

\startMPpositiongraphic{highlightgraphic}
   save n; path n[];

   initialize_box(\MPpos{\MPvar{from}}); n[1] := pxy;
   initialize_box(\MPpos{\MPvar{to}});   n[2] := pxy;

   draw n[1];
   draw n[2];

   drawarrow (center n[1]){dir 45} .. {dir -45}(center n[2])
        cutbefore n[1]
        cutafter  n[2];

   anchor_box(\MPanchor{\MPvar{from}});
\stopMPpositiongraphic

\setuppapersize[A6]

\setupbackgrounds[page][background=highlight]

\starttext
\hpos{n1}{this} belongs to \hpos{n2}{that}
\stoptext

Aditya


More information about the ntg-context mailing list