插入程序代码
传统一点, \usepackage{listings}
, 详情可以使用texdoc listings
查看。
\lstset{language=C}
\begin{lstlisting}
#include <iostream>
using namespace std;
int main()
{
cout<<"hello"<<endl;
return 0;
}
\end{lstlisting}
对效果进行一些定制:
\usepackage{
listings}
\usepackage{
xcolor}
\lstset{
numbers=left,
numberstyle= \tiny,
keywordstyle= \color{
blue!70},
commentstyle= \color{
red!50!green!50!blue!50},
frame=shadowbox, % 阴影效果
rulesepcolor=