0

When I use glossaries-extra with cyrillic characters in LuaLaTeX, I get two issues:

  1. different line spacing in glossary and abbreviation;

  2. incorrect sorting in the index for Cyrillic words.

Please refer to the below MWE, for an example, which compiles to the document provided at the end of this question.

I am use MikTex in Windows 10 with option JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8". In TexStudio use this command: bib2gls.exe -g --tex-encoding utf-8 % .

How might I be able to resolve this issues?

Thanks so mach.

enter image description here

% !TeX program = lualatex
% !TeX encoding = utf-8
% !TeX spellcheck = ru_RU
%============================================================================================
\documentclass[12pt, a4paper]{article}
\usepackage{polyglossia}
\setdefaultlanguage[spelling=modern]{russian}  %% устанавливает главный язык документа
\setotherlanguage{english}                     %% устанавливает второй язык документа
\defaultfontfeatures{Ligatures={TeX},Renderer=Basic} %% задаёт свойства шрифтов по умолчанию
\setmainfont{Times New Roman}                  %% задаёт основной шрифт документа
\setsansfont{Arial}                            %% задаёт шрифт без засечек
\setmonofont{Courier New}                      %% задаёт моноширинный шрифт
%==========================================================
\usepackage[tracking=true]{microtype}
\microtypecontext{kerning=russian}
\usepackage{indentfirst}
%==========================================================
\usepackage[colorlinks]{hyperref}
\usepackage[record,% using bib2gls
index,% create 'index' glossary
abbreviations,% create 'abbreviations' glossary
postdot,% insert dot after descriptions
nostyles,%don't load predefined styles
stylemods={tree,bookindex},% load the 'tree' and 'bookindex' style packages
style={tree}% set the default style to 'tree'
]{glossaries-extra}

\setabbreviationstyle[common]{short} % set abbreviation style before \GlsXtrLoadResources

\GlsXtrLoadResources[ src={terms},% data in terms.bib label-prefix={idx.},% prefix for primary entry labels dual-prefix={},% prefix for dual entry labels type=index,% put primary entries in 'index' glossary combine-dual-locations={primary}% merge locations and assign to primary list ]

% provide commands that work like \gls etc for the @index entries % (that don't have a dual counterpart) \glsxtrnewglslike{idx.}{\idx}{\idxpl}{\Idx}{\Idxpl} \usepackage{filecontents} \begin{filecontents}[overwrite]{terms.bib} % Encoding: UTF-8 @index{hippo} @index{ЛПР} @index{goose,plural={geese}} @index{chateau,name={ch^ateau},plural={ch^ateaux}} @dualindexentry{duck, name = {duck}, description = {a waterbird with webbed feet} } @dualindexentry{whale, name = {кит}, description = {большая рыба} } @dualindexentry{shark, name = {акула}, description = {хищная рыба} } @dualindexentry{parrot, name = {parrot}, description = {mainly tropical bird with bright plumage} } @dualindexabbreviation{debs, short = {DEBS}, long = {Distributed Event-Based System} } @dualindexabbreviation{p2p, short = {P2P}, long = {Peer-to-Peer} } @dualindexabbreviation{http, short = {HTTP}, long = {Hypertext Transfer Protocol}, category={common} } @dualindexabbreviation{xml, short = {XML}, long = {eXtensible Markup Language} } @dualindexabbreviation{db, short = {БД}, long = {База данных} } @dualindexabbreviation{yamao, short = {ЯМАО}, long = {Ямало-Ненецкий автономный округ} } \end{filecontents}

\begin{document} \section{Sample}

First use \gls{debs} and \gls{p2p}.\\
\textbf{My test:} \gls{xml}, \gls{yamao}, \gls{db}.

Next use: \gls{debs} and \gls{p2p}.\\
\textbf{My test:} \gls{xml}, \gls{yamao}, \gls{db}.

No expansion: \gls{http}.

\section{Another Sample}

A \gls{duck} and a \gls{parrot} and \gls{whale} and \gls{shark}. Lots of \glspl{duck}.
\Idx{hippo}, \idxpl{goose} and a \idx{chateau}.

Тут написано про \idx{ЛПР}.

\printunsrtglossary % main glossary
\printunsrtglossary[type=abbreviations]% list of abbreviations

\newpage
\printunsrtglossary[type=index, style=bookindex, title=Index] % index

\end{document}

Youra_P
  • 1,054
  • I run OK (TeXLive 2022, Windows): no problems with line-spacing, and sorting in Index is Unicode: кит comes after parrot because Cyrillic is after Latin (also, capital letters before small letters). Perhaps I do not understand what the expected result should be. – Cicada Oct 23 '22 at 11:41
  • Sorting: "If the sort field is missing the default is obtained from the name field" (texdoc bib2gls). – Cicada Oct 23 '22 at 12:14
  • Related: https://tex.stackexchange.com/questions/287080/best-solution-for-acronyms-abbreviations-glossary-and-index/287128#287128 – Cicada Oct 23 '22 at 12:48
  • Thanks, @Cicada. Please, add a picture of your result. Sorting issue in Index only cyrillic words (bottom example in the picture). I used the example from the link you provided as a basis. – Youra_P Oct 23 '22 at 12:57
  • bib2gls.exe -g <---- Problems appear due to this option "-g". – Youra_P Oct 23 '22 at 13:03
  • I see what you mean now. It is related to grouping and sorting. – Cicada Oct 23 '22 at 17:13

1 Answers1

1

With grouping in the index, the simplest set-up is to auto-group on case-insensitive letters:

group={auto},
sort={letter-nocase},

gloss

abbrev

index

The package can do much more powerful output than that, though. For me, I will have to read the manual fully and see the examples.

MWE

\begin{filecontents}[overwrite]{terms.bib}
% Encoding: UTF-8 
@index{hippo}
@index{cake}
@index{КИТ,name={КИТ}}
@index{ЛПР}
@index{goose,plural={geese}}
@index{chateau,name={ch\^ateau},plural={ch\^ateaux}}
@dualindexentry{duck,
    name = {duck},
    description = {a waterbird with webbed feet}
}
@dualindexentry{кит2,
    name = {кит2},
    description = {большая рыба2}
}
@dualindexentry{whale,
    name = {кит},
    description = {большая рыба}
}
@dualindexentry{shark,
    name = {акула},
    description = {хищная рыба}
}
@dualindexentry{parrot,
    name = {parrot},
    description = {mainly tropical bird with bright plumage}
}
@dualindexabbreviation{debs,
    short = {DEBS},
    long = {Distributed Event-Based System}
}
@dualindexabbreviation{p2p,
    short = {P2P},
    long = {Peer-to-Peer}
}
@dualindexabbreviation{http,
    short = {HTTP},
    long = {Hypertext Transfer Protocol},
    category={common}
}
@dualindexabbreviation{xml,
    short = {XML},
    long = {eXtensible Markup Language}
}
@dualindexabbreviation{db,
    short = {БД},
    long = {База данных}
}
@dualindexabbreviation{yamao,
    short = {ЯМАО},
    long = {Ямало-Ненецкий автономный округ}
}
\end{filecontents}

%============================================================================================ \documentclass[12pt, a4paper]{article} \usepackage{polyglossia} \setdefaultlanguage[spelling=modern]{russian} %% устанавливает главный язык документа \setotherlanguage{english} %% устанавливает второй язык документа \defaultfontfeatures{Ligatures={TeX},Renderer=Basic} %% задаёт свойства шрифтов по умолчанию \setmainfont{Times New Roman} %% задаёт основной шрифт документа \setsansfont{Arial} %% задаёт шрифт без засечек \setmonofont{Courier New} %% задаёт моноширинный шрифт %========================================================== \usepackage[tracking=true]{microtype} \microtypecontext{kerning=russian} \usepackage{indentfirst}

%========================================================== \usepackage[colorlinks]{hyperref} \usepackage[record,% using bib2gls index,% create 'index' glossary abbreviations,% create 'abbreviations' glossary postdot,% insert dot after descriptions nostyles,%don't load predefined styles stylemods={tree,bookindex},% load the 'tree' and 'bookindex' style packages style={tree},% set the default style to 'tree' ]{glossaries-extra}

\setabbreviationstyle[common]{short} % set abbreviation style before \GlsXtrLoadResources

\GlsXtrLoadResources[ src={terms},% data in terms.bib %dual-sort={letter-nocase}, label-prefix={idx.},% prefix for primary entry labels dual-prefix={},% prefix for dual entry labels type=index,% put primary entries in 'index' glossary combine-dual-locations={primary},% merge locations and assign to primary list group={auto}, sort={letter-nocase}, %category={same as entry}, ]

% provide commands that work like \gls etc for the @index entries % (that don't have a dual counterpart) \glsxtrnewglslike{idx.}{\idx}{\idxpl}{\Idx}{\Idxpl} %\usepackage{filecontents}

\begin{document} \section{Sample}

First use \gls{debs} and \gls{p2p}.\\
\textbf{My test:} \gls{xml}, \gls{yamao}, \gls{db}.

Next use: \gls{debs} and \gls{p2p}.\\
\textbf{My test:} \gls{xml}, \gls{yamao}, \gls{db}.

No expansion: \gls{http}.

\section{Another Sample}

A \gls{duck} and a \gls{parrot} and \gls{whale} and \gls{shark}. Lots of \glspl{duck}.
\Idx{hippo}, \idxpl{goose} and a \idx{chateau}.

Тут написано про \idx{ЛПР}.

    \newpage
    \printunsrtglossary % main glossary
\newpage
    \printunsrtglossary[type=abbreviations]% list of abbreviations

\newpage
\printunsrtglossary[type=index, style=bookindex, title=Index] % index

\end{document}

Cicada
  • 10,129