Hello list,

I’m trying to reproduce the positional graphics examples in the MetaFun manual 
on pp. 151-153. There are two examples of code for the mpos:box. The first 
example uses \MPvar to retrieve variables set using \setupMPvariables. This 
works fine. The second example uses texvar to retrieve variables, but it does 
not work in the current LMTX. However, the second example does work with my 
TeXLive install.

I’ve put my working example below, with both versions of the mpos:box code. Log 
output from a failed run is below that. Any ideas where I might be going wrong?

Thanks!
Gavin


\setupbackgrounds
  [page]
  [background={backgraphics,foreground,foregraphics}]
\defineoverlay [backgraphics] [\positionoverlay{backgraphics}]
\defineoverlay [foregraphics] [\positionoverlay{foregraphics}]

\setupMPvariables
  [mpos:box]
  [linecolor=blue,
   linewidth=\linewidth,
   fillcolor=lightgray,
   filloffset=2pt]

%%%%%%%%  This mpos:box works using \MPvar. %%%%%%%
\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth}
  string tag; tag := "\MPvar{self}" ;
  path box ; box := positionbox(tag) ;
  box := box enlarged  \MPvar{filloffset} ;
  fill box
    withcolor \MPvar{fillcolor} ;
  draw box
    withcolor \MPvar{linecolor}
    withpen pencircle scaled \MPvar{linewidth} ;
  positioninregion ;
\stopMPpositiongraphic

%%%%%%%  This mpos:box does not work using texvar. (log below) %%%%%%%
%\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth}
%  path box ; box := positionbox(texstr("self")) ;
%  box := box enlarged  texvar("filloffset") ;
%  fill box
%    withcolor texvar("fillcolor") ;
%  draw box
%    withcolor texvar("linecolor")
%    withpen pencircle scaled texvar("linewidth") ;
%  positioninregion ;
%\stopMPpositiongraphic


\starttext

to get \hpos {A-0} {positions} sorted

\startpositionoverlay{backgraphics}
   \setMPpositiongraphic{A-0}{mpos:box}{self=A-0}
\stoppositionoverlay

\stoptext


system          > 
system          > ConTeXt  ver: 2022.05.11 11:36 LMTX  fmt: 2022.5.20  int: 
english/english
system          > 
system          > 'cont-new.mkxl' loaded
open source     > level 1, order 1, name 
'/Users/Gavin/context-osx-arm64/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system          > beware: some patches loaded from cont-new.mkiv
close source    > level 1, order 1, name 
'/Users/Gavin/context-osx-arm64/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl'
system          > files > jobname './ContractionExperiments', input 
'./ContractionExperiments.tex', result './ContractionExperiments'
fonts           > latin modern fonts are not preloaded
languages       > language 'en' is active
system          > synctex functionality is enabled, expect 5-10 pct runtime 
overhead!
open source     > level 1, order 2, name './ContractionExperiments.tex'
fonts           > preloading latin modern fonts (second stage)
fonts           > 'fallback modern-designsize rm 12pt' is loaded
metapost        > initializing instance 'metafun:1' using format 'metafun' and 
method 'double'
metapost        > loading 'metafun' as 'metafun.mpxl' using method 'double'
metapost        > initializing number mode 'double'
metapost        > trace > This is MPLIB for LuaMetaTeX, version 3.12, running 
in double mode.
metapost        > trace > 
metapost        > trace > loading metafun for lmtx, including the plain 1.004 
base definitions
metapost        > trace > 
metafun         > log >
metafun         > log > error: Missing ')' has been inserted
metafun         > log >
metapost        > trace > <to be read again> ,
metapost        > trace > <macro> paired -> <primary> -> 
begingroup.if.pair(EXPR2):(EXPR2)else:((EXPR2),(EXPR2))fi.endgroup
metapost        > trace > <to be read again> ,
metapost        > trace > <macro> llmoved -> -> 
((llcorner(EXPR0))shifted(-xpart.paired((EXPR1)),-ypart.paired((EXPR1))))
metapost        > trace > <to be read again> {
metapost        > trace > <macro> -- -> -> {curl1}..{curl1}
metapost        > trace > <macro> enlarged -> -> 
((EXPR0)llmoved(EXPR1)--(EXPR0)lrmoved(EXPR1)--(EXPR0)urmoved(EXPR1)--(EXPR0)ulmoved(EXPR1)--cycle)
metapost        > trace > <to be read again> ;
metafun         > log >
metafun         > log > I found no right delimiter to match a left one. So I've 
put one in, behind the
scenes; this may fix the problem.
metafun         > log >
metapost        > trace > <direct> path box ; box := 
positionbox(texstr("self")) ; box := box enlarged texvar("filloffset") ; fill 
box withcolor texvar("fillcolor") ; draw box withcolor texvar("linecolor") 
withpen pencircle scaled texvar("linewidth") ; positioninregion ; ;
metapost        > trace > 
backend         > xmp > using file 
'/Users/Gavin/context-osx-arm64/tex/texmf-context/tex/context/base/mkiv/lpdf-pdx.xml'
pages           > flushing realpage 1, userpage 1, subpage 1
___________________________________________________________________________________
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