I’ve created a Pandoc filter that basically does what @AmberV’s compile replacements do for ODT, but with the added flexibility of supporting Typst + ODT + DOCX + LaTeX. It depends on the same two styles AmberV specifies: Index Key
and Index Term
— these should get compiled to \index{ancestor!parent!keyword}
and \indext{ancestor!parent!keyword}
(you need to wire these up in your compile format); the ancestor and parent are optional. The difference between \index
and \indext
are based on whether you want the term to be retained in the text. So if you write This [term] here.
with [term] being an Index Term
style, the output in e.g. Typst would be: This term #index[Term] here.
with output like This term here.
i.e. it adds the term to the text and uses a title case of the same word for the index. Using Index Key
you’d get This #index[Term] here.
and the output text would be This here.
For outputs other than ODT / Typst / LaTeX the filter will retain \indext
terms and remove \index
terms from the text, so this should play nicely with any of the zillion outputs Pandoc supports from Scrivener… LaTeX itself offers more complex options, but as these are not clearly supported by other output engines I didn’t implement them… The filter could also support DOCX [EDIT: now it does], but the XML is so fussy and annoying to work with (as @amberV mentioned), also Libreoffice has a nicer UI for editing index entries IMO…
EDIT: V1.06 of the filter also supports DOCX output