\documentclass{article}
%%%%%%%%%%%%% C++ Code
\usepackage{color}
\usepackage{xcolor}
\definecolor{keywordcolor}{rgb}{0.8,0.1,0.5}
\usepackage{listings}
\lstset{breaklines}%这条命令可以让LaTeX自动将长的代码行换行排版
\lstset{extendedchars=false}%这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题
\lstset{language=C++, %用于设置语言为C++
keywordstyle=\color{keywordcolor} \bfseries,
identifierstyle=,
basicstyle=\ttfamily,
commentstyle=\color{blue} \textit,
stringstyle=\ttfamily,
showstringspaces=false,
%frame=shadowbox, %边框
captionpos=b
}
%%%%%%%%%%%%% C++ Code
\title{AC Machine}
\author{Boat}
\begin{document}
\maketitle
\begin{lstlisting}
/*
**ac_automation: multipattern match algorithm
*input: n patterns and string
*output: all the patterns that appear in the string
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
return 0;
}
\end{lstlisting}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%beamer\documentclass{beamer}
\usetheme{Berkeley}
%%%
\usepackage{color}
\usepackage{xcolor}
\definecolor{keywordcolor}{rgb}{0.8,0.1,0.5}
\usepackage{listings}
\lstset{breaklines}%这条命令可以让LaTeX自动将长的代码行换行排版
\lstset{extendedchars=false}%这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题
\lstset{language=C++, %用于设置语言为C++
keywordstyle=\color{keywordcolor} \bfseries, %设置关键词
identifierstyle=,
basicstyle=\ttfamily,
commentstyle=\color{blue} \textit,
stringstyle=\ttfamily,
showstringspaces=false,
%frame=shadowbox, %边框
captionpos=b
}
%%%
\begin{document}
\begin{frame}[fragile]
\frametitle{C Code Show}
\begin{lstlisting}
int main(int argc, char *argv[])
{
int i;
return 0;
}
\end{lstlisting}
\end{frame}
\end{document}
posted on 2012-10-16 20:55
lixiucheng 阅读(5765)
评论(0) 编辑 收藏 引用