使用时mcode.sty,我意识到在带有长注释的换行符处,周围框架的部分会变成绿色,甚至在使用数学公式时会保留为白色,例如在以下示例中:
\documentclass{article}
% load package with ``framed'' and ``numbered'' option.
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}
% something NOT relevant to the usage of the package.
\setlength{\parindent}{0pt}
\setlength{\parskip}{18pt}
\begin{document}
\begin{itemize}
\item The following demo block shows the problems:
\begin{lstlisting}
for i = 1:3
if i >= 5 % literate programming replacement
disp('cool'); % comment with some §\mcommentfont\LaTeX in it: $\mcommentfont\pi x^2$§
end
really really long really really long really really long really really long really really long line % blaaaaaaaa
end
\end{lstlisting}
\end{itemize}
\end{document}
如何才能使镜框颜色均匀呈黑色?
答案1
第一个问题可以很容易地通过在包含之后添加几行代码来解决(我认为这是包 mcode.sty 中的一个错误)\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}
:
\lstset{
rulecolor=\color{black}
}
使用数学公式的问题仍然存在。