GeneralListings: How to support hyphens in keywords?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
benowar
Posts: 33
Joined: Mon Aug 06, 2007 2:05 pm

Listings: How to support hyphens in keywords?

Post by benowar »

I read that for listings you can not have a "-" inside a keyword. But I want to emphasize a property list that looks like this:

Foo-Bar : Value

Any ideas how to set "Foo-Bar" as keyword?

Thanks,
Ben

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Listings: How to support hyphens in keywords?

Post by gmedina »

From listings documentation:
Another problem: by default some characters are not allowed inside keywords, for example ‘-’, ‘:’, ‘.’, and so on. The reference guide covers this problem by introducing some more keys, which let you adjust the standard character table appropriately.

So, read the section "Reference Guide"
1,1,2,3,5,8,13,21,34,55,89,144,233,...
benowar
Posts: 33
Joined: Mon Aug 06, 2007 2:05 pm

Re: Listings: How to support hyphens in keywords?

Post by benowar »

Thanks! For some reason I thought the reference manual was separate. The solution is to define:

alsoletter={-}
Post Reply