tmdxyz 发表于 2021-4-22 07:24
楼主可否给一段代码例子,以便我们小白学习?谢谢。
定义.cls文件时,
% 导入 LaTeX 宏包
\
RequirePackage{listings}%排版程序源代码
% 设置宏包 listings/lstlistings
\lstset{tabsize=4,
language=R, %
frame=none, %把代码用带有阴影的框圈起来
backgroundcolor=\color[RGB]{240,240,240},%背景
commentstyle=\tiny, %小字注释
%rulesepcolor=\color{red!20!green!20!blue!20}, %代码块边框为淡青色
keywordstyle=\color{black}, %代码关键字的颜色为蓝色,粗体
showstringspaces=false, %不显示代码字符串中间的空格标记
stringstyle=\ttfamily, % 代码字符串的特殊格式
keepspaces=true,
breakindent=22pt,
numbers=left, %左侧显示行号
stepnumber=1,
numberstyle=\scriptsize, %行号字体用小号
basicstyle={\footnotesize\ttfamily},
showspaces=false,
flexiblecolumns=true,
breaklines=true, %对过长的代码自动换行
breakautoindent=true,
breakindent=4em,
aboveskip=1em, %代码块边框
fontadjust,
captionpos=t,
framextopmargin=1pt,framexbottommargin=1pt,abovecaptionskip=-9pt,belowcaptionskip=9pt,
xleftmargin=2em,xrightmargin=1em, % 设定listing左右的空白
texcl=true,
% 设定中文冲突,断行,列模式,数学环境输入,listing数字的样式
extendedchars=false,columns=flexible,
mathescape=false
numbersep=-1em,
morekeywords={in, TRUE, FALSE, filter, group, color, size}
}