zoukankan      html  css  js  c++  java
  • Latex中插入C代码 [转]

    用LaTeX写论文时,插入C++源代码有专门的宏包,方法如下:

     1 \usepackage{listings}
    2
    3 \lstset{language=C++}%这条命令可以让LaTeX排版时将C++键字突出显示
    4
    5 \lstset{breaklines}%这条命令可以让LaTeX自动将长的代码行换行排版
    6
    7 \lstset{extendedchars=false}%这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题
    8
    9 \begin{lstlisting}
    10
    11 %paste your C++ code here
    12
    13 \end{lstlisting}

      

    下面是我常用的设置:

     1 \lstset{                        %Settings for listings package.
    2 language=[ANSI]{C},
    3 backgroundcolor=\color{lightgray},
    4 basicstyle=\footnotesize,
    5 breakatwhitespace=false,
    6 breaklines=true,
    7 captionpos=b,
    8 commentstyle=\color{olive},
    9 directivestyle=\color{blue},
    10 extendedchars=false,
    11 % frame=single,%shadowbox
    12 framerule=0pt,
    13 keywordstyle=\color{blue}\bfseries,
    14 morekeywords={*,define,*,include...},
    15 numbersep=5pt,
    16 rulesepcolor=\color{red!20!green!20!blue!20},
    17 showspaces=false,
    18 showstringspaces=false,
    19 showtabs=false,
    20 stepnumber=2,
    21 stringstyle=\color{purple},
    22 tabsize=4,
    23 title=\lstname
    24 }


  • 相关阅读:
    Android数据的四种存储方式SharedPreferences、SQLite、Content Provider和File (二) —— SQLite
    理解 Continuation
    99种用Racket说I love you的方式
    Racket Cheat Sheet
    scheme 教程 #lang racket
    开始学习Scheme
    MIT Scheme 的基本使用
    CPS变换
    SECD machine
    scheme 之门
  • 原文地址:https://www.cnblogs.com/longdouhzt/p/2357799.html
Copyright © 2011-2022 走看看