# messy/overwritten numbering in enumerate tag

I have the following in my LateX code:

\begin{enumerate}
\item
\begin{lstlisting}
x = [x for x in xrange(4, 9)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}


Now, the result I get overlaps/overwrites positions for the numberings:

This obviously, not what anyone would want to do. How can I fix the numbering?

Thanks for all the help?

-
Depending on your application, I would consider using \lstinline instead... Might I ask what you're trying to get at? (Just out of curiosity.) –  Sean Allred Feb 1 '14 at 5:59
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Mar 20 '14 at 22:52

Leave a blank line (or use \par):

\documentclass{article}
\usepackage{listings}

\begin{document}

\begin{enumerate}
\item
\begin{lstlisting}
x = [x for x in xrange(4, 9)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\par
\item
\begin{lstlisting}
x = [x for x in xrange(6)]
\end{lstlisting}
\end{enumerate}

\end{document}


Or use \lstinline:

\documentclass{article}
\usepackage{listings}

\begin{document}

\begin{enumerate}
\item
\lstinline{x = [x for x in xrange(4, 9)]}
\item
\lstinline{x = [x for x in xrange(6)]}
\item
\lstinline{x = [x for x in xrange(6)]}
\end{enumerate}

\end{document}


-
Is there a TeX command line where I could use a help interface? For example, could I do help(par)? –  CodeKingPlusPlus Feb 1 '14 at 1:49
@codeking You can use the command texdoc but that is mostly for packages. –  Kartik Feb 1 '14 at 2:12
@CodeKingPlusPlus there's \show that gives the "definition" of commands, but since \par is a TeX primitive, it won't help here. \par end the paragraph; it is equivalent to leaving a blank line in the code. –  Gonzalo Medina Feb 1 '14 at 2:15