I am using lstlisting as part of a large document, and I wish to present line numbers. I am using the following code:
\begin{lstlisting}[language=C++, numbers=left, frame=single, escapechar=@]
int a = 1; // first line @\label{demo:first_line}@
int b = 2; // second line @\label{demo:second_line}@
int c = 3; // third line @\label{demo:third_line}@
\end{lstlisting}
a appears in line \ref{demo:first_line}.
b appears in line \ref{demo:second_line}.
c appears in line \ref{demo:third_line}.
However, only a single number appears on the top left corner (changing the "numbers" flag to "right" will move it to the top right corner). Also, the frame appears to be broken and references to line numbers are all 0. See picture:
I copied the same code to a clean document, and everything worked fine:
EDIT: The following code reproduces the problem:
custom.cls:
\def\filename{custom}
\LoadClass{article}
\RequirePackage[hebrew,english]{babel}
\endinput
main.tex:
\documentclass{custom}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[language=C++, numbers=left, frame=single, escapechar=@]
int a = 1; // first line @\label{demo:first_line}@
int b = 2; // second line @\label{demo:second_line}@
int c = 3; // third line @\label{demo:third_line}@
\end{lstlisting}
a appears in line \ref{demo:first_line}.
b appears in line \ref{demo:second_line}.
c appears in line \ref{demo:third_line}.
\end{document}
\documentclass{...}
and ending with\end{document}
.