7

Background

To influence the order in which ConTeXt puts register entries you can use a specific key value in

\index[KEY]{Term}

This is for instance useful if you want to mix upper-case and lower-case entries in your register, e.g.

\defineregister[regname]
\setupregister[regname]
   [compress=yes,
    indicator=no,
    pagestyle=\tf,
    n=1,
    before=\blank]

 \starttext
 \page
 % mixed
 Aa\regname[AA]{Aa}
 ab\regname[AB]{ab}
 Ac\regname[AC]{Ac}
 % not mixed
 Ba\regname[Ba]{Ba}
 bb\regname[bb]{bb}
 Bc\regname[Bc]{Bc}

 \page
 \placeregname
 \stoptext

leads to

Register


Problem

Sometimes there are words that only differ in the first letter (upper-case vs. lower-case). When both appear in the register and are mentioned on different pages, the register entries do not collapse, since the terms themselves start with different letters. E.g.

\defineregister[regname]
\setupregister[regname]
  [compress=yes,
   indicator=no,
   pagestyle=\tf,
   n=1,
   before=\blank]

 \starttext

 hebräisch\regname[HEBRÄISCH]{hebräisch}
 Hebräisch\regname[HEBRÄISCH]{Hebräisch}

 \page

 hebräisch\regname[HEBRÄISCH]{hebräisch}
 Hilfe\regname[HILFE]{Hilfe}

 \page

 \placeregname

 \stoptext   

results in

Register2


Question:

Is it possible to sum up the entries with the same first letter without putting all lower-case entries behind all upper-case ones? I want to achieve something like this:

Register3

  • 1
    You are abusing \index[key]{entry}. Specifying the key is reserved for cases where sorting cannot be deduced from entry, i.e. \index[CONTEXT]{\ConTeXt}. Also the mapping key <-> entry has to be bijective, i.e. a single key has to map to a single entry and a single entry has to map to a single key. Multimaps are not supported and there is no reason to support them either. – Henri Menke Jun 21 '17 at 22:47
6

Don't use the optional argument. The optional argument is meant for cases where the sorting cannot be inferred from the content, i.e. \regname[CONTEXT]{\ConTeXt}. This is clearly not the case for the words you use. Adding this optional argument and having differing entries exempts the word from taking part in the collapse which leads to the behaviour you observe. Instead of trying to trick ConTeXt into thinking that everything is uppercase, just tell it that you want to have uppercase words before lowercase in the index by adjusting the sorting method.

\defineregister[regname]
\setupregister[regname]
  [compress=yes,
   indicator=no,
   pagestyle=\tf,
   n=1,
   before=\blank,
   method={zc,mm,uc}]

\starttext

hebräisch\regname{hebräisch}
Hebräisch\regname{Hebräisch}
helfen\regname{helfen}
Herrscher\regname{Herrscher}
hölzern\regname{hölzern}

\page

hebräisch\regname{hebräisch}
Hilfe\regname{Hilfe}
haben\regname{haben}
Holz\regname{Holz}

\page

\placeregname

\stoptext

enter image description here


If you insist on using the optional argument, you have to use different keys for different entries.

\defineregister[regname]
\setupregister[regname]
  [compress=yes,
   indicator=no,
   pagestyle=\tf,
   n=1,
   before=\blank]

\starttext

hebräisch\regname[Hebräisch]{hebräisch}
Hebräisch\regname[HEBRÄISCH]{Hebräisch}

\page

hebräisch\regname[Hebräisch]{hebräisch}
Hilfe\regname[HILFE]{Hilfe}

\page

\placeregname

\stoptext

enter image description here

  • I tried the first solution you proposed and it works like charm. Thanks a lot! – meliade Jun 22 '17 at 7:33

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.