# Listings lstlisting environment has white horizontal lines

I have sort of the same problem as the user benregn in

Listings code snippet has white horizontal lines across it

. But making the numberstyle smaller than the basicstyle does not solve my problem.

Minimum working example:

\documentclass{article}
\usepackage{lipsum}
\usepackage{lstautogobble}
\usepackage{listings}
\lstdefinestyle{myStyle}
{
tabsize=4,
autogobble=true,
mathescape=true,
numbers=left,
xleftmargin=9mm,
framexleftmargin=9mm,
comment=[l]\%\ ,
backgroundcolor=\color{black!10!white},
keywordstyle=\color{blue},
keywords=
{
and,
and,
case,
do,
else,
elseif,
end,
for,
function,
if,
switch,
to,
while,
}
}
\usepackage{xcolor}

\begin{document}
\lipsum[1]
\begin{lstlisting}[style=myStyle]
$abcdefghijklmnopqrstuvwxyz$
$\left\lfloor \frac{abcdefghijklmnopqrstuvwxyz}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\right\rfloor$
\end{lstlisting}
\lipsum[2]
\end{document}


The result looks like

. How do I fix this problem?

This issue is documented in the listings manual.

8.2 Listings with a background colour and LATEX escaped
formulas


At the moment there is only one workaround: • Write your code into an external file <filename>. • Input your code by \lstinputlisting{<filename>} into your document and surround it with a frame generated by \begin{mdframed} . . . \end{mdframed}.

This being said, I tried the shorter route and it appears to work, but no idea if it really does work.

\documentclass{article}
\usepackage{lipsum}
\usepackage{lstautogobble}
\usepackage{listings}
\lstdefinestyle{myStyle}
{
tabsize=4,
autogobble=true,
mathescape=true,
numbers=left,
xleftmargin=9mm,
framexleftmargin=9mm,
comment=[l]\%\ ,
keywordstyle=\color{blue},
keywords=
{
and,
and,
case,
do,
else,
elseif,
end,
for,
function,
if,
switch,
to,
while,
}
}
\usepackage{xcolor}

\usepackage{mdframed}

\begin{document}
\lipsum[1]
\begin{mdframed}[backgroundcolor=black!10!white]
\begin{lstlisting}[style=myStyle]
#test&&#$abcdefghijklmnopqrstuvwxyz$
$\left\lfloor \frac{abcdefghijklmnopqrstuvwxyz}{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\right\rfloor$
\end{lstlisting}
\end{mdframed}

\lipsum[2]
\end{document}