Using LUA commands to create an index/glossary

 

Consider a data source with the following data. This example creates a glossary of all the words in the ‘Glossary’ field, showing the pages they appear on. The words are sorted alphabetically and the pages are numerical within each word.

glossary

The resulting output looks something like:

big – p 13,14,
bill – p 13,
black – p 14,
bone – p 13,
comb – p 16,
feathers – p 13,16,
feline – p 14,16,17,18,
horns – p 14,
mane – p 16,
neck – p 14,
spots – p 14,
stripes – p 17,
tail – p 14,18,
trunk – p 13,
whiskers – p 18,
wool – p 16,

Here’s the code required to produce the output: