On 5/31/2021 6:50 PM, Aditya Mahajan wrote:
On Mon, 31 May 2021, Hans Hagen wrote:

Hi,

I uploaded a new lmtx version. This time a new mechanism.

This is very interesting...I haven't played around with it, but is it the case 
that \markanchor does not do alignment and so can completely replace the old 
\hpos{...} class of macros?

This also gives many interesting possibilities for math .... drawing "boxes" in 
matrices (e.g., 
https://tex.stackexchange.com/questions/333011/draw-a-box-around-matrix-elements) or even 
the nath style `\wall` macro (see pg 11 of https://texdoc.org/serve/nathguide.pdf/0) ... 
Of course, I mean this in terms of the visual effect and not the interface.
Like this ... I'll think about taking some size into account (a bit like hpos does).

\starttext

\startuseMPgraphic{whatever-1}
    fill OverlayBox withcolor "lightgray" ;
    drawdot anchorxy("one", 0, 1)
        withpen pencircle scaled 1mm
        withcolor "red" ;
    drawdot anchorxy("one", 0, 2)
        withpen pencircle scaled 1mm
        withcolor "red" ;
    drawdot anchorxy("two", 0, 1)
        withpen pencircle scaled 1mm
        withcolor "red" ;
    drawdot anchorxy("two", 0, 2)
        withpen pencircle scaled 1mm
        withcolor "red" ;
    drawdot anchorxy("three", 0, 1)
        withpen pencircle scaled 1mm
        withcolor "red" ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\startuseMPgraphic{whatever-2}
    pair a ; a := anchorxy("one", 0, 1) ;
    pair b ; b := anchorxy("one", 0, 2) ;
    drawarrow
        anchorxy("one", 0, 1) { right } ..
        anchorxy("one", 0, 2)
        withcolor "blue" withtransparency (1,.75) ;
    drawarrow
        anchorxy("two", 0, 1) { down } ..
        anchorxy("two", 0, 2)
        withcolor "blue" withtransparency (1,.75) ;
    drawarrow
        anchorxy("two", 0, 1) { dir 30 } ..
        anchorxy("three", 0, 1)
        withcolor "blue" withtransparency (1,.75) ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[whatever-1][\useMPgraphic{whatever-1}]
\defineoverlay[whatever-2][\useMPgraphic{whatever-2}]

\framed
  [synchronize=yes,
   align=normal,
   offset=10pt,
   frame=off,
   background={whatever-1,foreground,whatever-2}]
  {\startmathmatrix
      \NC \markanchor{two}{0}{1}a \NC b \NC c\NR
      \NC a \NC b \NC c\NR
      \NC a \NC \markanchor{one}{0}{1}b \NC c\NR
      \NC \markanchor{one}{0}{2}a \NC b \NC \markanchor{two}{0}{2}c\NR
      \NC a \NC \markanchor{three}{0}{1}b \NC c\NR
  \stopmathmatrix}

\startuseMPgraphic{whatever-3}
    pair a ; a := anchorxy("a", 0, 1) ;
    pair b ; b := anchorxy("a", 0, 2) ;
    draw boundingbox (a--b)
        leftenlarged .25EmWidth
        rightenlarged EmWidth
        topenlarged StrutHeight
        bottomenlarged .5StrutDepth
        withcolor "blue" withtransparency (1,.75) ;
    setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[whatever-3][\useMPgraphic{whatever-3}]

\framed
  [synchronize=yes,
   align=normal,
   offset=10pt,
   frame=off,
   background=whatever-3]
  {\startmathmatrix
      \NC a \NC                     a \NC                       b \NC c\NR
      \NC a \NC                     a \NC                       b \NC c\NR
      \NC a \NC \markanchor{a}{0}{1}a \NC                       b \NC c\NR
      \NC a \NC                     a \NC \markanchor{a}{0}{2}b \NC c\NR
      \NC a \NC                     a \NC                       b \NC c\NR
      \NC a \NC                     a \NC                       b \NC c\NR
  \stopmathmatrix}

\stoptext

The \markanchor{a}{0}{1 can be wrapped in a simpler one, or we can have something \markedanchor{a}{2}{b} but that need a little thinking because we don't want to mess too much with math spacing. Actually we can consider (in this case) \MC[a,2] or so although these are probabbly not features used that often.

Hans

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to