TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why is enumerating listings in LaTeX causing numbers in the list to be displayed in the wrong place? The following code prints the first and third list numbers in the correct place, but prints the second list number in the same place as the third and doesn't print the fourth at all.

\documentclass[titlepage]{article}
\usepackage{listings}
\begin{document}
\begin{enumerate}
\item
\begin{lstlisting}
SELECT * FROM foo;
\end{lstlisting}
\item
\begin{lstlisting}
SELECT * FROM bar;
\end{lstlisting}
\item
\begin{lstlisting}
SELECT * FROM foobar;
\end{lstlisting}
\item
\begin{lstlisting}
SELECT * FROM barfoo;
\end{lstlisting}
\end{enumerate}
\end{document}
share|improve this question

closed as too localized by cmhughes, Joseph Wright Dec 3 '12 at 16:23

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Are you sure you want to use the lstlisting environment and not the \lstinline macro? – egreg Dec 3 '12 at 13:27
    
Thanks @egreg, that fixed my problem and is a neater solution. – Nic Dec 3 '12 at 13:43