Follow up question to this one.

\newfontfamily\sanskritfont{Latin Modern Roman}[Ligatures=TeX]





%  \ifglshaslong{#2}%
%  {\glsletentryfield{#1}{#2}{long}}%
%  {\glsletentryfield{#1}{#2}{sort}}%




This example compiles fine. If I comment in the redefined \glsxtrautoindexassignsort it stops working,

Writing index file test.idx 
! Undefined control sequence.
\in@ #1#2->\begingroup \def \in@@ 
                                  ##1#1{}\toks@ \expandafter {\in@@ #2{}{}#1...
l.34 \gls{yh}


unless I remove my language switching command, by changing to the commented out version.

The redefinition of \glsxtrautoindexassignsort has been copied from sample-autoindex.tex, it should have the effect of the entry being sorted according to its long form (Yoginīhṛdaya), not the short one (YH), which is something one would want. I compile this with latexmk calling xelatex and xindy (texindy).

EDIT: changing the definition of \skti to use \newrobustcmd it compiles, but the "Yoginīhṛdaya" entry gets sorted under S, presumably because of the presence of \skti. \indexentry{\\skti {Yoginīhṛdaya}@\glsentryfirst{yh}}{1} is the line in the idx file. Curiously in my real file it appears under Y, but before other entries, suggesting that it has been sorted under YH. The idx file line there is \indexentry{\skti {Yoginīhṛdaya}@\glsentryfirst{yh}}{1}, for some reason the testing file has two backslashes, \\skti.

  • 1
    Try defining \skti as a robust command. (That is, replace \newcommand with \newrobustcmd.) – Nicola Talbot Jun 14 '18 at 14:26
  • @NicolaTalbot Please see my edit above. – muk.li Jun 14 '18 at 19:04

The glossaries package's xindy option uses xindy's native format (rather than the makeindex emulation provided with texindy). This means that it has to escape xindy's special characters rather than makeindex's. For example, if you have:


with the xindy option, the sort value (obtained from the name) has to have the backslash escaped so that it's written to the xindy file as:

(indexentry :tkey (("\\skti {Yoginīhṛdaya}" "\\glossentry{sample}") ) :locref "{}{1}" :attr "pageglsnumberformat" )

The autoindexing function uses makeindex syntax in \index and also tries to escape any special characters. It should just escape the special characters identified by commands like \GlsXtrSetEscChar but it seems it's also still trying to escape the backslash because the base glossaries code is in native xindy mode. That's why you get the double backslash \\skti in the indexing file.

One way around this is to provide a definition of \glsxtrautoindexassignsort that strips \skti out when obtaining the sort value from the long field:


This temporarily defines \skti to \@firstofone, which means that the command will be removed during the \protected@edef.

Another possibility is to move the formatting command out of the long field and into the abbreviation style:




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.