Text FormattingDifferent types of listing captions in the same document

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
gkl
Posts: 28
Joined: Sat Jan 17, 2009 12:21 am

Different types of listing captions in the same document

Post by gkl »

Dear All,

I have the following problem: in my PhD thesis, I have two "types" of listings - say those that contains definitions and pseudocode and those that contain examples.

I know that I can use the caption package in order to change the appearance of captions for the listings. However, I want to be able to have two different types of captions, one to be used for each different type of listing and to be able to switch between them every time I have a lstlisting environment.

Is there a way of doing this?

Regards,
George

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

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Re: Different types of listing captions in the same document

Post by sommerfee »

Take a look at \lstnewenvironment (described in the listings package documentation)
gkl
Posts: 28
Joined: Sat Jan 17, 2009 12:21 am

Re: Different types of listing captions in the same document

Post by gkl »

Works like a charm, thank you very much!
Post Reply