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
participants (1)
-
Jason Grout