# lstlisting only shows single line number on top

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}
\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}

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Nov 2, 2017 at 12:27
• Thanks for the useful link about (MWEs). While minimizing, I already found the problem. Nov 2, 2017 at 14:18
• Then, what was the problem? Nov 2, 2017 at 14:21
• I edited the original question to include the solution as well. A "\RequirePackage[hebrew,english]{babel}" command inside the cls was the source of the problem. I did not actually need that package in the document, so I simply removed it. Nov 2, 2017 at 14:27