词汇表包:删除 numberlist 和 seelist 之间的分隔符

词汇表包:删除 numberlist 和 seelist 之间的分隔符

我正在使用glossaries使用包makeidx(在手册中称为选项 2)。我的词汇表包含几个与其他术语有交叉引用的项目,其中一个定义的示例如下:

\newglossaryentry{gls:crossCorrelation}{name={cross-correlation},
description={A mathematical process which is used to determine the similarity of two signals},
see={gls:convolution}
}

我希望交叉引用出现在描述和页面列表的单独一行上(在手册中numberlist有时称为locationlist)。为此,我将seeformat命令重新定义为:

\renewcommand*{\glsseeformat}[3][\seename]{
\newline \emph{#1} \glsseelist{#2}}

我遇到的问题是,seelist实际上是数字列表的一部分(如手册第 111 页所述glossaries),因此共享其分隔符标点。因此,上述示例的词汇表条目显示为:

互相关用来确定两个信号相似性的数学过程。26, 49,
另请参阅:卷积

从上可以看出,后面有一个不想要的逗号numberlist

我仔细查看了手册和文档代码,但找不到删除这个逗号的方法。我曾希望找到构建的命令,numberlist并假设会有一个与交叉引用列表相关的 if 语句。

完整 MWE:

\documentclass{article}
\usepackage{glossaries}

%Setup see formatting of gloaary entries
\renewcommand*{\seename}{See also:}
\renewcommand*{\glsseeformat}[3][\seename]{
\newline \emph{#1} \glsseelist{#2}}

%Enable glossaries
\makeglossaries

%Gloassry entries
\newglossaryentry{gls:world}{name={World},
    description={A planet capable of supporting life. It is not unheard of for bowls of petunias or indeed whales to fall towards them},
    see={gls:planet,gls:life}
}
\newglossaryentry{gls:planet}{name={planet},
    description={A large object with a radius typically greater than $2000~\mathrm{km}$ which meets the following criteria: is in orbit around the Sun, has sufficient mass for its self-gravity to overcome rigid body forces so that it assumes a hydrostatic equilibrium (nearly round) shape, and (c) has cleared the neighbourhood around its orbit}
}
\newglossaryentry{gls:life}{name={life},
    description={The condition that distinguishes animals and plants from inorganic matter, including the capacity for growth, reproduction, functional activity, and continual change preceding death}
}

\begin{document}
Hello \gls{gls:world}! How is \gls{gls:life} on your \gls{gls:planet}?
\printglossary
\end{document}

这是用以下代码编译的:

pdflatex.exe example.tex
makeindex -s example.ist -t example.glg -o example.gls example.glo
makeindex -s example.ist -t example.alg -o example.acr example.acn
pdflatex.exe example.tex

这些的结果如下所示(突出显示了不需要的逗号)。

MWE 输出

答案1

makeindex将交叉引用视为具有特定格式的位置,通常,格式化命令(\glsseeformat在本例中)会忽略该位置。如果这不符合您的要求,您可以将交叉引用存储在用户键之一中,而不是使用该see键。然后您需要编写使用此信息的词汇表样式。调整您的 MWE:

\documentclass{article}
\usepackage{glossaries}

%Enable glossaries
\makeglossaries

%Glossary entries
\newglossaryentry{gls:world}{name={World},
    description={A planet capable of supporting life. It is not unheard of for bowls of petunias or indeed whales to fall towards them},
    user1={gls:planet,gls:life}
}
\newglossaryentry{gls:planet}{name={planet},
    description={A large object with a radius typically greater than $2000~\mathrm{km}$ which meets the following criteria: is in orbit around the Sun, has sufficient mass for its self-gravity to overcome rigid body forces so that it assumes a hydrostatic equilibrium (nearly round) shape, and (c) has cleared the neighbourhood around its orbit}
}
\newglossaryentry{gls:life}{name={life},
    description={The condition that distinguishes animals and plants from inorganic matter, including the capacity for growth, reproduction, functional activity, and continual change preceding death}
}

\newglossarystyle{crossreflist}%
{% base it on list (adapt as required)
  \renewcommand*{\glossentry}[2]{%
  \item[\glsentryitem{##1}%
        \glstarget{##1}{\glossentryname{##1}}]
     \glossentrydesc{##1}\glspostdescription\space ##2%
% check if the user1 key has been supplied:
    \ifglshasfield{useri}{##1}%
    {% do cross-reference
      \newline
      \glsletentryfield{\crossrefs}{##1}{useri}%
      \glsseeformat[See also:]{\crossrefs}{}%
    }%
    {}%
  }%
}
\setglossarystyle{crossreflist}

\begin{document}
Hello \gls{gls:world}! How is \gls{gls:life} on your \gls{gls:planet}?

\printglossary
\end{document}

得出的结果为:

生成的词汇表的图像

相关内容