在部分标题中使用 \Glsentrytext{} 时出错

发布于 2024-09-05 19:30:58 字数 425 浏览 4 评论 0原文

在 LaTeX 文档中使用 glossaries 包时,我偶尔想使用词汇表条目作为章节或章节标题的一部分。例如:

\section{\Glsentrytext{big}}

但这会导致错误。尝试使用 \protect\Glsentrytext{} 并不能解决问题。请注意,使用非大写版本 (\glsentrytext) 不会产生任何问题。

有谁知道有什么方法可以让它发挥作用吗?



我偶尔使用词汇表包作为以一致的方式格式化特定字符串的方法。例如 \gls{big} 变成“beam-into-gas”。显然,我可以创建两个术语表条目(带大写和不带大写)来实现这一目标,并且在最终术语表中只包含一个。但这是一个丑陋的解决方案。

When using the glossaries package in a LaTeX document I occasionally want to use a glossary entry as part of section or chapter title. For example:

\section{\Glsentrytext{big}}

This however results in an error. Trying to use \protect\Glsentrytext{} does not solve the the problem. Note that using the non-capitalized version (\glsentrytext) does not produce any problems.

Does anyone know of a way to get this to work?

I use the glossaries package occasionally as way to format specific strings in a consistent way. For example \gls{big} turns into 'beam-into-gas'. Obviously I could create two glossary entries, with and without caps, to achieve this and only include one in the final glossary. That is an ugly solution though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

说不完的你爱 2024-09-12 19:30:58

不幸的是,我不知道为什么这不起作用或如何修复它,但我知道一个解决方法:

注意:这需要 glossaries 包的当前版本。我用 2.07 版测试了它,它可以工作,而 2.03 版则不起作用,因为该版本中不存在 user1-user6 键。

解决方法

使用以下命令定义条目:

\newglossaryentry{big}{name=big,type=main,text={beam-into-gas},user1={Beam-into-gas}}

然后像这样使用它:

\section{\glsentryuseri{big}}

如果章节标题是该条目的唯一出现,那么您必须使用 \glsadd{big}

评论

此解决方法与您发布的有关创建两个条目的想法类似,只是您不必创建两个条目。 :-)

但是,我可以想象 \Glsentrytext 不起作用的事实是 LaTeX 中的一个限制,这意味着它无法完成。但这只是猜测。

PS:也许您应该将问题发布到 http://tex.stackexchange.com 上,以便更快地获得答案。

Unfortunately I don't know why this doesn't work or how to fix it but I know a workaround:

Note: This requires a current version of the glossaries package. I tested it with version 2.07 which worked and with version 2.03 which didn't work because the user1-user6 keys didn't exist in that version.

Workaround

Define the entry with the following command:

\newglossaryentry{big}{name=big,type=main,text={beam-into-gas},user1={Beam-into-gas}}

And then use it like that:

\section{\glsentryuseri{big}}

If the section title is the only occurrence of the entry then you have to add the entry to the glossary manually using \glsadd{big}.

Comment

This workaround is similar to the idea you posted about creating two entries except that you don't have to create two entries. :-)

However, I could imagine that the fact that \Glsentrytext doesn't work is a limitation in LaTeX which would mean that it can't be done. But this is just guessing though.

PS: Maybe you should have posted the question on http://tex.stackexchange.com to get an answer faster.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文