On 1/1/2022 11:46 AM, Youssef Cherem via ntg-context wrote:
> Dear list users,
>
> How can one go about implementing a ruler around the page/text area
> (such as a background) like the one provided by the latex package
> fgruler? https://www.ctan.org/tex-archive/macros/latex/contrib/fgruler
> <https://www.ctan.org/tex-archive/macros/latex/contrib/fgruler> or koma
> script's \layercontentsmeasure?
a good opportunity to learn some metapost
\startuniqueMPpagegraphic{ruler}
numeric n, f, sign ;
pair first, last;
if OnOddPage :
first := urcorner Page;
last := lrcorner Page;
sign := -1;
else :
first := ulcorner Page;
last := llcorner Page;
sign := 1;
fi ;
f := xpart first;
n := 0;
draw first -- last withpen pencircle scaled 2pt;
for i = ypart first step -1mm until ypart last :
if (n mod 10) == 0 :
draw (f,i) -- (f+sign*10mm,i) ;
if OnOddPage :
draw thetextext.lft(n/10,(f+sign*12mm,i)) ;
else :
draw thetextext.rt (n/10,(f+sign*12mm,i)) ;
fi
elseif (n mod 5) == 0 :
draw (f,i) -- (f+sign*5mm,i) ;
else :
draw (f,i) -- (f+sign*3mm,i) ;
fi ;
n := n + 1 ;
endfor ;
setbounds currentpicture to Page ;
\stopuniqueMPpagegraphic
\defineoverlay[ruler][\uniqueMPpagegraphic{ruler}]
\setupbackgrounds[page][background=ruler]
\setuppagenumbering[alternative=doublesided]
\starttext
\dorecurse{10}{test \page}
\stoptext
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------