ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* measure layer/ ruler
@ 2022-01-01 10:46 Youssef Cherem via ntg-context
  2022-01-01 13:15 ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Youssef Cherem via ntg-context @ 2022-01-01 10:46 UTC (permalink / raw)
  To: ntg-context; +Cc: Youssef Cherem


[-- Attachment #1.1: Type: text/plain, Size: 263 bytes --]

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 or koma
script's \layercontentsmeasure?

[-- Attachment #1.2: Type: text/html, Size: 663 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: measure layer/ ruler
  2022-01-01 10:46 measure layer/ ruler Youssef Cherem via ntg-context
@ 2022-01-01 13:15 ` Hans Hagen via ntg-context
  2022-01-01 15:55   ` Youssef Cherem via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen via ntg-context @ 2022-01-01 13:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: measure layer/ ruler
  2022-01-01 13:15 ` Hans Hagen via ntg-context
@ 2022-01-01 15:55   ` Youssef Cherem via ntg-context
  0 siblings, 0 replies; 3+ messages in thread
From: Youssef Cherem via ntg-context @ 2022-01-01 15:55 UTC (permalink / raw)
  To: Hans Hagen; +Cc: Youssef Cherem, mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2320 bytes --]

Hans,

Thanks a lot. I'm still trying to apply this to the top/bottom; I suppose
it should be simple after I have a firmer grasp of language.

lør. 1. jan. 2022 kl. 10:15 skrev Hans Hagen <j.hagen@xs4all.nl>:

> 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
> -----------------------------------------------------------------
>

[-- Attachment #1.2: Type: text/html, Size: 3546 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-01 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-01 10:46 measure layer/ ruler Youssef Cherem via ntg-context
2022-01-01 13:15 ` Hans Hagen via ntg-context
2022-01-01 15:55   ` Youssef Cherem via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).