Answering my own question in case someone else is interested: The code
below seems to work on this specific example (but probably needs adapting
in more complex cases).

_____________________________________________
\setupbodyfont[dejavu,9pt]

\setuphead[subject][
    style=bold,
    before={\blank[line]},
    after={\blank[none]},
]

\setuplayout[
    backspace=13mm,
    width=middle,
    topspace=13mm,
    height=middle,
    header=0mm,
    footer=0mm,
    grid=yes,
]

\startMPcode
  numeric NColsOnPage ; NColsOnPage := 0 ;
  numeric PageOfLastCol ; PageOfLastCol := 0 ;
\stopMPcode

\startuseMPgraphic{verticalrule}
save vrule ;
boolean lastpage ; lastpage := (positionpage("allendshere") ==
RealPageNumber) ;
if RealPageNumber > PageOfLastCol :
  NColsOnPage := 0 ;
  PageOfLastCol := RealPageNumber ;
fi ;
boolean lastcolumn ; lastcolumn := ((NColsOnPage * (TextWidth +
\frameddimension{distance}) + BackSpace)
                                    > (xpart positionxy("allendshere")));
boolean pastlastcolumn ; pastlastcolumn := (((NColsOnPage-1) * (TextWidth +
\frameddimension{distance}) + BackSpace)
                                            > (xpart
positionxy("allendshere")));
if NColsOnPage > 0 :
  if (lastpage and pastlastcolumn) :
    % nothing
  elseif (lastpage and lastcolumn) :
    % nothing
    path vrule ; vrule := ((ulcorner OverlayBox)
                          -- (0, (ypart positionxy("allendshere") -
TopSpace)))
                            shifted (-\frameddimension{distance}/2,0) ;
    draw vrule ;
  else :
    path vrule ; vrule := (leftboundary OverlayBox) shifted
(-\frameddimension{distance}/2,0) ;
    draw vrule ;
  fi ;
fi ;
NColsOnPage := NColsOnPage + 1 ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[verticalrule][\useMPgraphic{verticalrule}]

\definecolumnset[ThreeColumns][n=3,background=verticalrule]

\setupalign[verytolerant,stretch]

\starttext

\startThreeColumns
    \dorecurse{10}{%
        \subject[title={Foo \recurselevel}]
        \samplefile{lorem}
    }
    \hpos{allendshere}{}
\stopThreeColumns

\stoptext
__________________________________________________________

Le sam. 6 déc. 2025 à 19:43, Florent Michel <[email protected]> a
écrit :

> Hi again,
>
> I tried running the code in the accepted answer from this StackExchange
> question:
> https://tex.stackexchange.com/questions/641779/adding-column-rules-in-contexts-columnsets-pagecolumns
> (see below); but the vertical rules do not seem to appear with LMTX
> 2025.12.05 17:46. (I think the code gave the expected output until at least
> two months ago, although I am not 100% sure of that.)
>
> Would anyone know how to update it to work with the latest version of
> LMTX?
> _______________________________________
> \setupbodyfont[dejavu,9pt]
>
> \setuphead[subject][
>     style=bold,
>     before={\blank[line]},
>     after={\blank[none]},
> ]
>
> \setuplayout[
>     backspace=13mm,
>     width=middle,
>     topspace=13mm,
>     height=middle,
>     header=0mm,
>     footer=0mm,
>     grid=yes,
> ]
>
> \startuseMPgraphic{verticalrule}
> save a, b, c, p, q, r ;
> path b ; b := positioncolumnbox(CurrentColumn) ;
> draw image (
>     path p ; p := rightboundary b shifted (\frameddimension{distance}/2,0)
> ;
>     numeric c ; c := positioncolumn(positionregion("allendshere")) ;
>     if (positionpage("allendshere") = RealPageNumber):
>         if (CurrentColumn < c) :
>             draw p withcolor black withpen pencircle scaled 1 ;
>         elseif (CurrentColumn > c) :
>             % nothing
>         else :
>             if CurrentColumn < NOfColumns :
>                 pair a ; a := positionxy ("allendshere") ;
>                 path q ; q := (0,ypart a) -- (PaperWidth,ypart a) ;
>                 path r ; r := p cutbeforefirst q ;
>                 draw r withcolor black withpen pencircle scaled 1 ;
>             fi ;
>         fi ;
>     else :
>         if CurrentColumn < NOfColumns :
>             draw p withcolor black withpen pencircle scaled 1 ;
>         fi ;
>     fi ;
> ) shifted -llcorner b ;
> setbounds currentpicture to OverlayBox ;
> \stopuseMPgraphic
>
> \defineoverlay[verticalrule][\useMPgraphic{verticalrule}]
>
> \setupalign[verytolerant,stretch]
>
> \starttext
>
> \startpagecolumns[n=3,background=verticalrule]
>     \dorecurse{10}{%
>         \subject[title={Foo \recurselevel}]
>         \samplefile{lorem}
>     }
>     \hpos{allendshere}{}
> \stoppagecolumns
>
> \stoptext
> _______________________________________________________
>
> Cheers,
> Florent
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to