Take the 2-minute tour ×

I want to take the answer to the question LaTeX source code listing like in professional books one step further, and change the (latex-generated) text in the caption from Listing n to something more personalized, like Code Snippet n.

How can I do this?

share|improve this question
Okay. How can I migrate this question? Or should I repost? –  SNag Jun 3 '12 at 20:34
You can flag it for attention by a moderator, and ask them to migrate it. –  Makoto Jun 3 '12 at 20:36
Makoto is right, it is described in this meta question –  buc Jun 3 '12 at 20:39
add comment

migrated from stackoverflow.com Jun 4 '12 at 7:56

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 6 down vote accepted

You can use \renewcommand* to change the value from Listing to whatever you wish.

Some dummy text.

% Some helpers that made C code look passable in a report
\begin{lstlisting}[caption={C code},label=C, language=C, basicstyle=\ttfamily, keywordstyle=\normalsize, identifierstyle=\normalsize, stringstyle=\normalsize, showstringspaces=false]

for (j = 0; j < 20; ++j) {  
        while ((c = getchar()) != '-') {
share|improve this answer
Thanks Makoto! This is what I was looking for! –  SNag Jun 3 '12 at 20:48
How does \renewcommand* differ from \renewcommand? –  SNag Jun 4 '12 at 20:26
@SNag: I don't think there is any (tested it out when you asked the question). It's the command that appeared in some of my old printoffs about TeX, and that's the one manual I had to grab when I answered this. –  Makoto Jun 5 '12 at 23:58
add comment

Your Answer


