tags:

views:

21

answers:

0

I use the following code to display line 23-45 of sort.cpp

\lstinputlisting[language=C++,linerange=23-45]{sort.cpp}

but the line number start with 1 while I want it start at 23.I read some reference and change to

\lstinputlisting[language=C++,linerange=23-45,firstnumber=23]{sort.cpp}

It works.And I want this the default setting.According page 31 of the reference listings.pdf,

auto lets the package choose the first number: a new listing starts with number one, a named listing continues the most recent same-named listing (see below), and a stand alone file begins with the number corresponding to the first input line.
last continues the numbering of the most recent listing and number sets it to the number.

it should be default.What's wrong or I misunderstood the reference.

My listings setting:

\usepackage{xcolor,listings}%color support for listings
\lstset{
basicstyle=\footnotesize,
numbers=left, 
numberstyle=\footnotesize, 
keywordstyle=\color{blue!70}, 
commentstyle=\color{red!50!green!50!blue!50}, 
%stringstyle=\ttfamily, % typewriter type for strings
%frame=shadowbox, 
rulesepcolor=\color{red!20!green!20!blue!20},
escapeinside=``, 
xleftmargin=2em,xrightmargin=2em, aboveskip=1em,
breaklines=true             % sets automatic line breaking
}