Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.
share|improve this question
    
@xport: I think you should classify your question as "community wiki". –  lockstep Jan 4 '11 at 12:12
    
@xport: I didn't mean retagging - there should be another button in the edit window that reads "community wiki". (Or is this something only moderators can do?) –  lockstep Jan 4 '11 at 12:20
    
@lockstep: Yep, it's already been some time that only mods can do that. But I do agree with you. –  Hendrik Vogt Jan 4 '11 at 12:50
    
@xport, @Hendrik: I flagged the question so that mods will see (and hopefully edit) it. –  lockstep Jan 4 '11 at 13:00
    
@lockstep, @Hendrik: I've hit it with the wiki-hammer. –  Loop Space Jan 4 '11 at 13:09

4 Answers 4

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
}}
{}
share|improve this answer

Neon in the dark


\usepackage[rgb]{xcolor}%<==    
\lstset
{%
     backgroundcolor=%
     \color{Black},%<==
     %
     basicstyle=\scriptsize%
     \color{lightgray}\ttfamily,%<==
     %
     keywordstyle=%
     \color{Orange}\sffamily,%<==
     %
     commentstyle=%
     \color{Green},%<==
     %
     stringstyle=%
     \color{Yellow}%<== 
}  

alt text

share|improve this answer

Classic Turbo Pascal (not sure 100%)


\usepackage[cmyk]{xcolor}%<==    
\lstset
{%
     backgroundcolor=%
     \color{Blue},%<==
     %
     basicstyle=\scriptsize%
     \color{White}\ttfamily,%<==
     %
     keywordstyle=%
     \color{Yellow}\sffamily,%<==
     %
     commentstyle=%
     \color{Red},%<==
     %
     stringstyle=%
     \color{Green}%<== 
} 

alt text

share|improve this answer
    
Almost Turbo Pascal, except the code and the blue! –  Yiannis Lazarides Jan 5 '11 at 9:55

Yellowish


\usepackage[rgb]{xcolor}%<==    
\lstset
{%
     backgroundcolor=%
     \color{Yellow!20},%<==
     %
     basicstyle=\scriptsize%
     \color{black}\ttfamily,%<==
     %
     keywordstyle=%
     \color{blue!80}\sffamily,%<==
     %
     commentstyle=%
     \color{OliveGreen},%<==
     %
     stringstyle=%
     \color{red}%<== 
} 

alt text

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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