LuaLaTeX 中的 glossaries-extra 包西里尔字符问题

LuaLaTeX 中的 glossaries-extra 包西里尔字符问题

当我在 LuaLaTeX 中使用带有西里尔字符的 glossaries-extra 时,遇到两个问题:

  1. 词汇表和缩写的行距不同;

  2. 西里尔字母索引的排序不正确。

请参阅下面的 MWE 作为示例,它编译为本问题末尾提供的文档。

我在 Windows 10 中使用 MikTex,选项如下JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8". 在 TexStudio 中使用此命令:bib2gls.exe -g --tex-编码 utf-8%

我怎样才能解决这个问题?

非常感谢。

在此处输入图片描述

% !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}

答案1

在索引中进行分组时,最简单的设置是按不区分大小写的字母自动分组:

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

光泽

缩写

指数

不过,该软件包可以实现比这更强大的输出。对我来说,我必须通读手册并查看示例。

平均能量损失

\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}

相关内容