Chinaunix首页 | 论坛 | 博客
  • 博客访问: 162149
  • 博文数量: 33
  • 博客积分: 2530
  • 博客等级: 少校
  • 技术积分: 580
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-25 16:03
文章分类
文章存档

2011年(1)

2010年(2)

2009年(17)

2008年(13)

我的朋友

分类: LINUX

2009-02-04 15:04:39

(转载)
The Listings package
 

Main Page:

The listings package is a source code printer for LATEX. You can typeset stand alone files as well as listings with an environment similar to verbatim as well as you can print code snippets using a command similar to \verb. Many parameters control the output and if your preferred programming language isn’t already supported, you can make your own definition.

Example:

  1. \documentclass[a4paper,10pt]{article}
  2. \usepackage{fancybox}
  3. \usepackage{listings}
  4. \usepackage{xcolor}
  5. \usepackage{times}
  6. \begin{document}
  7. \section{Counting Numbers of Uppercase Characters}
  8. \begin{center}
  9. \begin{lstlisting}[language={[ANSI]C},
  10. numbers=left,
  11. numberstyle=\tiny,
  12. basicstyle=\small\ttfamily,
  13. stringstyle=\color{purple},
  14. keywordstyle=\color{blue}\bfseries,
  15. commentstyle=\color{olive},
  16. directivestyle=\color{blue},
  17. frame=shadowbox,
  18. %framerule=0pt,
  19. %backgroundcolor=\color{pink},
  20. rulesepcolor=\color{red!20!green!20!blue!20}
  21. %rulesepcolor=\color{brown}
  22. %xleftmargin=2em,xrightmargin=2em,aboveskip=1em
  23. ]
  24. /*===================================================
  25. * FileName: counter.c
  26. * Author : Shaobin Li
  27. * Date : 2007-09-13
  28. * Description: count numbers of uppercase
  29. * characters from input streams, and output
  30. * the numbers respectively.
  31. *=================================================*/
  32. #include
  33. #include
  34. #include
  35. #define SIZE 26
  36. int
  37. main (int argc, char *argv[])
  38. {
  39. int array[SIZE];
  40. int i;
  41. char c;
  42. for (i = 0; i < SIZE; i++)
  43. array[i] = 0;
  44. while ((c = getchar ()) != EOF)
  45. {
  46. if (isupper (c))
  47. {
  48.    array[c - 'A']++;
  49. }
  50. }
  51. for (i = 0; i < 26; i++)
  52. printf ("%c:%5d\n", (char) ('A' + i), array[i]);
  53. return 0;
  54. }
  55. \end{lstlisting}
  56. \end{center}
  57. \end{document}

阅读(1501) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

cuichaox2009-10-28 11:43:44

mark