9

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.

3
  • 1
    Is this really a bug - or a feature? – Stephen Nov 5 '12 at 19:18
  • 1
    i'd prefere a black border over a colored one... – Andreas Pabst Nov 5 '12 at 19:22
  • 1
    Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It is considered a lot better to put in some code that will compile, as it makes it a lot easier for us to copy it into our text editor and work with it, and see exactly what it is you are trying to do. – Mensch Nov 5 '12 at 19:36
9

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}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.