# lstlisting produces empty row when used inside a tabular

Is there any way I can get rid of the empty new row produced by lstlisting inside a tabular?

Here's a minimum working example:

\documentclass[11pt]{article}

\usepackage{listings}
\lstset{
language=python,
showspaces=false,
showtabs=false,
tabsize=4,
frame=trbl,
frameround=tttt,
basicstyle=\ttfamily,
showstringspaces=false,
numbers=left,
breaklines=true,
}

\begin{document}

\begin{tabular}{l | p{0.8\textwidth}}
test &
\begin{lstlisting}
somecode
\end{lstlisting}
\end{tabular}

rest of text

\end{document}


I'm using TexShop with xelatex.

Follow-up question: It also seems to break when I'm using longtable: The tables don't continue into other pages, instead it creates huge gaps and I'm suspecting it has to do with lstlisting.

-

belowskip=-\baselineskip


So

\begin{tabular}{l | p{0.8\textwidth}}
test &
\begin{lstlisting}[belowskip=-\baselineskip]
somecode
\end{lstlisting}
\end{tabular}


There is also aboveskip

-
I get missing number, treated as zero. –  pg-robban Oct 14 '11 at 17:22
The option must be added when calling the environment. It's an option for \lstset, but I don't think it's good to put it in the general options. I put it in the wrong place, sorry. –  egreg Oct 14 '11 at 17:24
It seems to work for tables, but seems to break if I have text immediately after when it's not inside a table: i.imgur.com/C98iu.png –  pg-robban Oct 14 '11 at 17:26
@pg-robban That's why it's better to set belowskip to zero only when really needed: don't put in \lstset, but only as optional argument in tables. –  egreg Oct 14 '11 at 17:29
Nevermind, just saw your update. It works now. Thanks :) –  pg-robban Oct 14 '11 at 17:31