Pergunta

Hallo All,

Estou trabalhando em um documento de látex e puxo algum código com o pacote de listagens. Encontrei ótimas coisas aqui no Stackoverflow e pareço muito legal, mas há duas coisas que quero, mas não sei como conseguir.

Eu gostaria de ver strings e palavras-chave (palavras-chave de clojure e palavras-chave não látex) destacadas no meu código (com destacado, só quero dizer uma cor diferente ou algo assim. Os padrões para string é "string" e uma palavra-chave é: nome da palavra-chave (assim de : para o próximo espaço). Alguém sabe como fazer isso.

Obrigado por você Anwsers.

Foi útil?

Solução

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. :-()

Outras dicas

Here is my package for support clojure in listings package. You can highlight keywords by using standard listings settings

The documentation for the listings package provides an example of defining your own language and specifying what its keywords are. The example begins:

\lstdefinelanguage{rock} {morekeywords={one,two,three,four,five,six,seven,eight,
nine,ten,eleven,twelve,o,clock,rock,around,the,tonight},

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top