1

I'm trying to add glossary items with umlauts in the description and got this error:

./mwe-glossary.gls:3: Package inputenc Error: Invalid UTF-8 byte sequence.

The problem seems to be, that the generated gl*-files are not in UTF-8:

$ file mwe-glossary.tex mwe-glossary.gl*
mwe-glossary.tex: LaTeX 2e document, UTF-8 Unicode text
mwe-glossary.glo: LaTeX raw glossary, ISO-8859 text
mwe-glossary.gls: LaTeX document, ISO-8859 text

Anyone could help me to fix this, please?


latexmkrc

add_cus_dep('acn', 'acr', 0, 'run_makeindex');
add_cus_dep('glo', 'gls', 0, 'run_makeindex');

sub run_makeindex {
  if ( $silent ) {
    system("makeindex -q -s '$_[0].gst' -o '$_[0].gls' '$_[0].glo'");
  }
  else {
    system("makeindex -s '$_[0].gst' -o '$_[0].gls' '$_[0].glo'");
  };
}

push @generated_exts, 'acn', 'acr', 'alg';
push @generated_exts, 'glo', 'gls', 'glg';
$clean_ext .= ' %R.ist %R.xdy';

mwe-glossary.tex

\documentclass{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\makeglossary

\begin{document}

\printglossary
\glossary{Umlaute}{ÄäÖöÜü}

\dots

\end{document}

(copied) mwe-glossary.gst

%%% basic.gst basic makindex glossary style file
%%% Output style parameters
preamble "\\begin{theglossary}"
postamble "\n\\end{theglossary}\n"

item_0 "\n\\glossitem"
delim_0 "{\\memglonum{"
encap_suffix "}}}"
%%% Input style parameters
keyword "\\glossaryentry"

And the command I run:

$ latexmk -pdf -file-line-error -interaction=nonstopmode
4
  • 1
    I would probably suggest using the glossary package instead
    – daleif
    Feb 19, 2020 at 14:10
  • 1
    Though, this is a memoir issue, it does not write the glossary correctly in the transport from the aux to the glo file. I'll see if I can find a patch
    – daleif
    Feb 19, 2020 at 14:17
  • 2
    @daleif Thanks. (OT: While you're at it, could you grep through the documentation for "withput"? ;-) Was willing to hunt for more typos, but haven't found the time.)
    – Da Mn
    Feb 19, 2020 at 14:32
  • Only found two, fixed, thanks.
    – daleif
    Feb 19, 2020 at 14:35

2 Answers 2

3

Edit 2020/02/24: Here seems to be an even easier patch

\makeatletter
\renewcommand{\@ctualm@mwritetoglo}[5]{%
  % \immediate\write \memglofile
  \immediate@protected@write\memglofile{}% the only line changed
  {\string\glossaryentry{#1\@nameuse{memglsact\m@mgf}
      {\string\memgloterm{#2}}{\string\memglodesc{#3}}
      {\string\memgloref{#4}}\@nameuse{memglsnf\m@mgf}}{#5}}%
  \endgroup}
\makeatother
  • I though I had tested that, apparently not thoroughly enough.

This patch seems to work

\makeatletter
\renewcommand{\@ctualm@mwritetoglo}[5]{%
  \immediate\write\memglofile{\string\glossaryentry{\detokenize{#1}\@nameuse{memglsact\m@mgf}
      {\string\memgloterm{\detokenize{#2}}}{\string\memglodesc{\detokenize{#3}}}
      {\string\memgloref{\detokenize{#4}}}\@nameuse{memglsnf\m@mgf}}{\detokenize{#5}}}%
  \endgroup}
\makeatother

I'll add it to the next memoir release. Though no idea when that will be

1
  • Confirmed to work. Thanks a lot!
    – Da Mn
    Feb 19, 2020 at 14:42
2

I've found a workaround to this problem by using iconv. Though, it doesn't look right.


latexmkrc

add_cus_dep('acn', 'acr', 0, 'run_makeindex');
add_cus_dep('glo', 'gls', 0, 'run_makeindex');

sub run_makeindex {
  if ( $silent ) {
    system("makeindex -q -s '$_[0].gst' -o '$_[0].gls' '$_[0].glo'");
  }
  else {
    system("makeindex -s '$_[0].gst' -o '$_[0].gls' '$_[0].glo'");
  };
  # XXX: using iconv doesn't look right to me
  system("iconv -f iso-8859-1 -t utf-8 -o '$_[0].gls' '$_[0].gls'");
}

push @generated_exts, 'acn', 'acr', 'alg';
push @generated_exts, 'glo', 'gls', 'glg';
$clean_ext .= ' %R.ist %R.xdy';

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .