3

EDIT: Added MWE

I can't seem to find fix for my problem, so I'll try to ask here. Any help will be appreciated.

I am working on my UNI thesis template and everything seems to be working great except for the glossary.

When I call \gls{cr} and in glossary I have C instead of Č everything works good, but when I use any character (like ěščřžýáíéů...) from czech language I get errors.

I am working in overleaf (because of simplicity for others) and using TeXLive2024 and LuaLaTeX (because of luavlna package which is crucial for czech thesis). Using \usepackage[utf8]{inputenc} is not doing anything because LuaLaTeX is not using it by default since it already should work with utf8.

MWE

\documentclass{article}
\usepackage{hyperref}
\usepackage{ragged2e}
\usepackage[automake]{glossaries-extra}
\makeglossaries
\begin{document}
\newglossaryentry{cr1}{
    name={CR},
    long={Ceska republika},
    description={},
    first={(ČR)}
}
\newglossaryentry{cr2}{
    name={ČR},
    long={Česká republika},
    description={},
    first={(ČR)}
}
\newglossarystyle{CustomList}{
    \setglossarystyle{long}
    \renewenvironment{theglossary}
    {\begin{longtable}{@{}p{.15\linewidth}p{.65\linewidth}p{.2\linewidth}@{}}}
        {\end{longtable}}
    \renewcommand*{\glossaryheader}{
        \textbf{Acronym} & \textbf{Full name} & \textbf{Page} \\ \endhead}
    \renewcommand*{\glsgroupheading}[1]{}
    \renewcommand*{\glsgroupskip}{}
    \renewcommand*{\glossentry}[2]{
        \glstarget{##1}{\glossentryname{##1}} &
        \RaggedRight\glsentrylong{##1}\newline\glossentrydesc{##1} &
        ##2 \\ \\
    }
}
\section{First page}
\gls{cr1} % working
and
% \gls{cr2} % errors because of czech symbol
\newpage
\printglossary[style=CustomList]
\end{document}

Error log when using \gls{cr2}:

String contains an invalid utf-8 sequence.

 
‪./output.gls, 6‬
l.6 \glsgroupheading{
                   �}}\relax \glsresetentrylist %
A funny symbol that I can't read has just been (re)read.
Just continue, I'll change it to 0xFFFD.

)
Runaway argument?
{�relax \glsresetentrylist \glossentry {cr2}{\glossaryentrynumbers \ETC.
File ended while scanning use of \glsgroupheading.

 
‪./output.gls, 39‬
<inserted text> 
\par 
l.39 \printglossary[style=CustomList]
                                   
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.
Extra }, or forgotten \endgroup.

 
‪./output.gls, 39‬
\@glsxtr@orgprintglossary ...lo@type }{#2}\egroup 
                                                  \global \let \glossaryentr...
l.39 \printglossary[style=CustomList]
                                   
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
LaTeX Error: \begin{longtable} on input line 2 ended by \end{document}.

 
‪./output.gls, 40‬
See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.40 \end{document}
                 
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.
Misplaced \noalign.

 
‪./output.gls, 40‬
You have used a \hline command in the wrong place, probably outside a table. If the \hline command is written inside a table, try including \\ before it.
Learn more
\newpage ->\noalign 
                    {\break }
l.40 \end{document}
                 
I expect to see \noalign only after the \cr of
an alignment. Proceed, and I'll ignore this case.
You can't use `\end' in internal vertical mode.

 
‪./output.gls, 40‬
\enddocument ...cument/end}\deadcycles \z@ \@@end 
                                                  
l.40 \end{document}
                 
Sorry, but I'm not programmed to handle this case;
I'll just pretend that you didn't ask for it.
If you're in the wrong mode, you might be able to
return to the right one by typing `I}' or `I$' or `I\par'.
Emergency stop.

 
‪./MWE.tex‬
<*> MWE.tex
        
*** (job aborted, no legal \end found)



Here is how much of LuaTeX's memory you used:
 15362 strings out of 476435
 125027,1977958 words of node,token memory allocated 2488 words of node memory still in use:
   33 hlist, 10 vlist, 21 rule, 3 disc, 9 local_par, 3 dir, 61 glue, 12 kern, 21 penalty, 6 unset, 48 glyph, 3 align_record, 71 attribute, 82 glue_spec, 71 attribute_list, 7 temp, 1 align_stack, 3 write, 1 pdf_start_link, 1 pdf_end_link, 4 pdf_dest, 1 pdf_action nodes
   avail lists: 1:1,2:5,3:128,4:3,5:12,7:61
 37196 multiletter control sequences out of 65536+600000
 18 fonts using 1118495 bytes
 106i,6n,101p,2366b,423s stack positions out of 10000i,1000n,20000p,200000b,200000s
!  ==> Fatal error occurred, no output PDF file produced!

Output.gls from Overelaf

    \glossarysection[\glossarytoctitle]{\glossarytitle}\glossarypreamble
\begin{theglossary}\glossaryheader
\glsgroupheading{C}\relax \glsresetentrylist %
\glossentry{cr1}{\glossaryentrynumbers{\relax 
        \setentrycounter[]{page}\glsnumberformat{1}}}\glsgroupskip
\glsgroupheading{Ä}\relax \glsresetentrylist %
\glossentry{cr2}{\glossaryentrynumbers{\relax 
        \setentrycounter[]{page}\glsnumberformat{1}}}%
\end{theglossary}\glossarypostamble

EDIT: making \gls{\v{C}R} for Č symbol is working at first glance, but in the list of acronyms it is not listed alphabetically and is not that much practical for basic users.

In pdfTeX it works good, but "luavlna" package cant work, in XeTeX it doesnt show the czech symbol at all and skips it.

Does anyone have any other idea except for the one already provided?

Can't seem to figure out why it doesnt work.

3
  • 1
    Welcome to TeX.SX! Please don't post code fragments. Instead, put your fragments into a complete compilable document that shows the problem. Commented Aug 31, 2024 at 8:44
  • sorry I said I had no error, but I used pdftex, with luatex I get the error you state. looking.... Commented Aug 31, 2024 at 14:27
  • 1
    glossaries can use the more capable xindy backend if you ask it, going by this answer loading glossaries-extra as \usepackage[xindy={language=czech, codepage=utf8},automake]{glossaries-extra} should work for you. Commented Sep 5, 2024 at 15:43

1 Answer 1

3

It's handling of the first letter is broken (it's surprising it breaks for unicode tex where it's a normal character and not for pdftex, but still....)

I haven't traced what it's doing but I think using classic TeX accent markup just in the name= field does the right thing with lualatex.

\documentclass{article}
\usepackage{hyperref}
\usepackage{ragged2e}
\usepackage[automake]{glossaries-extra}
\makeglossaries
\begin{document}
\newglossaryentry{cr1}{
    name={CR},
    long={Ceska republika},
    description={},
    first={(ČR)}
}
\newglossaryentry{cr2}{
    name={\v{C}R},
    long={Česká republika},
    description={},
    first={(ČR)}
}
\newglossarystyle{CustomList}{
    \setglossarystyle{long}
    \renewenvironment{theglossary}
    {\begin{longtable}{@{}p{.15\linewidth}p{.65\linewidth}p{.2\linewidth}@{}}}
        {\end{longtable}}
    \renewcommand*{\glossaryheader}{
        \textbf{Acronym} & \textbf{Full name} & \textbf{Page} \\ \endhead}
    \renewcommand*{\glsgroupheading}[1]{}
    \renewcommand*{\glsgroupskip}{}
    \renewcommand*{\glossentry}[2]{
        \glstarget{##1}{\glossentryname{##1}} &
        \RaggedRight\glsentrylong{##1}\newline\glossentrydesc{##1} &
        ##2 \\ \\
    }
}
\section{First page}
\gls{cr1} % working
and
\gls{cr2} % errors because of czech symbol
\newpage
\printglossary[style=CustomList]
\end{document}

enter image description here

2
  • 2
    The tool change uses MakeIndex, and it's treating UTF-8 as bytes ... Commented Aug 31, 2024 at 16:49
  • @JosephWright sigh of course yes. Commented Aug 31, 2024 at 16:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.