Hi, I uploaded a new lmtx version. This time a new mechanism. ----------------------------- From an upcoming details chapter: ----------------------------- The mechanism described here is still experimental. Although it could be implemented in \MKIV\ it is only available in \LMTX. Already early in \MKII\ we had a positioning mechanism available. At that time we had \DVI\ output and specials were used to track positions. A script calculated the positions that were then fed back into the second run. Later Taco wrote \DVIPOS\ which sped up the analysis between runs. When \PDFTEX\ showed, an equivalent positioning mechanism was added there. In \MKIV\ positioning support was optimized a bit as part of the upgrading process but the principles remained the same. The interface to positioning comes with a lot of commands and many of them relate to what we want to do with \METAFUN. The alternative interface discussed here is a bit simpler and has (at least now) less commands and, combined with local name spaces, can be easier to use in more local situations. It's also integrated in the frequently used \type {\framed} commands and has basic support at the \METAFUN\ end. The performance is comparable to the regular positioning mechanisms but especially at the \METAPOST\ end has less overhead. ----------------------------- Here are some examples: ----------------------------- \framed [synchronize=yes,align=normal] {% test test test 1 \sync{one}{1}test test 2 \crlf test test 1 \sync{one}{1}test test test 2 \crlf test 1 \sync{one}{1}test 2 \crlf test test test test 1 \sync{one}{1}test test 2 } \framed [synchronize=yes,align=normal] {% one one \sync{a}{1}two \sync{a}{2}three \crlf one one \sync{a}{1}two two \sync{a}{2}three \crlf one \sync{a}{1}two \sync{a}{2}three \crlf one one one \sync{a}{1}two \sync{a}{2}three } \framed [synchronize=yes,align=normal] {% \syncanchor{one}{1}{1}A \syncanchor{one}{2}{1}BBB \syncanchor{one}{3}{1}C \crlf \syncanchor{one}{1}{2}AA \syncanchor{one}{3}{2}C \crlf \syncanchor{one}{1}{3}AAA \syncanchor{one}{2}{3}BB \syncanchor{one}{3}{3}C } \framed [synchronize=yes,align=normal] {% \alignanchor{one}{1}{1}{l}A \alignanchor{one}{1}{2}{m}AA \alignanchor{one}{1}{3}{r}AAA \syncanchor {one}{1}{4}\crlf \alignanchor{one}{2}{1}{right}B \alignanchor{one}{2}{2}{middle}BB \alignanchor{one}{2}{3}{left}BBB \syncanchor {one}{2}{4} } \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}] {% \markanchor{two}{0}{1}{\red\bf foo}% \markanchor{one}{0}{1} bar rab oof\crlf foo bar rab oof\crlf oof rab bar foo\crlf oof rab \markanchor{two}{0}{2}{\red\bf bar}% \markanchor{one}{0}{2} foo% \markanchor{three}{0}{1}% } \framed [synchronize=yes, align=normal, offset=10pt, frame=off, background={whatever-1,foreground,whatever-2}] {% one one one \syncanchor{a}{1}{1}two two two \syncanchor{a}{2}{1}three three\par one \syncanchor{a}{1}{2}two \syncanchor{a}{2}{2}three\par one \syncanchor{a}{1}{3}two \syncanchor{a}{2}{3}three\par \blank \markanchor{two}{0}{1}{\red\bf foo}% \markanchor{one}{0}{1} bar rab oof\crlf foo bar rab oof\crlf oof rab bar foo\crlf oof rab \markanchor{two}{0}{2}{\red\bf bar}% \markanchor{one}{0}{2} foo% \markanchor{three}{0}{1}% \blank one one \syncanchor{a}{1}{4}two two \syncanchor{a}{2}{4}three\par one one \syncanchor{a}{1}{5}two two \syncanchor{a}{2}{5}three three% \markanchor{three}{0}{1}% } \framed[synchronize=yes,align=normal]{% one one \sync{a}{1}two \sync{a}{2}three\par one one \sync{a}{1}two two \sync{a}{2}three\par \blank tst tst \sync{b}{1}tst \sync{b}{2}tst\par tst \sync{b}{1}tst tst \sync{b}{2}tst\par \blank one \sync{a}{1}two \sync{a}{2}three } \page \startpacked $a = b + c $\par $b = c + d $\par $c = e + f $\par \stoppacked \startpacked \startsynchronizing $a \syncanchor{one}{1}{1}= b \syncanchor{one}{2}{1}+ c$\par $b \syncanchor{one}{1}{2}= c \syncanchor{one}{2}{2}+ d$\par $c \syncanchor{one}{1}{3}= e \syncanchor{one}{2}{3}+ f$\par \stopsynchronizing \stoppacked \startpacked \startsynchronizing $a \sync{one}{1}= b \sync{one}{2}+ c$\par $b \sync{one}{1}= c \sync{one}{2}+ d$\par $c \sync{one}{1}= e \sync{one}{2}+ f$\par \stopsynchronizing \stoppacked \startpacked \startsynchronizing $a \mathsync{1}= b \mathsync{2}+ c$\par $b \mathsync{1}= c \mathsync{2}+ d$\par $ \mordsync{1}= e \mathsync{2}+ f$\par \stopsynchronizing \stoppacked ----------------------------- remark ----------------------------- So, it's a varaant on the positioning mechanism. It also works in framed when the synchronization option is enabled. Don't enable that when not used (as there is some overhead involved). I have no clue how useful it is but users always find a way to use mechanisms. One can do really freaky things with it. Who knows what gets added over time. Also, it doesn't replace the existing positioning mechanism which served us well for decades; it's just a lightweight variant with different pros and cons. 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 -----------------------------------------------------------------
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-elem...) 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. Thanks, Aditya
On 5/31/2021 6:50 PM, Aditya Mahajan wrote:
as long as you work within a predictable namespace and box/unbox situation
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-elem...) 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. ah ... http://www.tug.org/tug2003/preprints/Bilotta/bilotta2.pdf
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 -----------------------------------------------------------------
On 5/31/2021 6:50 PM, Aditya Mahajan wrote:
\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 -----------------------------------------------------------------
On 5/31/2021 9:04 PM, Aditya Mahajan wrote:
\starttext \startuseMPgraphic{whatever-5} fill OverlayBox withcolor "lightgray" ; draw matrixbox (1, 1) (2, 1) withpen pencircle scaled 1pt withcolor "blue" ; draw matrixbox (2, 2) (4, 4) withpen pencircle scaled 1pt withcolor "red" ; % drawdot anchorxy("matrix", 3, 4) withpen pencircle scaled 4pt withcolor "green"; setbounds currentpicture to OverlayBox ; \stopuseMPgraphic \defineoverlay[whatever-5][\useMPgraphic{whatever-5}] \framed [synchronize=background, align=normal, frame=off, background=whatever-5] {\setmathmatrixanchoring[both]% left|right|both|yes % {\setmathmatrixanchoring[right]% left|right|both|yes \startmathmatrix \NC a1 \NC a \NC b \NC c\NR \NC a2 \NC a \NC b \NC c\NR \NC a3 \NC a^2 \NC b \NC c\NR \NC a4 \NC a \NC b_2 \NC c\NR \NC a5 \NC a \NC b \NC c\NR \NC a6 \NC a \NC b \NC c\NR \stopmathmatrix} \blank \startuseMPgraphic{whatever-5} fill OverlayBox withcolor "darkgray" ; draw matrixbox (1, 1) (2, 1) enlarged OverlayOffset shifted paired(OverlayOffset) withpen pencircle scaled 1pt withcolor "blue" ; draw matrixbox (2, 2) (4, 4) enlarged OverlayOffset shifted paired(OverlayOffset) withpen pencircle scaled 1pt withcolor "red" ; setbounds currentpicture to OverlayBox ; \stopuseMPgraphic \framed [synchronize=background, align=normal, frame=off, background=whatever-5, backgroundoffset=.5ex, foregroundcolor=white] {\setmathmatrixanchoring[yes]% left|right|both|yes \startmathmatrix \NC a1 \NC a \NC b \NC c\NR \NC a2 \NC a \NC b \NC c\NR \NC a3 \NC a^2 \NC b \NC c\NR \NC a4 \NC a \NC b_2 \NC c\NR \NC a5 \NC a \NC b \NC c\NR \NC a6 \NC a \NC b \NC c\NR \stopmathmatrix} \stoptext as a side track / distraction I added italic correction prevention, as shown in: \starttext \startTEXpage[offset=10pt] \showglyphs \startcombination[nx=3,ny=1] \startcontent \framed[strut=no,align=normal,offset=1ex]\bgroup \showmakeup[math,kern]% $a = b + c$\par $b = c + d$\par $c = e + f$\par \egroup \stopcontent \startcaption italic correction \stopcaption \startcontent \framed[strut=no,align=normal,offset=1ex]\bgroup \showmakeup[math,kern]% \noitaliccorrection $a = b + c$\par $b = c + d$\par $c = e + f$\par \egroup \stopcontent \startcaption no italic correction \stopcaption \startcontent \framed[strut=no,align=normal,offset=1ex]\bgroup \showmakeup[math,kern]% $a = b + c$\par $\noitaliccorrection b = c + d$\par $c = e + f$\par \egroup \stopcontent \startcaption selected correction \stopcaption \stopcombination \stopTEXpage \stoptext but of course different width are still a reason why this doesn't align 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 -----------------------------------------------------------------
participants (2)
-
Aditya Mahajan
-
Hans Hagen