views:

80

answers:

1

I've been looking at Philip Bunge's post on how to create a "Tango" style with LaTeX listings, and trying to adapt this to make the default text style white and the background black (this is for slides, not an article!). This is what I added:

\definecolor{Black}{gray}{0.0}
\definecolor{White}{gray}{0.9}
...
\lstset{
  basicstyle=\color{White},
  backgroundcolor=\color{Black},
  ...
}

This assumes that basicstyle sets the default style of all text. The listings documentation says this:

basicstyle is selected at the beginning of each listing. You could use \footnotesize, \small, \itshape, \ttfamily, or something like that. The last token of must not read any following characters.

The output of this still shows "default" text as black. It is possible to set more style directives that cover most tokens in a given programming language, but even doing this some tokens (such as brackets and other punctuation) will be missed. What did I do wrong?

A: 

The following code worked for me, but I converted the .dvi file to a .pdf in order to have the text appear as white, so it might have been your viewer? I'm using xdvi and xpdf.

\documentclass[a4paper, 11pt]{article}
\usepackage{listings}
\usepackage{color}
\definecolor{theWhite}{gray}{0.9}
\definecolor{theBlack}{gray}{0.0}
\lstset { basicstyle=\color{theWhite}, backgroundcolor=\color{theBlack} }
\begin{document}
\begin{lstlisting}
((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
\end{lstlisting}
\end{document}

I hope that helps!

emptyset
Thanks for this, and is sort of helps! You're using article, I was using Beamer; you were writing lambda-calculus, I was writing Python; so you're answering a slightly different question than the one I asked. Otherwise, there are only two differences between your code and mine, one is that you used gray rather than rgb to define white / black (this doesn't seem to make any difference) and secondly you are not using the rest of the "tango" style from the blog post I linked. It seems to be the stuff in tango that's causing the problem, rather than Beamer, XDVI, Python or anything else.
snim2
OK, a bit more digging and I've found the issue, there was already a \basicstyle directive in Philip Bunge's stuff and I stupidly missed it. D'OH. Thanks for your help.
snim2
No problem! I haven't used Latex since college so it was fun to dive back into it, even briefly!
emptyset