2

This example in English

\documentclass{article}
\usepackage{glossaries}
\newglossaryentry{tea}
{
  name=tea,
  description={a drink}
}
\makeglossaries
\begin{document}
Drink \gls{tea}.
\printglossaries
\end{document}

works fine.

A problem appears when I use diacritic marks for glossary entries:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{glossaries}
\newglossaryentry{tēju}
{
  name=tēja,
  description={a drink}
}
\makeglossaries
\begin{document}
Dzert \gls{tēju}.
\printglossaries
\end{document}

The error is:

! Missing \endcsname inserted.
<to be read again> 
                   \unhbox 

How to make the glossary friendly to other languages?

  • 2
    As stated in the manual: "Note that although an extended Latin character or other non-Latin character, such as é or ß, looks like a plain character in your .tex file, it’s actually a macro (an active character) and therefore can’t be used in the label. (This applies to LaTeX rather than XeLaTeX.)" So if you want to use non-ASCII characters in the label you need to use XeLaTeX or LuaLaTeX. – Nicola Talbot Nov 23 '18 at 16:35
  • @NicolaTalbot, using xelatex solved the problem. – Viesturs Nov 23 '18 at 21:09
  • @NicolaTalbot, will you provide and answer in case someone else has this problem? – Viesturs Nov 23 '18 at 21:27
2

From section 4. "Defining Glossary Entries" of the user manual:

Note that although an extended Latin character or other non-Latin character, such as é or ß, looks like a plain character in your .tex file, it’s actually a macro (an active character) and therefore can’t be used in the label. (This applies to LaTeX rather than XeLaTeX.) Also be careful of babel’s options that change certain punctuation characters (such as : or -) to active characters.

With PDFLaTeX, a UTF-8 character, such as é, is actually seen as two octets. The first octet is made active (by inputenc) and becomes an accent command and the second octet is the argument for that command. So, if you are restricted to using PDFLaTeX then you can't use non-ASCII characters in the labels and you'd need to determine a suitable ASCII-only naming scheme. See, for example, section 1.1 "Labels" of glossaries-extra and bib2gls: an introductory guide (PDF).

If you want to use non-ASCII characters in the labels then you need to use either XeLaTeX or LuaLaTeX, which both natively support UTF-8 without the need for the active octet trick.

The reason for this limitation is that the labels are used to construct internal control sequences that are used to store all the information associated with the glossary entry. This means that the labels must be able to fully expand in order to create a command name.

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.