ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Cc: ntg-context@ntg.nl
Subject: Re: Header counter that resets with page
Date: Sat, 29 Sep 2001 19:01:40 +0200	[thread overview]
Message-ID: <5.1.0.14.1.20010929154333.025ba350@pop.planet.nl> (raw)
In-Reply-To: <20010923152859.A914@ruhrau.de>

Hi,

>I need a heading with a counter on its own, which is referrable,
>and listable, and which resets with each new page. Eventually,
>it should have a number that consists of the page number and
>an alphabetical counter, so subsequent entries on one page 6 have
>counters 6a, 6b, and so on.

let's first get your file working -)

you say : \defineenumeration[nwcodechunkhead]

the enumeration and description commands take an argument delimited by a 
\par (or empty line); they do so because they can apply a font to a 
definition.

\defineenumeration[test]

\test something \par

or (was already suggested by someone else here)

\starttest
   something \par
   something more
\stoptest

which is the better way.

btw, you can put enum's in the margin directly

so

\nwmargintag{{\nwtagstyle{}\at[NWlont-*-1].\in[NWlont-*-1]}}\par

will work ok for you. Now to the page sync'd enumerations.

% The following can go into cont-new.tex

\unprotect

% some new code
\newif\ifpagechanged \let\lastchangedpage\empty

\def\checkpagechange#1%
   {\gettwopassdata{\s!paragraph}%
    \pagechangedfalse
    \iftwopassdatafound
      \ifnum\twopassdata>0\getvalue{\s!paragraph:p:#1}\relax
        \pagechangedtrue
      \fi
    \fi
    \ifpagechanged
      \global\letvalue{\s!paragraph:p:#1}\twopassdata
      \global\let\lastchangedpage\twopassdata
    \else
      \global\let\lastchangedpage\realfolio
    \fi
    \doparagraphreference}

% a bonus

\def\changedpage#1%
   {\getvalue{\s!paragraph:p:#1}}

% an overloaded macro

\def\verhoognummer[#1]%
   {\doifelsevalue{\s!number#1\c!wijze}{\v!per\v!pagina}
      {\checkpagechange{#1}%
       \ifpagechanged\resetcounter{\s!number#1}\fi}
      {\checknummer{#1}}%
    \ifnummeren
      \pluscounter{\s!number#1}%
    \else
      \setcounter{\s!number#1}{0\getvalue{\s!number#1\c!start}}%
    \fi}

\protect
% so far for cont-new. Here is your test material

\defineenumeration [test] [way=bypage,text=\lastchangedpage]

\starttext \dorecurse{10}{\test \input tufte \par} \stoptext

% happy hacking

Hans

-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


      reply	other threads:[~2001-09-29 17:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-20 19:45 Johannes Huesing
2001-09-20 20:45 ` Johannes Huesing
2001-09-21  9:04 ` Hans Hagen
2001-09-22 16:02   ` Johannes Huesing
2001-09-23  9:59     ` Hans Hagen
2001-09-23 13:28       ` Johannes Huesing
2001-09-29 17:01         ` Hans Hagen [this message]

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=5.1.0.14.1.20010929154333.025ba350@pop.planet.nl \
    --to=pragma@wxs.nl \
    --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).