ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Bug or feature? Strange counter behaviour in macro
Date: Sat, 12 Jan 2008 12:44:38 -0500 (EST)	[thread overview]
Message-ID: <alpine.DEB.0.9999.0801121220420.21905@nqv-yncgbc> (raw)
In-Reply-To: <FD4571E3-AC92-4BDE-94EE-AFE7A970F6E0@zarm-technik.de>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 5679 bytes --]

Hi Carsten,

On Fri, 11 Jan 2008, Carsten Fechtmann wrote:

> first off: I am new to ConTeXt (even if not so new to LaTeX)
> and would like to transfer some of my old macros to ConTeXt...
>
> I am well aware, that this means re-programming (most) of them.
> So be it.

Have you looked at enumerations? They provide a way to something very 
similar to what you want.

> If one places \NewIssue[Some Time] somewhere in the text, it should
> result in a new (issue / timestamp) to be generated, which can then
> placed in a list of issues / changes.

\defineenuemration[Issue][title=yes]

\Issue[one]{January 9, 2008} blah blah blah

\Issue[two]{January 10, 2008} more blah blah blah

In issue \in[one] we wrote what we did on \about[one]

> I also want to be able to make use of the last value Issue to be
> placed in the header, same goes for the last timestamp

Another option may to think of issue as a section (or subsection)

\definehead[Issue][section]

\Issue {Jan 9, 2008} What we did at that time.

\Issue {Jan 10, 2008} something else

\stoptext

Then you can use \setupheadertexts[issue] to get the current issue in the 
header.

> Now this is how I went out to do this in ConTeXt (maybe wrongly so?)
> following the manual and some examples on contextwiki

I haven't looked at your code below. First check if one the in-built 
stuctural environments of ConTeXt do what you want.

Aditya

> %---------------  code below  -----------------------
> \definesynonyms[Issue][issues][\IssueText][\IssueDate]
> \setupsynonyms[Issue][criterium=all]
>
> \newcounter\IssueCounter
>
> \definenumber[IssueNumber]
>
> \def\TempIssueText{%
> %% This was the (seemingly) only way to get any value beside 0
> %% 	from \getnumber within doAddIssue
> %% Original place for
> \incrementnumber[IssueNumber]
> 	Issue~\getnumber[IssueNumber]:
> }
> \def\NewIssue{\dosingleargument\doNewIssue}
> \def\doNewIssue[#1]{%
> 	\increment\IssueCounter  % This one works correctly.
> %% Alternative place for
> %\incrementnumber[IssueNumber]
>
> %% if placed here instead of in \TempIssueText
> %% a DIFFERENT, but still wrong result comes out
> %% that is: Debug shows the right progression,
> %% but ALL "Issue x" Numbers are set to the last one
> 	Debug: \IssueCounter / \getnumber[IssueNumber]%
> %% but alas I can't seem to make this work with the following lines :-(
> 	\doifempty{#1}{\Issue[\IssueCounter]{\TempIssueText}{\currentdate}}
> 	\doifnotempty{#1}{\Issue[\IssueCounter]{\TempIssueText}{#1}}
> %% Note: Using \dofiemptyelse gives the same result,
> %% I just wanted to make sure here that I am /really/ not calling it
> twice,
> %% somehow, by being able to disable each case, separately and
> definitely.
> 	-- \IssueCounter / \getnumber[IssueNumber]
> 	\crlf
> }
> % -- -- -- -- -- --
> \starttext
> \NewIssue[January 9, 2008]
> \NewIssue[January 10, 2008]
> \NewIssue 			% January 11, 2008
>
> List of issue \# and dates:
>
> \placelistofissues \blank
>
> \IssueDate{\IssueCounter} % produces correct result in either case
>
> \stoptext
> %---------------  code above  -----------------------
>
>  Result as printed out by original version
> ----------------------------------------------
>  Debug: 1/ 0 – 1/ 0
>  Debug: 2/ 0 – 2/ 0
>  Debug: 3/ 0 – 3/ 0
>
>  List of issue # and dates:
>  Issue 2: January 9, 2008
>  Issue 4: January 10, 2008
>  Issue 6: January 11, 2008
>
>  January 11, 2008
> ------------------------------
> So while \IssueCounter is updated correctly and used with the right
> values,
> \getnumber[IssueNumber] always sees / reports the original value
> However, the value in \placelistofissues are twice what they should be?!
>
> This is changed if one places \incrementnumber[IssueNumber] INSIDE of
> \doAddIssue
> Here, \getnumber[IssueNumber] does report the right value (same as
> IssueCounter)
> However, in that case the result looks like this:
>
>  Result as printed out by alternative version
> ----------------------------------------------
> Debug: 1/ 1 – 1/ 1
> Debug: 2/ 2 – 2/ 2
> Debug: 3/ 3 – 3/ 3
>
> List of issue # and dates:
>
> Issue 3: January 9, 2008
> Issue 3: January 10, 2008
> Issue 3: January 11, 2008
>
> January 11, 2008
> ------------------------
> In short, while now the value of \getnumber[IssueNumber] is correct
> before and after,
> its value in \placelistofissues is always the last value, i.e. equal
> to the total number of issues.
>
> And this does NOT even change, when one replaces
> 	Issue~\getnumber[IssueNumber]:
> 	Issue~\IssueCounter:
> in \TempIssueText
>
> So for some reason, \TempIssueText is called twice ? How? Where?
>
> Unfortunately, my ConTeXt.foo is not yet good enough to make it over
> the TeX.bar here
> as I haven't found a way to make this work (preferably with
> \IssueCounter
> as all this \XXXnumber stuff does not seem to work the way I think it
> should, anyway...)
>
> And yes, ANY help with this is very welcome by now
>
> Sincerely
> Carsten
> 
P.S: Context version is 2007.01.12 15:56 / TeXlive / OS X
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>
>
>

[-- Attachment #2: Type: text/plain, Size: 487 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2008-01-12 17:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-11 18:13 Carsten Fechtmann
2008-01-12 17:44 ` Aditya Mahajan [this message]
2008-01-12 19:45   ` Carsten Fechtmann
2008-01-12 22:29     ` Aditya Mahajan
2008-01-12 23:52       ` Carsten Fechtmann
2008-01-13  2:40         ` Aditya Mahajan

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=alpine.DEB.0.9999.0801121220420.21905@nqv-yncgbc \
    --to=adityam@umich.edu \
    --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).