latex - 如何为 LaTeX 列表创建黑底白字样式

标签 latex listings typesetting

我一直在查看 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 以使文本显示为白色,因此它可能是你的观众?我正在使用 xdvixpdf

\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/

相关文章:

CSS:内联标题的行高会扰乱行间距

c# - 用.NET排版文本

graphics - 如何查看 Functional MetaPost 的输出 .mp 文件

latex 纸尺寸

Latex 列表字符串和关键字

列表中的数学符号

r - 从 R 中的 ftable 对象创建 latex 表

latex - 在 LaTeX 中处理行间距

latex - 更改 "List of Listings"文本

html - 用于打印的 3 个文本 div 的最佳布局