删除词汇表中页面范围的破折号分隔符

删除词汇表中页面范围的破折号分隔符

我希望更改页码在每个词汇表条目末尾的显示方式。例如,我希望它不显示 16-19,而是显示在正文中引用该条目的每一页(即 16、17、18、19)。

有没有什么方法可以做到这一点?

\documentclass [a4paper, 12pt] {report}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[backref=page, hyperfootnotes=false, hidelinks, colorlinks, citecolor=OliveGreen, linkcolor=Blue, linktocpage, bookmarks=true]{hyperref}
\usepackage[toc, nopostdot, nogroupskip]{glossaries}

\newglossarystyle{mylong}{
\setglossarystyle{long}
  \renewenvironment{theglossary}
{\begin{longtable}[l]{@{}p{\dimexpr 8cm-\tabcolsep}p{0.5\hsize}}}
 {\end{longtable}}
}

\makeglossaries
\newglossaryentry{Entry}{name={Entry}, description={This is a glossary entry. I want the page number entries to display 1, 2, 3 instead of 1--3.}}
\newglossaryentry{Entry2}{name={Entry2}, description={This is another glossary entry.}}


\begin{document}
\tableofcontents
\printglossary[style=mylong]

\chapter{Introduction}
This is an \gls{Entry}. This is another \gls{Entry2}.

\newpage

This is the same entry on another page \gls{Entry}.

\newpage

This is the same entry on yet another page \gls{Entry}.

\end{document}

答案1

为此,您可以使用辛迪选择词汇表包和命令一起使用\GlsSetXdyMinRangeLength。根据glossaries手册,你应该能够使用

\GlsSetXdyMinRangeLength{none}

但这对我来说不起作用。相反,我用

\GlsSetXdyMinRangeLength{100}

要以这种方式创建词汇表,您需要将其xindy作为选项添加到glossaries包中,然后makeglossaries从命令行/shall 运行命令,它将xindy为您调用。使用您的 MWE,这将产生

在此处输入图片描述

请注意,由于标题页的原因,页码为3,4,5,而不是。1,2,3

完整代码如下:

\documentclass [a4paper, 12pt] {report}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[backref=page, hyperfootnotes=false, hidelinks, colorlinks, citecolor=OliveGreen, linkcolor=Blue, linktocpage, bookmarks=true]{hyperref}
\usepackage[toc, nopostdot, nogroupskip, xindy]{glossaries}
\GlsSetXdyMinRangeLength{100}

\newglossarystyle{mylong}{
\setglossarystyle{long}
  \renewenvironment{theglossary}
{\begin{longtable}[l]{@{}p{\dimexpr 8cm-\tabcolsep}p{0.5\hsize}}}
 {\end{longtable}}
}

\makeglossaries
\newglossaryentry{Entry}{name={Entry}, description={This is a glossary entry. I want the page number entries to display 1, 2, 3 instead of 1--3.}}
\newglossaryentry{Entry2}{name={Entry2}, description={This is another glossary entry.}}


\begin{document}
\tableofcontents
\printglossary[style=mylong]

\chapter{Introduction}
This is an \gls{Entry}. This is another \gls{Entry2}.

\newpage

This is the same entry on another page \gls{Entry}.

\newpage

This is the same entry on yet another page \gls{Entry}.

\end{document}

相关内容