Document ClassesHow can I rename a Listing caption

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
betyaros
Posts: 9
Joined: Thu May 01, 2008 10:02 pm

How can I rename a Listing caption

Post by betyaros »

Hi,

How can I rename the Listing prefix which is standing before the number of it? So I would like to rename "Listing ##" to "Something ##". I hope you understand me :)

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

How can I rename a Listing caption

Post by Stefan Kottwitz »

Hi betyaros,

try

Code: Select all

\renewcommand*\lstlistingname{Something}
Stefan
LaTeX.org admin
betyaros
Posts: 9
Joined: Thu May 01, 2008 10:02 pm

How can I rename a Listing caption

Post by betyaros »

Some similar solution I need... but in this case I got the following error message :

Code: Select all

LaTeX Error: \lstlistingname undefined.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: How can I rename a Listing caption

Post by Stefan Kottwitz »

I assumed you were using the listings package, there's that command defined. What are you using? Can you give a small example?

Stefan
LaTeX.org admin
betyaros
Posts: 9
Joined: Thu May 01, 2008 10:02 pm

Re: How can I rename a Listing caption

Post by betyaros »

ummm my god :oops: I mixed up the \usepackage and the \renewcommand commands. \usepackage should precedes \renewcommand.

Thank you - it's working :)
betyaros
Posts: 9
Joined: Thu May 01, 2008 10:02 pm

Re: How can I rename a Listing caption

Post by betyaros »

By the way, how can I change the order of them? So I want to write "##. Something." instead of "Something ##." before the caption. (where ## are numbers)
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

How can I rename a Listing caption

Post by sommerfee »

Code: Select all

\usepackage{caption}
\DeclareCaptionLabelFormat{something}{#2.#1.}
\captionsetup[lstlisting]{labelformat=something}
should work.
betyaros
Posts: 9
Joined: Thu May 01, 2008 10:02 pm

Re: How can I rename a Listing caption

Post by betyaros »

Thank you, I learnt a lot.
Post Reply