ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: mf <massifr@fastwebnet.it>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: registers: setting pageleft parameter by index term
Date: Tue, 30 Apr 2019 02:16:52 +0200	[thread overview]
Message-ID: <1dffc7c5-43a3-6b69-7c8a-f6d79c9aa9c9@fastwebnet.it> (raw)

Hello list, please consider this MWE:

\definenumber[p]
\setnumber[p][1]
\def\PageLeft{ p.~}
\def\TextCommand#1{\getnumber[p] 
#1\doif{\rawcountervalue[p]}{2}{\def\PageLeft{ P.~}}\incrementnumber[p]}
\setupindex[n=1,pageleft=\PageLeft,pageright=,textcommand=\TextCommand]
\starttext
Foo\index{foo}.
\page
Bar\index{bar}.
\page
Baz\index{baz}.
\page
\placeindex
\stoptext

The pageleft parameter of \setupindex (\setupregister) is normally set 
to " p.~", but it gets redefined to " P.~" for the second term in the 
index ("baz").

Here i'm using a counter and i check when it is 2, but i'd like to check 
if the term is "baz" (and i don't know how to do that test).

If you use deeptextcommand instead of textcommand, the pageleft 
parameter can't be redefined.

The following variation compiles, but it does not work, because pageleft 
is always " p.~":

\definenumber[p]
\setnumber[p][1]
\def\PageLeft{ p.~}
\def\TextCommand#1{\getnumber[p] 
#1\doif{\rawcountervalue[p]}{2}{\def\PageLeft{ P.~}}\incrementnumber[p]}
\setupindex[n=1,pageleft=\PageLeft,pageright=,deeptextcommand=\TextCommand]
\starttext
Foo\index{foo}.
\page
Bar\index{bar}.
\page
Baz\index{baz}.
\page
\placeindex
\stoptext

In my setup i must use deeptextcommand, and i want to set the pageleft 
and pageright parameters to a different value for some particular terms 
of the index.

Since the argument passed to deeptextcommand is not the text of the term 
(it's actually an id used to retrieve a much longer text), i can 
discriminate the terms by their id, but i can't setup pageleft and 
pageright accordingly from the command specified by deeptextcommand.

On the other hand, textcommand would let me set pageleft and pageright, 
but its argument is not pure text, and i don't know how to get the id 
from it.

How can i solve this problem?

Thanks,

Massimiliano

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

                 reply	other threads:[~2019-04-30  0:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1dffc7c5-43a3-6b69-7c8a-f6d79c9aa9c9@fastwebnet.it \
    --to=massifr@fastwebnet.it \
    --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).