【问题标题】:Exclude entry from glossary?从词汇表中排除条目?
【发布时间】:2010-05-15 01:38:04
【问题描述】:

我正在使用 LaTeX 中的词汇表包。我的文档中有\gls{foo},但我不希望“foo”的条目出现在词汇表中。如何在文档正文中保留工作(即扩展)\gls{foo},但从词汇表中排除“foo”条目?

编辑:我想使用\gls{foo} 来表示“这里使用的‘foo’在本文档中具有其特定含义。”不过,在少数情况下,我得到了一个“foo”,它的定义太明显——或者难以——在词汇表中表达清楚。

所以我希望\gls{foo} 像往常一样扩展,但我不希望“foo”条目出现在词汇表中。

我希望这能增加更多关于我想要完成的工作的信息。这可能是对术语表的滥用,但我发现确保在编写技术文档时始终使用相同的单词和正确的单词很有帮助。

【问题讨论】:

  • 你能举例说明这在哪里有用吗?为什么不直接用foo 替换\gls{foo}?您希望看到的实际最终效果是什么?

标签: latex glossaries


【解决方案1】:

如果您使用glossaries 包,您可以创建一个“忽略”词汇表,如

\documentclass{article}

\usepackage{glossaries}
\newglossary[glignoredl]{ignored}{glignored}{glignoredin}{Ignored Glossary}
\makeglossaries

\newglossaryentry{foofoo}{name={FOOFOO},description={foofoo stuff}}
\newglossaryentry{foo}{name={FOO},type={ignored},description={no good description}}
\newglossaryentry{bar}{name={BAR},description={bar of stuff}}

\begin{document}

Here is a \gls{foo} that is also a \gls{bar}, but of course it's also a \gls{foofoo}.
Why not consider buying a \gls{foo}?

\printglossary
% \printglossary[type={ignored}]

\end{document}

【讨论】:

    【解决方案2】:

    我不知道你为什么要这样做,但以下应该可以工作:

    \let\oldgls\gls% store the original meaning of \gls in a new command named \oldgls
    \let\gls\relax$ make \gls do nothing
    Some text with \gls{foo} no links to the glossary, 
    and no ``foo'' entry in the glossary.
    \let\gls\oldgls% restore the original meaning of \gls
    Some more text with \gls{bar} that links to the glossary,
    and with a ``bar'' entry in the glossary.
    

    【讨论】:

    • \gls{foo} 在我的文档中出现了几十次。此外,有时“foo”是一个不同的词,但后来变成了“foo”,现在我不想在词汇表中出现“foo”,但我仍然希望用 \gls{foo} 来引用它(它可能会自行更改在未来的某个时候)。因此,我更喜欢不需要我在每次使用 \gls{foo} 时都掺假的解决方案。我在想应该有某种方法来设置条目,就好像它在 something 开始生成词汇表时“未使用”一样。我不介意在最后添加\glsignore{foo} 之类的内容。
    【解决方案3】:

    这可以通过将术语添加到特殊的common 字典来完成。它实际上是glossaries 包的内置功能,甚至是exemplified by the package author。从上述例子:

    \documentclass{article}
    
    \usepackage{glossaries}
    \newignoredglossary{common}
    \makeglossaries
    
    \newglossaryentry{sample}{name={sample},description={an example}}
    \newglossaryentry{commonex}{type=common,name={common term}}
    
    \begin{document}
    \gls{sample}. \gls{commonex}.
    \printglossaries
    \end{document}
    

    注意\newignoredglossary 命令的使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-27
      • 1970-01-01
      • 2018-01-29
      • 1970-01-01
      相关资源
      最近更新 更多