1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| \lstset{ basicstyle = \sffamily, % 基本代码风格 keywordstyle = \bfseries, % 关键字风格 commentstyle = \rmfamily\itshape, % 注释的风格,斜体 stringstyle = \ttfamily, % 字符串风格 flexiblecolumns, % 别问为什么,加上这个 numbers = left, % 行号的位置在左边 showspaces = false, % 是否显示空格,显示了有点乱,所以不现实了 numberstyle = \zihao{-5}\ttfamily, % 行号的样式,小五号,tt等宽字体 showstringspaces = false, captionpos = t, % 这段代码的名字所呈现的位置,t指的是top上面 frame = lrtb, % 显示边框 }
\lstdefinestyle{Python}{ language = Python, % 语言选Python basicstyle = \zihao{-5}\ttfamily, numberstyle = \zihao{-5}\ttfamily, keywordstyle = \color{blue}, keywordstyle = [2] \color{teal}, stringstyle = \color{magenta}, commentstyle = \color{red}\ttfamily, breaklines = true, % 自动换行,建议不要写太长的行 columns = fixed, % 如果不加这一句,字间距就不固定,很丑,必须加 basewidth = 0.5em, }
\appendix \section{附录1}
\lstinputlisting[ style = Python, caption = {\bf 标题}, label = {part1.R} ]{part1.txt}
|