9 Comments

  1. Hi tom!
    Thanks for your code examples. Have you seen that white lines/stripes between the lines of code? – Do you know a solution for disabling them?

    Best regards!

    • Hi Kai,

      Thanks for your comment. I am aware of the problem. I found the following solution on stackoverflow and modified it slightly adding line numbers:

      \documentclass{minimal}
      \usepackage[pdftex]{xcolor}
      \usepackage[a4paper,hmargin=6cm]{geometry}
      \usepackage{listings}
      \usepackage{framed}
      \lstset{numbers=left,
      stepnumber=1,
      numbersep=1pt,
      numberstyle=\color{black},
      basicstyle=\ttfamily}
      \begin{document}
      \definecolor{shadecolor}{named}{gray}
      \begin{shaded}
      \begin{lstlisting}
       if (a < b)
       {
          printf("A is smaller than  B!\n");
       }
       a = b;
      \end{lstlisting}
      \end{shaded}
      \end{document}

      Best, Tom.

      • Thanks, Tom! – I have seen this on so, too. But the shaded box is (a little bit) ugly… :-|

        I have seen some examples that use “backgroundcolor” for the listings _without_ the white lines. Also I found an answer on tex.sx… But my listings are always striped… :-(

Leave a Reply