我一直在查看 Philip Bunge 在 how to create a "Tango" style with LaTeX listings 上的帖子,并尝试对此进行调整,使默认文本样式变为白色,背景变为黑色(这是针对幻灯片,而不是文章!)。这是我添加的:
\definecolor{Black}{gray}{0.0}
\definecolor{White}{gray}{0.9}
...
\lstset{
basicstyle=\color{White},
backgroundcolor=\color{Black},
...
}
这假设 basicstyle
设置所有文本的默认样式。列表文档是这样说的:
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.
此输出仍将“默认”文本显示为黑色。可以设置more样式指令来覆盖给定编程语言中的大多数标记,但即使这样做,也会丢失一些标记(例如括号和其他标点符号)。我做错了什么?
最佳答案
以下代码对我有用,但我将 .dvi
文件转换为 .pdf
以使文本显示为白色,因此它可能是你的观众?我正在使用 xdvi
和 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}
希望对您有所帮助!
关于latex - 如何为 LaTeX 列表创建黑底白字样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3132966/