ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Wolfgang Schuster" <schuster.wolfgang@googlemail.com>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: Re: need help with creating a grid with context
Date: Thu, 11 Oct 2007 09:27:45 +0200	[thread overview]
Message-ID: <115224fb0710110027r35bfa638j86b3b8b71b385779@mail.gmail.com> (raw)
In-Reply-To: <470C933B.1060308@gmx.net>

2007/10/10, Peter Rolf <indiego@gmx.net>:
> Hi Peter,
>
> MASON Peter J schrieb:
> > I'm trying to layout a grid of bullets. The results isn't the expected
> > one. Perhaps someone could offer help here? Thanks.
> >
> > Here's the sort of thing I'm doing ....
> >
> > \setuplayout[leftmargin=0pt, leftmargindistance=0pt, backspace=0pt,
> > rightmargin=0pt, rightmargindistance=0pt, cutspace=0pt, width=middle,
> > topspace=0pt, header=0pt, headerdistance=0pt, footer=0pt,
> > footerdistance=0pt, bottomspace=0pt, height=middle]
> >
> > %\showlayout
> >
> > \starttext
> > \setuppositioning[unit=cm]
> > \startpositioning
> >         \newcount\Row
> >
> >         \Row    = 0
> >         \loop
> >                 {
>                   ^^
> >                         \newcount\Col
> >
>  ^^
> >                         \Col = 0
> >                         \loop
> >                                 \position(\Col, \Row) {$\bullet$}
> >                                 \ifnum\Col < 14
> >                                         \advance\Col by 1
> >                         \repeat
> >                 }
>                   ^^
> >                 \ifnum\Row < 36
> >                         \advance\Row by 1
> >         \repeat
> > \stoppositioning
> > \stoptext
> >
> You introduce "spurious spaces" (line break sometimes adds a space) in
> you loops. See
>
> http://tug.ctan.org/tex-archive/info/texbytopic/
>
> if you want to learn more about it.
>
>
> \starttext
> \setuppositioning[unit=cm]
> \startpositioning
> \newcount\Row
> \newcount\Col
>
> \Row=0
> \dorecurse{36}
>  {\Col=0
>   \dorecurse{14}
>     {\position(\Col,\Row){$\bullet$}
>      \advance\Col by 1
>     }%
>   \advance\Row by 1
>  }
> \stoppositioning
> \stoptext
>
>
> Remove the comment sign behind the inner loop and see what happens.
>
> Also see
>
> http://wiki.contextgarden.net/System_Macros/Loops_and_Recursion
>
> for the nicer ConTeXt loop macros.
>
>
> Best wishes, Peter

Hi,

there is smarter and better solution than loop for doing this work,
you can use leaders. I prefer myself xledaers in this example (alternative b).

\defineoverlay[PageGrid][\PageGrid]

\setupbackgrounds[page][background=PageGrid,offset=5mm]

\starttext

% alternative a:

\def\PageGrid
  {\setbox\scratchbox\hbox to\dimexpr\paperwidth-1cm\relax
     {\leaders\hbox to 1cm{\hss$\bullet$\hss}\hfill}%
   \vbox to\dimexpr\paperheight-1cm\relax
     {\leaders\vbox to 1cm{\vss\box\scratchbox\vss}\vfill}}

\page[empty]

% alternative b:

\def\PageGrid
  {\setbox\scratchbox\hbox to\dimexpr\paperwidth-1cm\relax
     {\xleaders\hbox to 1cm{\hss$\bullet$\hss}\hfill}%
   \vbox to\dimexpr\paperheight-1cm\relax
     {\xleaders\vbox to 1cm{\vss\box\scratchbox\vss}\vfill}}

\page[empty]

% alternative c:

\def\PageGrid
  {\setbox\scratchbox\hbox to\dimexpr\paperwidth-1cm\relax
     {\cleaders\hbox to 1cm{\hss$\bullet$\hss}\hfill}%
   \vbox to\dimexpr\paperheight-1cm\relax
     {\cleaders\vbox to 1cm{\vss\box\scratchbox\vss}\vfill}}

\page[empty]

\stoptext

Wolfgang
___________________________________________________________________________________
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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2007-10-11  7:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-09 23:42 MASON Peter J
2007-10-10  8:54 ` Peter Rolf
2007-10-11  7:27   ` Wolfgang Schuster [this message]
2007-10-10  1:06 MASON Peter J
2007-10-10 10:08 ` Mojca Miklavec
2007-10-10 13:02   ` Wolfgang Schuster
2007-10-10 19:33     ` Mojca Miklavec
2007-10-11  7:43       ` Wolfgang Schuster
2007-10-10 23:33 MASON Peter J

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=115224fb0710110027r35bfa638j86b3b8b71b385779@mail.gmail.com \
    --to=schuster.wolfgang@googlemail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).