[Tex/LaTex] listings with background color and mathescape broken

listings

I have a listings environment in my document with backgroundcolor=\color{grey} to get a nice grey background and mathescape=true for using math symbols. However when using the \vdots command inside a code listing I get a break in my listing, as follows:

\documentclass{book}
\usepackage{color}
\definecolor{grey}{rgb}{0.9,0.9,0.9}
\usepackage{listings}
\lstset{%
language=Lisp,
basicstyle=\small,
backgroundcolor=\color{grey},
mathescape=true}

\begin{document}
\begin{lstlisting}
(let ((<$var_1$> <$exp_1$>)
      (<$var_2$> <$exp_2$>)
      $\vdots$
      (<$var_n$> <$exp_n$>))
   <$body$>))
\end{lstlisting}
\end{document}

Resulting output:

enter image description here

So far it's only \vdots which is doing this (and it happens multiple times so I know it's not a fluke). Is there a fix for this, or maybe would minted work better at this sort of thing? (Although I'd rather not switch if I don't have to.)

Best Answer

The problem seems to be that listings expects a constant line height, and that \vdots just takes up too much vertical space. One fix is to redefine \vdots so that it takes up less vertical space:

\renewcommand\vdots{%
  \vbox{\baselineskip3pt\lineskiplimit0pt\kern1pt\hbox{.}\hbox{.}\hbox{.}\kern-1pt}}