[Tex/LaTex] What configuration do you propose for listings.sty to make the output look comfortable

listingssubjective

The objective of this topic is to make a common place where we can share our settings for listings.sty. So we can use this as a reference.

Note that I am only interested in the following settings:

  1. font family, font size, font weight, font color
  2. background color

In other words, the layout such as frame, line numbers, etc must not be taken into account here.

The rule of the game:

  1. Use the following code snippet as the template. Only modify the lines marked with %<==. NOTE: Please leave the font size unchanged. I already set it to \scriptsize.

    \documentclass[dvips,dvipsnames]{article}
    \usepackage[a4paper,margin=55mm]{geometry}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{listings}
    \lstset%
    {%
    language={[Sharp]C},
    breaklines=true,
    breakindent=0pt,
    tabsize=2,
    showstringspaces=true
    }
    
    %=================================
    %Rule of the Game:
    %You are ONLY allowed  to 
    %modify the lines marked with %<==
    %=================================   
    \usepackage[rgb]{xcolor}%<==    
    \lstset
    {%
      backgroundcolor=%
      \color{Black},%<==
      %
      basicstyle=\scriptsize%leave the font size unchanged please.
      \color{lightgray}\ttfamily,%<==
      %
      keywordstyle=%
      \color{Orange}\sffamily,%<==
      %
      commentstyle=%
      \color{Green},%<==
      %
      identifierstyle=%
      \color{Cyan},%<==
      %
      stringstyle=%
      \color{Yellow}%<== 
    }  
    \begin{document}
    \begin{lstlisting}
    using System;
    public class Foo
    {
     public static void Main()
     {
            Console.WriteLine("I Love LaTeX");//This is a comment.
     }
     /*This is a comment too.*/
    }
    \end{lstlisting}
    \end{document}
    
  2. View the pdf output in 150% scale and make a screenshot of it in *.png format.

  3. Submit your screenshot followed by your modified settings (NOT complete code please). You can submit as many as you want but make sure you don't make a duplication.

Best Answer

I prefer to go for simpler designs, both on the web as well as for printed works. Too much color confuses the reader and to paraphrase Bringhurst it is an intrusion. alt text

rather highligh the point of discussion than the whole code. Code must read like a paragraph! Also I prefer generally environments rather than macros on their own and so here is my minimal!

\gdef\emphasis#1{\lstset{emph={write,void,writeln,#1},
   emphstyle={\itshape\ttfamily\textcolor{blue}}}}

\lstnewenvironment{teXXX}[1][]
  {\lstset{language=[LaTeX]TeX}\lstset{%
      breaklines=true,
      framesep=5pt,
      basicstyle=\normalsize\ttfamily,
      showstringspaces=false,
      keywordstyle=\itshape,
      stringstyle=\color{maroon},
     commentstyle=\color{black},
     rulecolor=\color{Gray},
     xleftmargin=0pt,
     xrightmargin=5pt,
     aboveskip=\medskipamount,
     belowskip=\medskipamount,
      backgroundcolor=\color{LightGray!5}, #1
}}
{}