3

I need to have index that will be sorted by book of the Bible in the order that the books appear in the Bible (Genesis, Exodus, etc.).

Is there any way to define a custom sorting of a register in conTeXt?


Update to an example and more explanation

So here is a minimal example and further explanation:

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

\starttext

This is a test.\regname{Psalm+81}
This is another sentene.\regname{Psalm+81+4}
One more.\regname{Matthew+4+5}
Yet again.\regname{Matthew+4+5-10}
Last one.\regname{Matthew+4+1-7}

\page

Another page.\regname{Romans+3}
Another sentence \regname{Genesis+12+5}
Last one.\regname{Exodus+3+12}
Nope. One more.\regname{Jude+1}

\page

\placeregname

\stoptext

I would like to define a custom sorting that would allow them in the non-alphabetical order. In this example, the ordering would be:

Genesis, Exodus, Psalm, Matthew, Romans, and Jude


Update to clarify question

So it seems that the register is processed on an early run engine and saved in some sort of data structure in the .tucfile. Would the best way then be to write some sort of script that uses that data to sort and then output my index? If so, are there any known examples of such, e.g. accessing the register data and manipulating it for a specific output?

Otherwise, it appears that I will have to "monkey" with the languages, and this really isn't a separate language as much as a different type of data structure with it's own sorting.

  • 1
    “method: sets up the sorter used for \placeregister” wiki.contextgarden.net/Command/setupregister Please clarify your question and add a minimal example. – Henri Menke Mar 5 '18 at 20:45
  • @HenriMenke I added some details. If I can just get a hint or two in the right direction, I might be ok. It seems sort-lan.luamay be important for me. – John Grasty Mar 6 '18 at 15:27
  • @HenriMenke Do you think that this previous question may be on the right trail for this problem? Particularly Philipp Gesang's answer. – John Grasty Mar 7 '18 at 13:20
2

I don't think you can replace the alphabetical sorter easily. You can do it manually by simply using the sorting argument of the register and enumerating the books alphabetically ascending.

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

\starttext

This is a test.\regname[c]{Psalm+81}
This is another sentene.\regname[c]{Psalm+81+4}
One more.\regname[d]{Matthew+4+5}
Yet again.\regname[d]{Matthew+4+5-10}
Last one.\regname[d]{Matthew+4+1-7}

\page

Another page.\regname[e]{Romans+3}
Another sentence \regname[a]{Genesis+12+5}
Last one.\regname[b]{Exodus+3+12}
Nope. One more.\regname[f]{Jude+1}

\page

\placeregname

\stoptext

To make your life at least a little easier you could wrap all of that in some macro code.

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

\unexpanded\def\definebook#1%
  {\advance\scratchcounter by 1
   \expandafter\edef\csname book:#1\endcsname{\convertnumber{a}{\scratchcounter}}}

\unexpanded\def\definebooks[#1]
  {\scratchcounter=0
   \processcommalist[#1]\definebook}

\unexpanded\def\book#1#2%
  {\regname[\csname book:#1\endcsname]{#1#2}}

\definebooks[Genesis,Exodus,Psalm,Matthew,Romans,Jude]

\starttext

This is a test.\book{Psalm}{+81}
This is another sentene.\book{Psalm}{+81+4}
One more.\book{Matthew}{+4+5}
Yet again.\book{Matthew}{+4+5-10}
Last one.\book{Matthew}{+4+1-7}

\page

Another page.\book{Romans}{+3}
Another sentence \book{Genesis}{+12+5}
Last one.\book{Exodus}{+3+12}
Nope. One more.\book{Jude}{+1}

\page

\placeregname

\stoptext
  • Thanks. This certainly works well and with minimal effort. I'm going to go ahead it mark your answer as solving it. I plan on investigating a script to access the register data structure, just because this is a big multi-year project and certain things like replacements for abbreviations would be handy, but even if I post another answer, I'll leave the green check mark with you! – John Grasty Mar 9 '18 at 6:08
  • @JohnGrasty If this is such a big project better ask Hans on the mailing list whether he can expose the sorter on the Lua end for you to replace it rather than trying to hack your way through the .tuc file. Also, if the format of .tuc changes in a future version, you're screwed. – Henri Menke Mar 9 '18 at 7:03
  • That's a great point. I will do that. Though your solution is perfect for my prototyping needs and in the future for small projects with similar needs from the registers. – John Grasty Mar 9 '18 at 8:32

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.