I have a glossary defined with the glossaries package, and I use the hyperref package to control aspects of the generated PDF file. When I set the document's language with polygossia's \setmainlanguage
command, I get the following warning near the end of compilation (whether with lualatex or xelatex):
(./test.toc) (./test.gls
Package hyperref Warning: Token not allowed in a PDF string (PDFDocEncoding):
(hyperref) removing `\textenglish' on input line 1.
)
It evidently doesn't like the \textenglish
command that appears in the table of contents:
\contentsline {section}{\textenglish {Glossary}}{1}{section*.2}
If I don't set the language, then the warning doesn't appear.
\documentclass{article}
\usepackage{polyglossia}
% Removing the following line makes the warning go away,
% but it introduces a biblatex error instead
\setmainlanguage{english}
\usepackage[backend=biber]{biblatex}
\usepackage{hyperref}
\usepackage[toc]{glossaries}
\makeglossaries
\newglossaryentry{foo}{
name=foo,
description={is foo}
}
\begin{document}
\tableofcontents
\section{foobar}
\gls{foo}
\printglossary
\end{document}
I've read related questions that all recommend using \texorpdfstring
to separate the text that goes into the PDF table of contents, but I'm not sure where I'm supposed to do that in this case since I'm not the one generating the table-of-contents code in the first place.
I'm not sure what effect \textenglish
really has on my document, especially considering all the text is already in English anyway. I can see that it comes from glossaries-english.ldf when polyglossia has been loaded, but I'm unsure what other effects the loading order has. Besides, if I remove the \setmainlanguage
command, then compilation fails at \begin{document}
, apparently because biblatex lacks some language information:
! Undefined control sequence.
<argument> blx@lng@\bbl@main@language
l.16 \begin{document}
How do I quell the hyperref warning?
Best Answer
You can either remove the
\textenglish
locally when you call\printglossary
via the following redefinition in your preamble:But this may affect other uses of
\textenglish
inside the glossary, if any. Another alternative might be to update\glossaryname
. However, the easiest way to get around this (in my opinion) is to specify your own title for the glossary using thetitle
key:This would override any language-specific alterations and set it as-is.