Latex 列表字符串和关键字
大家好,
我正在处理一个乳胶文档,我在列表包中提取了一些代码。我在 stackoverflow 上发现了一些很棒的东西,我看起来真的很酷,但是有两件事我想要,但我不知道如何获得。
我希望看到我的代码中突出显示的字符串和关键字(clojure 关键字而不是乳胶关键字)(突出显示的只是表示不同的颜色或其他内容。字符串的模式是“字符串”,关键字是:关键字名称(因此从:到下一个空间)有人知道如何做到这一点吗?
谢谢您的回答。
Hallo all,
I'm working on a latex document and I pull some code in with the listings package. I found some great stuff here on stackoverflow and i look really cool but there are two things I want but I don't know how to get.
I would like to see strings and keywords (clojure keywords not latex keywords) highlighted in my code (with highlighted I just mean a diffrent color or something. The patterns for string is "string" and a keyword is :keyword-name (so from :to the next space). Does anybody know how to do this.
Thanks for you anwsers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里是我在列表包中支持 clojure 的包。您可以使用标准列表设置突出显示关键字
Here is my package for support clojure in listings package. You can highlight keywords by using standard listings settings
我不相信列表能够处理这个问题。您可以使其突出显示字符串(通过
stringstyle
optin),但不能突出显示任意标记(关键字需要这些标记)。另一种方法是使用 minted 软件包。诚然,它的用法并不那么简单,因为它依赖于安装的附加软件(Pygments),但从好的方面来说,它附带了一个用于 Closure 的现成词法分析器。
(如果您下载 minted,请使用存储库中的提示版本而不是最新版本,因为该版本有错误。:-()
I don’t believe listings is able to handle that. You can make it highlight strings (via the
stringstyle
optin), but not arbitrary tokens (which you would need for your keywords).An alternative would be to use the minted package. Admittedly, its usage isn’t as straightforward since it relies on additional software (Pygments) to be installed, but on the plus side it ships with a ready-made lexer for Closure.
(If you download minted, use the tip version from the repository instead of the latest release, since the release is buggy. :-()
列表包的文档提供了定义您自己的语言并指定其关键字的示例。示例开始:
我没有任何使用此功能的经验,但我相信您能够弄清楚。您还必须确保为您的列表设置关键字突出显示。
The documentation for the listings package provides an example of defining your own language and specifying what its keywords are. The example begins:
I don't have any experience using this feature, but I'm sure you'll be able to figure it out. You'll also have to ensure that you set keyword highlighting on for your listings.