1

Code I got from here...

When I run it, the output has line numbers broken, like it says 1, then from 3 to 6 and then 8 to 11... Any idea why?

\documentclass{beamer}

\setbeamercovered{transparent}

\usepackage{pxfonts}
\usepackage{listings}

\begin{document}

\lstset{language=python,
        numbers=left,
        numberstyle=\tiny,
        showstringspaces=false,
        aboveskip=-40pt,
        frame=leftline
        }

\begin{frame}[fragile]
\frametitle{\texttt{parrot.py}}
\begin{semiverbatim}
\pause
\begin{lstlisting}
if __name__ == "__main":

\end{lstlisting}

\pause
\begin{lstlisting}[firstnumber=last]
    print "Oh yes, the, uh,
           the Norwegian Blue..."
    print "What's, uh...
           What's wrong with it? "

\end{lstlisting}

\pause
\begin{lstlisting}[firstnumber=last]
    print "I'll tell you what's wrong with it,
           my lad."
    print "'E's dead,
           that's what's wrong with it!"

\end{lstlisting}
\end{semiverbatim}
\end{frame}

\end{document
4

There are empty lines in those listings. A line number is assigned to each empty line, but that number is not printed. Try:

\documentclass{beamer}

\setbeamercovered{transparent}

\usepackage{pxfonts}
\usepackage{listings}

\begin{document}

\lstset{language=python,
        numbers=left,
        numberstyle=\tiny,
        showstringspaces=false,
        aboveskip=-40pt,
        frame=leftline
        }

\begin{frame}[fragile]
\frametitle{\texttt{parrot.py}}
\begin{semiverbatim}
\pause
\begin{lstlisting}
if __name__ == "__main":
\end{lstlisting}

\pause
\begin{lstlisting}[firstnumber=last]
    print "Oh yes, the, uh,
           the Norwegian Blue..."
    print "What's, uh...
           What's wrong with it? "
\end{lstlisting}

\pause
\begin{lstlisting}[firstnumber=last]
    print "I'll tell you what's wrong with it,
           my lad."
    print "'E's dead,
           that's what's wrong with it!"
\end{lstlisting}
\end{semiverbatim}
\end{frame}

\end{document}

enter image description here

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.