[Tex/LaTex] lstlisting border bug when breaking lines

colorframedlistings

I have a certain bug regarding listings. I have used the \lstset command to configure my lstlisting environment.

Somehow, when I have a line that is too long to fit into one row the listing breaks it properly, but somehow the border gets the same colour as the font.

Here is the \lstset:

\lstnewenvironment{pascalCode}[1][]
{
  \lstset{  
    backgroundcolor=\color{lightgrey},
    breaklines=true,
    basicstyle=\footnotesize,
    keywordstyle=\color{Blue},
    commentstyle=\color{DarkGreen}\textit,
    numbers=left,
    numberstyle=\footnotesize,
    stringstyle=\color{red},
    showspaces = false,
    showstringspaces = false,
    tabsize = 2,
    %numbers=left,
    %numbersyle=\tiny
    frame=single,
    xleftmargin=5pt,
    xrightmargin=3pt,
    language =  Pascal,
    aboveskip = 20pt,
    #1
  }
}{}

If you have any ideas how to fix that please reply.

Best Answer

Using the option rulecolor=\color{black} fixes that. Here is a before and after comparison:

enter image description hereenter image description here

Code:

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}

\lstnewenvironment{pascalCode}[1][]
{
  \lstset{  
    backgroundcolor=\color{gray!40},
    breaklines=true,
    basicstyle=\footnotesize,
    keywordstyle=\color{blue},
    commentstyle=\color{green}\textit,
    numbers=left,
    numberstyle=\footnotesize,
    stringstyle=\color{red},
    showspaces = false,
    showstringspaces = false,
    tabsize = 2,
    %numbers=left,
    %numbersyle=\tiny
    frame=single,
    xleftmargin=5pt,
    xrightmargin=3pt,
    language =  Pascal,
    aboveskip = 20pt,
    rulecolor=\color{black},
    #1
  }
}{}

\begin{document}
\begin{pascalCode}
(*
Some really long line that takes more than one line so lstlistings needs to wrap this line.
*)
\end{pascalCode}
\end{document}