zoukankan      html  css  js  c++  java
  • latex的listings宏包常用设置

    documentclass[UTF-8]{article}
    usepackage{listings}
    usepackage{color,xcolor}
    usepackage{fontspec}
    usepackage{xeCJK}
    setmonofont[Mapping={}]{Monaco}    %英文引号之类的正常显示,相当于设置英文字体
    setsansfont{Monaco} %设置英文字体 Monaco, Consolas,  Fantasque Sans Mono
    setmainfont{Monaco} %设置英文字体
    setCJKmainfont{微软雅黑}  %中文字体设置
    %setCJKsansfont{楷体} %设置中文字体
    %setCJKmonofont{} %设置中文字体
    
    definecolor{mygreen}{rgb}{0,0.6,0}
    definecolor{mygray}{rgb}{0.5,0.5,0.5}
    definecolor{mymauve}{rgb}{0.58,0,0.82}
    lstset{
    backgroundcolor=color{white},   % choose the background color
    basicstyle=footnotesizemonaco, % size of fonts used for the code或改成smallmonaco稍大
    numbers=left,                        % 设置行号
    numberstyle=	inymonaco,            % 设置行号字体大小
    columns=fullflexible,
    breaklines=true,                 % automatic line breaking only at whitespace
    captionpos=b,                    % sets the caption-position to bottom
    tabsize=4,                       % 把tab扩展为4个空格,默认是8个太长
    commentstyle=color{mygreen},    % 设置注释颜色
    escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
    keywordstyle=color{blue},       % 设置keyword颜色
    stringstyle=color{mymauve}monaco,     % string literal style
    frame=single,                        % 设置有边框
    rulesepcolor=color{red!20!green!20!blue!20},
    % identifierstyle=color{red},
    language=c++,
    }
    
    egin{document}
    
    egin{lstlisting}
    inline int gcd(int a, int b) { 
        // 如果a<b,则递归得gcd(b,a%b)即gcd(b, a),即交换了位置,时间复杂度O(log max(a, b))
        return b==0?a:gcd(b,a%b)
    }
    inline int lcm(int a, int b) {
        return a/gcd(a,b)*b;
    }
    end{lstlisting}
    
    end{document}
  • 相关阅读:
    用户控件被添加到容器的整个处理过程
    c#项目后期生成事件命令行常用命令
    Sass 系统知识
    非 root 用户
    Linux 系统版本查看
    Docker Swarm
    Docker Compose
    Linux RocketMQ双主双从,Centos7 RocketMQ4集群(双主双从)
    Linux RocketMQ安装配置和使用,Centos7 RocketMQ4安装配置
    Springboot Logback日志使用,Springboot Logback详细配置和日志分割
  • 原文地址:https://www.cnblogs.com/litifeng/p/12174384.html
Copyright © 2011-2022 走看看