1

I have seen Latex sort macros (for an index, which is precisely what I want, the index having several thousand entries); but I haven't seen one in plain (or AmS-TeX, for that matter; either is OK). Can someone point me to one?

  • Welcome to TeX.SX! The usual way of sorting an index with LaTeX (I'm sure it is adaptable to plain) is to call an external program (makeindex or xindy) for that matter. Why would you want to do it on macro level? – TeXnician Apr 14 '19 at 19:11
  • I am used to tables of contents (for which I managed to write macros for plain, writing to toc files); these update themselves (after an additional compile), and I hope to do the same with the indexes. I have never used makeindex or xindy; do these run in plain, and update themselves as changes are made to the tex files? – David Handelman Apr 14 '19 at 19:15
  • The manpage of makeindex suggests it can do so. Naturally you would have to write the typical interfacing macros but at least sorting would be more efficient. And updating itself is not quite understandable, as an external tool it has to be called. You could automate this by using a build tool like arara, but that's independent from the choice of external tools. – TeXnician Apr 14 '19 at 19:17
  • I should add that I have done indexing before, but only by writing all the index entries to a file, sorting the resulting text file in something like TeX-edit (despite its name, unrelated to TeX), and then by hand, consolidating multiple entries. Naturally, any change in the document will affect this, so I wait until the very end to do this (once). – David Handelman Apr 14 '19 at 20:11
  • See https://tex.stackexchange.com/questions/273037/expandable-quick-sort-array-macro/273476?r=SearchResults&s=1|30.5805#273476 There may be some LaTeX command, but it is mostly base TeX. – John Kormylo Apr 14 '19 at 23:58
  • Here is an older article http://www.tug.org/TUGboat/tb14-3/tb40laan-sort.pdf by Kees van der Laan; it uses only plain \TeX macros. – Udo Wermuth Apr 16 '19 at 10:43
  • @UdoWermuth Thank you! At least one them is very close to what I want, if rather complex (which is probably necessary). I will try it out. – David Handelman Apr 16 '19 at 12:43
  • Eplain can work with makeindex. Is eplain an option you can use? To use eplain, have \input eplain at the beginning of a plain tex document. – corporal Apr 17 '19 at 07:39

0 Answers0