From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/30664 Path: news.gmane.org!not-for-mail From: Jason Grout Newsgroups: gmane.comp.tex.context Subject: index page range bug Date: Tue, 05 Sep 2006 18:12:28 -0600 Message-ID: <44FE126C.6010609@math.byu.edu> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1157524198 15942 80.91.229.2 (6 Sep 2006 06:29:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Sep 2006 06:29:58 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Wed Sep 06 08:29:55 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1GKqv1-00081a-Mm for gctc-ntg-context-518@m.gmane.org; Wed, 06 Sep 2006 08:29:51 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 466C71FDD9; Wed, 6 Sep 2006 08:29:50 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 07866-02; Wed, 6 Sep 2006 08:29:47 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 744E81FDDD; Wed, 6 Sep 2006 08:03:33 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id ED2DE1FD9B for ; Wed, 6 Sep 2006 02:12:37 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 14723-02 for ; Wed, 6 Sep 2006 02:12:30 +0200 (CEST) Original-Received: from mail01.math.byu.edu (mail01.math.byu.edu [128.187.40.23]) by ronja.ntg.nl (Postfix) with SMTP id 788681FD08 for ; Wed, 6 Sep 2006 02:12:29 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by mail01.math.byu.edu (Postfix) with ESMTP id D313211A5614 for ; Tue, 5 Sep 2006 18:12:27 -0600 (MDT) Original-Received: from mail01.math.byu.edu ([127.0.0.1]) by localhost (mail01.math.byu.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00343-10 for ; Tue, 5 Sep 2006 18:12:24 -0600 (MDT) Original-Received: from [10.4.35.19] (unknown [10.4.35.19]) by mail01.math.byu.edu (Postfix) with ESMTP id 2189D11A55F6 for ; Tue, 5 Sep 2006 18:12:24 -0600 (MDT) User-Agent: Thunderbird 1.5.0.5 (Macintosh/20060719) Original-To: ntg-context@ntg.nl X-Virus-Scanned: by amavisd-new at math.byu.edu X-Virus-Scanned: amavisd-new at ntg.nl X-Mailman-Approved-At: Wed, 06 Sep 2006 08:03:29 +0200 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:30664 Archived-At: Hans (or whoever could change this), When using startregister/stopregister commands, if the range is only one one page, then while both a [f] and a [t] are written to the tui file, only one \registerfrom command is put in the tuo file. If there is only one range, it seems like the software deals with it nicely. However, if there are two ranges (like in the example below), then the index incorrectly assumes that the first \registerfrom command in the tuo file corresponds to the \registerto command. Here's an example test.tex: \setuppapersize [letter][letter] \starttext \input knuth KNUTH START\startregister[index][knuthrange1]{Knuth} \input knuth KNUTH END\stopregister[index][knuthrange1] \dorecurse{10}{\input zapf } KNUTH START\startregister[index][knuthrange2]{Knuth} \dorecurse{10}{\input knuth } KNUTH END\stopregister[index][knuthrange2] \completeindex \stoptext test.tui: r f {index} {1} {} {Knuth} {2--0-0-0-0-0-0-0--1} {1} r t {index} {2} {} {Knuth} {2--0-0-0-0-0-0-0--1} {1} r f {index} {3} {} {Knuth} {2--0-0-0-0-0-0-0--3} {3} r t {index} {4} {} {Knuth} {2--0-0-0-0-0-0-0--5} {5} test.tuo: \registerentrya{index}{Knuth} \registerfrom{index}{,}{1}{2--0-0-0-0-0-0-0--1}{1} \registerfrom{index}{,}{3}{2--0-0-0-0-0-0-0--3}{3} \registerto{index}{,}{4}{2--0-0-0-0-0-0-0--5}{5} and the index reads "Knuth 1--5", but it should read "Knuth 1, 3--5" My guess is the problem lies in the line in texutil.rb: if copied || ! ((lastpage == entry.page) && \ (lastrealpage == entry.realpage)) then (sorry, that was one line before my mail program wrapped it). Since the ending [t] reference for the first \stopregister command is on the same page as the first one, the whole section outputting a \registerto command to the tuo file is skipped. Instead, how about making the code check to see if we have a range that ends on the same page as it started? If it does, then just insert a \registerpage command instead of a \registerfrom command. I've corrected this in the perl version (I had an old version of ConTEXt before today, otherwise I would have worked on the ruby version). I also added support for nesting ranges, which I then discovered weren't supported anyway. (I also had to change the sort order on @RegisterEntries so that [f] and [t] entries would be consecutive, instead of all the [f] entries preceding the [t] entries, but it looks like that was fixed already). Here's my code from the perl texutil (with a bunch of comments from me): { # print "$LastPage / $Page // $LastRealPage / $RealPage\n" ; $NextEntry = "{$Class}{$PreviousA}{$PreviousB}{$PreviousC}{$PageHow,$TextHow}" ; $SavedLine = "{$Class}{$PageHow,$TextHow}{$Location}{$Page}{$RealPage}\n" ; # If we are starting a new level, start our nesting over. # This will completely ignore the last non-properly # nested result in the previous heading. if($Copied) { $NestingLevel=0; $TopLevelFromPage=""; $TopLevelFromRealPage=""; $TopLevelFromLine=""; } if ($RegisterState eq $RegStat{"f"}) # If we are starting a range { FlushSavedLine ; if($NestingLevel eq 0) { $TopLevelFromLine=$SavedLine; $TopLevelFromPage=$Page; $TopLevelFromRealPage=$RealPage; } $NestingLevel++; } elsif ($RegisterState eq $RegStat{"t"}) # If we are ending a range { FlushSavedLine ; $NestingLevel--; if($NestingLevel <= 0) { if((($Page eq $TopLevelFromPage) and ($RealPage eq $TopLevelFromRealPage)) or $NestingLevel < 0) { print TUO "\\registerpage$SavedLine" ; } else { print TUO "\\registerfrom$TopLevelFromLine" ; print TUO "\\registerto$SavedLine" ; } $NestingLevel = 0 ; $TopLevelFromPage=""; $TopLevelFromRealPage=""; $TopLevelFromLine=""; } } else # If we have a normal single entry { if ($CollapseEntries) { if ($SavedEntry ne $NextEntry) { $SavedFrom = $SavedLine } else { $SavedTo = $SavedLine } $SavedEntry = $NextEntry } else { print TUO "\\registerpage$SavedLine" } } Of course, if I've missed something, please let me know. I've only started using ConTEXt in the last few weeks. I needed grid typesetting for a book I was working on and I was getting tired of LaTeX not helping me there. I've absolutely loved working with ConTEXt! (well, other than sometimes a frustrating lack of documentation, but there have been lots of good posts on the mailing list that have helped me). Thanks, Jason