How do I get correct values from the %refpage variable and partial (Range+) composition?

XPP 9.3.1, using XML mode (without CSS) and the Looseleaf add-on

We have a situation where we need to display the number of pages between the current page and some specific forward destination. The way that we currently implement this is by putting a <rx;end-1> macro at the destination. Then, at the place where we want to print the number of pages, we have:

<rf;end-1;0;0></ns;52;%refpage-%pagenum+1></ri;#52;an>

All of this happens in main blocks.

This works perfectly as long as we compose the entire division. However, if we do a Range+ compose, though, we sometimes get an incorrect count. We need the Range+ compose to return the correct result because we will be using Looseleaf, which may do partial composes.

As part of the debugging process, I outputted the values of the %refpage and %pagenum variables using </ri;%refpage;an> and </ri;%pagenum;an>. What I've generally observed is that the %pagenum variable is accurate, but the %refpage variable seems to return the wrong value when the destination marked spot "end-1" is part of the range compose. When that happens, %refpage returns the page position relative to the range being composed, instead of relative to the entire division. For example, in the case where "end-1" is on page 13 and we're printing the count on page 12, I expect %refpage to return "13". However, the result depends on which pages I compose:

  • Range+ compose 12 => %refpage = 13
  • Range+ compose 12 thru 13 => %refpage = 2
  • Range+ compose 11 thru 13 => %refpage = 3

The odd thing to me is that if I then look at the output of show_xref, the entry for end-1 always shows the correct page number 13.

(I kind of glossed over this, but in all cases, we've already done one full compose pass, so I'm sure that the forward cross-reference is resolving to some value)

Assuming this is a bug, or just some edge case that I'm not understanding, is there a more reliable way to get the count that I'm looking for? The multipart page numbers (%refpg1, etc.) seem to return the correct result, but I can't use that because it won't tell me about potential insert pages.

Parents Reply Children
No Data