Hi Dalyoung,
Thanks a lot for the feedback! Glad to hear that my attempt at updating
this example can be useful!
On this note, I noticed that the code in my previous message fails when
there are multiple `ThreeColumns` regions. The code below seems to fix this
issue (although in a slightly hack-y way).
________________________________________________
\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,
]
\startMPinclusions
numeric NColsOnPage ; NColsOnPage := 0 ;
numeric PageOfLastCol ; PageOfLastCol := 0 ;
\stopMPinclusions
\startuseMPgraphic{verticalrule}
save vrule, lastpage, lastcolumn, pastlastcolumn ;
boolean lastpage ; lastpage := (positionpage("\terminationMark") ==
RealPageNumber) ;
if RealPageNumber > PageOfLastCol :
NColsOnPage := 0 ;
PageOfLastCol := RealPageNumber ;
fi ;
boolean lastcolumn ; lastcolumn := ((NColsOnPage * (TextWidth +
\frameddimension{distance}) + BackSpace)
> (xpart
positionxy("\terminationMark")));
boolean pastlastcolumn ; pastlastcolumn := (((NColsOnPage-1) * (TextWidth +
\frameddimension{distance}) + BackSpace)
> (xpart
positionxy("\terminationMark")));
if NColsOnPage > 0 :
if (lastpage and pastlastcolumn) :
% nothing
elseif (lastpage and lastcolumn) :
path vrule ; vrule := ((ulcorner OverlayBox)
-- (0, (ypart positionxy("\terminationMark") -
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,
]
\setcounter[nColumnSets][0]
\definestartstop[MyColumns][
before={\incrementcounter[nColumnSets]
\def\terminationMark{allendshere\rawcountervalue[nColumnSets]}
\startThreeColumns},
after={\xypos{\terminationMark}{}\stopThreeColumns},
]
\setupalign[verytolerant,stretch]
\starttext
\startMyColumns
\dorecurse{1}{%
\subject[title={Foo \recurselevel}]
\samplefile{lorem}
}
\stopMyColumns
\startMyColumns
\dorecurse{3}{%
\subject[title={Foo \recurselevel}]
\samplefile{lorem}
}
\stopMyColumns
\startMyColumns
\dorecurse{5}{%
\subject[title={Foo \recurselevel}]
\samplefile{lorem}
}
\stopMyColumns
\startMyColumns
\dorecurse{10}{%
\subject[title={Foo \recurselevel}]
\samplefile{lorem}
}
\stopMyColumns
\stoptext
________________________________________________
Cheers,
Florent
Le lun. 8 déc. 2025 à 08:51, Jeong Dal via ntg-context <[email protected]>
a écrit :
> Dear Florent,
>
> Thanks for sharing your example. It works very well, and your metaFun code
> looks nice.
>
> I usually use the two-column text surrounded by the box for the exam
> paper.
> When I had troubles to draw it, experts in this list helped me to draw the
> boxes.
> And your code may be another way for more columns.
>
> Best regards,
>
> Dalyoung
>
>
>
> ___________________________________________________________________________________
> 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
>
> ___________________________________________________________________________________
>
___________________________________________________________________________________
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
___________________________________________________________________________________