0

I am trying to incorporate bib2gls into glossaries managment in my project, however I hit into trouble when using my native language (czech) and its diacritics (as far as my knowledge goes, those are non-ASCII, but Unicode acceptable characters).

Showing those explicitly, its "ěščřžýáíéďťň."

As far as my troubleshooting abilities go, I was able to track down the source of the problem in .glstex file, which unable to accept the .bib file with non-ASCII characters.

I hit upon package newunicode, answer might be there, but I dont know how to use it for my specific case.

I am lloking for solution working in XeLaTeX and LuaLaTeX ideally, or at least one of those. I tryed combination of encodings-package as far as my knowledge goes, but none led to correct display of all the characters (glyphs).

MWE:

% !TEX encoding = UTF-8 Unicode

%% Pokyny pro arara:

% arara: xelatex
% arara: bib2gls if found("aux", "glsxtr@resource")
% arara:  xelatex
% arara: bib2gls if found("aux", "glsxtr@resource")
% arara:  xelatex
% arara:  xelatex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass [a4paper, 12pt, twoside,openright] {book}                %nastavení knihy

\usepackage [czech] {babel} 
%\usepackage[utf8]{inputenc}        
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{microtype}          
\usepackage [a4paper, twoside, inner=2.5cm, outer=2.5cm, bottom=3cm] {geometry}         

\usepackage{import}     
\usepackage{filecontents}       

\usepackage[record, nopostdot, automake, abbreviations,% 
                    nostyles, stylemods={all}%
                    ]{glossaries-extra}

\GlsXtrLoadResources[selection={all},%
            src={testgls},%
            save-locations=false,%
            ]

%Glossary entries
\begin{filecontents}{testgls.bib}
% !TEX encoding = UTF-8 Unicode
@entry{nonasciichartest,
    name={ačšěřžýáíéťďň},
    description={ačšěřžýáíéťďň}
}
@entry{asciitest,
    name={ASCII test},
    description={abcdefghijklmopqrstuvwxyz}
}
\end{filecontents}{testgls.bib}

\begin{document}

\nonfrenchspacing
%\pagenumbering{roman}                  %nutné pro kompilovatelnost referencí - hned od začátku nastavit číslování stránek

\thispagestyle{empty}

\printunsrtglossary[type={main}, style={altlistgroup}, title=Slovníček pojmů, toctitle=Slovníček pojmů]

\clearpage

Standard text:

ěščřžýáíéťďň

\end{document}

Final note: I also tryed to use magic comments, which also did not led to working solution. Theyre use might be even redundant :)

Thank you very much for any help, tips regarding this complication. Bib2gls is an amazing tool that I would like to learn to use.

Tomas

  • 1
    You are making testing difficult with all this import/subimport stuff. But beside this is looks as if there is something wrong in bib2gls, it doesn't write correct utf8. Make a bug report. – Ulrike Fischer May 7 at 13:58
  • The bib2gls manual (page 31) mentions a slightly different way to specify the encoding of the .bib file, you could try if that changes anything. – Marijn May 7 at 15:35
  • @UlrikeFischer Thank you mr. Fischer for your advice, I have edited my MWE. Next time I wont recreate my document-parts-tree; I though it might be relevant, but most probably it isnt. – Tomáš Kruliš May 8 at 9:00
  • 1
    I'm Mrs. Fischer. And I already tested your example and my advice stays: Make a bug report. – Ulrike Fischer May 8 at 9:03
  • 1
    Then answer your own question - and make a bug report anyway. The package should be able to detect xetex/luatex and handle this correctly on its own. – Ulrike Fischer May 8 at 9:24
0

As Ms. Fischer instructed, I am answering my own question (strange).

Solution for this problem lies in adding option "charset=UTF-8" to \GlsXtrLoadResources, leading to:

% !TEX encoding = UTF-8 Unicode

% arara: xelatex
% arara: bib2gls if found("aux", "glsxtr@resource")
% arara:  xelatex
% arara: bib2gls if found("aux", "glsxtr@resource")
% arara:  xelatex
% arara:  xelatex

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass [a4paper, 12pt, twoside,openright] {book}       
\usepackage [czech] {babel}       
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{microtype}          
\usepackage [a4paper, twoside, inner=2.5cm, outer=2.5cm, bottom=3cm] {geometry}         

\usepackage{import}     
\usepackage{filecontents}       

\usepackage[record, nopostdot, automake, abbreviations,% 
                    nostyles, stylemods={all}%
                    ]{glossaries-extra}

\GlsXtrLoadResources[selection={all},%
            src={testgls},%
            save-locations=false,%
            charset=UTF-8%
            ]

%Glossary entries
\begin{filecontents}{testgls.bib}
% !TEX encoding = UTF-8 Unicode
@entry{nonasciichartest,
    name={ačšěřžýáíéťďň},
    description={ačšěřžýáíéťďň}
}
@entry{asciitest,
    name={ASCII test},
    description={abcdefghijklmopqrstuvwxyz}
}
\end{filecontents}{testgls.bib}

\begin{document}

\nonfrenchspacing

\thispagestyle{empty}

\printunsrtglossary[type={main}, style={altlistgroup}, title=Slovníček pojmů, toctitle=Slovníček pojmů]

\clearpage

Standard text:

ěščřžýáíéťďň

\end{document}

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.