我遇到了有关 的一个错误listings
。我已使用该\lstset
命令来配置我的lstlisting
环境。
不知何故,当我的一行太长而无法放入一行时,列表会正确地将其分解,但不知何故,边框的颜色却与字体相同。
这里是\lstset
:
\lstnewenvironment{pascalCode}[1][]
{
\lstset{
backgroundcolor=\color{lightgrey},
breaklines=true,
basicstyle=\footnotesize,
keywordstyle=\color{Blue},
commentstyle=\color{DarkGreen}\textit,
numbers=left,
numberstyle=\footnotesize,
stringstyle=\color{red},
showspaces = false,
showstringspaces = false,
tabsize = 2,
%numbers=left,
%numbersyle=\tiny
frame=single,
xleftmargin=5pt,
xrightmargin=3pt,
language = Pascal,
aboveskip = 20pt,
#1
}
}{}
如果您对如何解决该问题有任何想法,请回复。
答案1
使用选项rulecolor=\color{black}
可以解决这个问题。下面是前和后比较:
代码:
\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstnewenvironment{pascalCode}[1][]
{
\lstset{
backgroundcolor=\color{gray!40},
breaklines=true,
basicstyle=\footnotesize,
keywordstyle=\color{blue},
commentstyle=\color{green}\textit,
numbers=left,
numberstyle=\footnotesize,
stringstyle=\color{red},
showspaces = false,
showstringspaces = false,
tabsize = 2,
%numbers=left,
%numbersyle=\tiny
frame=single,
xleftmargin=5pt,
xrightmargin=3pt,
language = Pascal,
aboveskip = 20pt,
rulecolor=\color{black},
#1
}
}{}
\begin{document}
\begin{pascalCode}
(*
Some really long line that takes more than one line so lstlistings needs to wrap this line.
*)
\end{pascalCode}
\end{document}