4

Background

For collapsing or expanding page numbers in indexes / registers, you can use \defineregister[name][compress=yes|no], e.g.

\defineregister
  [photographer]
  [compress=yes]

\starttext
  \dorecurse{4}{%%
    Foo
   \photographer{Yousuf Karsh} \page}

 \completephotographer   
\stoptext

which will result in an index that subsumes the page references to "1-4".

(Example taken from http://wiki.contextgarden.net/Command/defineregister.)


Problem

The compress parameter works fine, but it also collapses when we have exactly two sequential page numbers, e.g. "1-2"

Unfortunately, this is very uncommon in German. Instead of "1-2" you would write "1f." when an entry refers to exactly two sequential pages.


Question

Is it possible to subsume page references that encompass exactly two sequential pages to e.g. "1f." while collapsing references that refer to more than two pages to e.g. "1-3"? If so, how would you do it?

2

You can hack into the display of the pagerange in ConTeXt.

\defineregister
  [photographer]
  [compress=yes]

\unprotect

\unexpanded\def\registerpagerange#1#2#3#4#5#6#7%
  {\registerpageseparator
   \global\setconstant\c_strc_registers_page_state\plusone
   \dostarttagged\t!registerpagerange\empty
   \dostarttagged\t!registerfrompage\empty
   \withregisterpagecommand{#1}{#2}{#3}{#4}%
   \dostoptagged
   \ifnum\the\numexpr#6-#3\relax=1
     f.%
   \else
     \registeronepagerangeseparator
     \dostarttagged\t!registertopage\empty
     \withregisterpagecommand{#1}{#5}{#6}{#7}%
     \dostoptagged
   \fi
   \dostoptagged}

\protect

\starttext
\dorecurse{1}{Foo\photographer{Foo Bar} \page}
\dorecurse{2}{Foo\photographer{John Doe} \page}
\dorecurse{4}{Foo\photographer{Yousuf Karsh} \page}

\completephotographer   
\stoptext

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.