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 captions on each of my listings. Each caption is prefaced with "Listing # [text]" where # is the number of the listing. Each caption is centered over my listing. How can I modify the options of these captions? Here is a visual:enter image description here

  1. I want to get truncate the caption to only contain [text]
  2. I want to move the position of the caption from the center towards the left-side
share|improve this question
up vote 5 down vote accepted
  1. If a listing has a title, it will be used instead of caption, but without "Listing #" line.

  2. Unfortunately centered titles are hardcoded into listings, so you need to change the code. Here is a solution: I've just took the package defined \@makecaption and deleted the secong \hfil and added \bfseries (note that \lst@maketitle uses \@makecaption and drops the first part. If you want to keept captions centered but titles left-aligned, you need to patch \lst@maketitle rather than \@maketitle).

Here us the result:

    \bfseries #1: #2\par

\begin{lstlisting}[title={Some listing}]
share|improve this answer

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.