# backgroundcolor in lstset does not work

When I use the backgroundcolor option in lstset, all I get is a colored line above the listing:

\lstset{%
language=Matlab,
backgroundcolor=\color{blue}
}

and in the document:

\L{\inputencoding{cp1255}
\begin{lstlisting}[basicstyle={\footnotesize\ttfamily}]
>> x(6)
ans =
9
\end{lstlisting}
\inputencoding{utf8x}}

and the result:

How can I fix this issue?

I'm using LyX and therefore I'm not sure which lines of code are crucial here.

EDIT: Here's a complete example source as generated by LyX, edited down to make a MWE (the output is the same image as above):

\documentclass[hebrew]{article}
\usepackage[T1]{fontenc}
\usepackage[cp1255]{inputenc}
\usepackage{babel}
\usepackage{listings}
\usepackage{color}

\lstset{%
language=Matlab,
backgroundcolor=\color{blue}
}

\begin{document}
\L{
\begin{lstlisting}[basicstyle={\footnotesize\ttfamily}]
>> x(6)
ans =
9
\end{lstlisting}
}
\end{document}
-
give a complete example not only fragments. – Herbert Mar 7 '11 at 17:31
@Herbert here you go – Amir Rachum Mar 7 '11 at 17:39
I made the MWE smaller by removing all unrelated stuff. It seems that whatever babel does for Hebrew causes the problem (also my computer complains about missing jerus10 font; no idea whether that is related). – Caramdir Mar 7 '11 at 23:34
You might be interested in the matlab-prettifier package; see this answer. – Jubobs Apr 28 '14 at 15:39

Amir, it seems as if the old fashioned cp1255/babel are not so robust. Here is an example using xetex. Perhaps you can start from it and work backwards to cp1255 and babel.

\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\setmainlanguage{english}

\lstset{language=Matlab,backgroundcolor=\color{blue}}
\setmainfont{Comic Sans MS}

\newfontfamily\hebrewfont[Script=Hebrew]{Ezra SIL}
\newfontfamily\listingsfont[
Extension=.otf,
UprightFont=*-Regular,
BoldFont=*-Bold,
ItalicFont=*-Italic,
BoldItalicFont=*-BoldItalic,
]{UMTypewriter}

\begin{document}

\let\ttfamily=\listingsfont

\begin{lstlisting}[basicstyle={\footnotesize\ttfamily}]
>> x(6)
ans =
9
\end{lstlisting}

\LR{
\begin{lstlisting}[basicstyle={\footnotesize\ttfamily}]
>> x(6)
ans =
9
\end{lstlisting}
}

\lstdefinestyle{numbered}{
backgroundcolor=\color{blue!20},
numbers=right,
stepnumber=1,
numbersep=-6pt,
xleftmargin=3ex,
xrightmargin=3ex,
numberblanklines=false,
numberstyle=\tiny\bf,
frame=trBL,
}
\begin{lstlisting}[style=numbered]
>> x(6)
ans =
9
\end{lstlisting}
\end{document}

-