如何在latex中插入程序源码
来源:互联网 发布:日用品数据分析网站 编辑:程序博客网 时间:2024/05/16 09:41
在宏包listings中提供lstinputlisting命令,及lstlisting环境。
\usepackage{listings}
\lstinputlisting{asianbin.m}
or
\begin{lstlisting}
put your code here
\end{lstlisting}
为了更好的显示源代码,可以添加如下设置命令
\lstset{ %
extendedchars=false,
language=Matlab,
basicstyle=\footnotesize\tt,
tabsize=3,
numbers=left,
numberstyle=\tiny,
stepnumber=1,
numbersep=5pt,
keywordstyle=\color[rgb]{0,0,1},
commentstyle=\color[rgb]{0.133,0.545,0.133},
stringstyle=\color[rgb]{0.627,0.126,0.941},
backgroundcolor=\color{white}, % choose the background color. Youmust add \usepackage{color}
showspaces=false,
showstringspaces=false,
showtabs=false,
frame=single,