TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a listing like so:

some Python code goes here

In the PDF this appears as Listing 1. Caption. How can I make it appear as Figure 1. Caption? It is worth mentioning that mixing real figures and listings has to keep consistent figure numbering.

share|improve this question
You should check next link that worked for me: stackoverflow.com/questions/2814714/… – user828814 Mar 27 '12 at 18:46
up vote 12 down vote accepted

I think it's appropriate to use a little trick here: don't set the caption in the lstlisting environment, but enclose the listing in figure and use \caption:





  \caption{Hello World}
  print "Hello World!"


This way you can mix real figures and listings while keeping consistent figure numbering.

share|improve this answer
Excellent, worked perfectly. I tried putting it in figures before but it didn't do any good because I didn't move the captions. – Adam Jun 2 '11 at 7:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.