# Changes sides of lstlisting line numbering when switching pages

I am currently writing some tesxt for my masters thesis. I have a coste listing which expands on two pages. I would like the listing to change sides of line numbering when switching the page. Is there any command for this? Thanks in advance

\usepackage{listings}
\lstset{ %
language=C++,
basicstyle=\footnotesize,
numbers=left,
numberstyle=\footnotesize,
stepnumber=1,
numbersep=5pt,
backgroundcolor=\color{white},
\usepackage{color}
showspaces=false,
showstringspaces=false,
showtabs=false,
frame=single,
tabsize=2,
captionpos=b,
breaklines=true,
breakatwhitespace=false,
escapeinside={\%*}{*)}
}

\begin{lstlisting}[caption={}, label={lst:label}, language=C]
function()
{
code
}
\end{lstlisting}

• Hi and welcome, do i understand it correctly, that you want to have the line numbers always at the outside (or inside), and not on the left side? Can you extend your snippet to a compilable minimal example so we see your basic setup? it also saves time building an own testcase. – Johannes_B Feb 4 '15 at 17:12
• Johannes_B yes I want the line numbers to be at the left OR right, depending on the page number. – raddirad Feb 4 '15 at 17:35
• Line numbers should always be at the left, in my opinion; if a line is short, a line number at the right margin will be almost unreachable without using a ruler for guiding the eyes to it. – egreg Feb 4 '15 at 20:40