listings-ext
我在 Ubuntu 11.10(带有 LyX)上使用它并listings.cfg
定义了样式colored-code
- 我在 LaTeX 序言中也使用了它:
\usepackage[style=colored-code]{listings-ext}
但每当我尝试将文档编译成 DVI 或 PDF 时,我都会得到以下信息:
\newcommand
{\lstdef}[3]{%
The following styles weren't loadable:
,colored-code$
This may cause errors in the sequel.
并出现一条消息“包列表错误:样式彩色代码未定义”。
我怎样才能解决这个问题?
listings.cfg 的内容如下:
\lstdefinestyle{colored-code}{
backgroundcolor=\color{yellow!10},%
basicstyle=\footnotesize\ttfamily,%
identifierstyle=\color{black},%
keywordstyle=\color{blue},%
stringstyle=\color{teal},%
commentstyle=\itshape\color{orange},%
}
答案1
我刚刚尝试过:
\documentclass[a4paper, 11pt]{article}
\usepackage[style=colored-code]{listings-ext}
\begin{document}
test
\end{document}
例如listings.cfg
:
\ProvidesFile{listings.cfg}%
[2009/08/23 v1.0 listings configuration of listings-ext]
\RequirePackage{xcolor}
\def\lstlanguagefiles{lstlang1.sty,lstlang2.sty,lstlang3.sty}
\lstset{defaultdialect=[ANSI]C,
defaultdialect=[ISO]C++,
defaultdialect=[95]Fortran,
defaultdialect=Java,
defaultdialect=[LaTeX]TeX,
frame=tlb,
resetmargins=false,
}
\lstdefinestyle{colored-code}{
backgroundcolor=\color{yellow!10},%
basicstyle=\footnotesize\ttfamily,%
identifierstyle=\color{black},%
keywordstyle=\color{blue},%
stringstyle=\color{teal},%
commentstyle=\itshape\color{orange},%
}
\lstdefinestyle{bw-code}{
basicstyle=\small\fontfamily{lmtt}\fontseries{m}\fontshape{n}\selectfont,
% instead of lmtt one should use ul9 (luximono) for boldface characters
keywordstyle=\small\fontfamily{lmtt}\fontseries{b}\fontshape{n}\selectfont,
commentstyle=\small\fontfamily{lmtt}\fontseries{m}\fontshape{sl}\selectfont,
stringstyle
=\small\fontfamily{lmtt}\fontseries{m}\fontshape{it}\selectfont,
}
并且编译时没有任何错误。我认为你listings.cfg
错了。