I'm struggeling a little bit with the display of table of contents. I had previously a problem using natbib , and now the same issue with listings. Maybe I'm mixing something up with documentclass article and how to reat it.

That's a sample stating the issue:


\usepackage[numbers, square]{natbib}  
    pdfborder = {0 0 0}


\columnsep 0.5cm









\lstset{language=[Objective]C, breakindent=20pt, breaklines, tabsize=1,
caption={Change Identifiers}}

- (void) myMethod
    NSLog(@"Hello there");






The Listings is dipslayed as Listings1, but the pagenumber should be right aligned. Can someone point me to the solution, or what I'm doing wrong?

  • Your example is using the report documentclass. Also, compiling your example as-is shows Contents with an entry for the (List of) Listings. T he provided listing has the appropriate page number (5) right aligned, similar to the Contents. Perhaps the above example does not duplicate your problem? – Werner Aug 23 '11 at 19:51
  • Hey Werner, I'm sorry I was messing around figuring out the problem, indee changing the document to report, the listing is displayed correct in the TOC, but my actual document uses article sorry for the confusion! – Alx Aug 23 '11 at 20:20

Instead of


you can use


to produce a section-like entry with the listing number and the page number, or


if you don't want the listing number to appear, but you want to preserve the indentation of an section-like entry, or


if you don't want the listing number nor the indentation. A little example showing the three options:



enter image description here

P.S.: note that the article document class doesn't support chapter-like sectional units.

  • Thx Gonzalo, that sorted out my confusion! :P – Alx Aug 23 '11 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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