博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LaTeX使用listings宏包插入代码时,将代码字体设为 Monaco
阅读量:6985 次
发布时间:2019-06-27

本文共 1944 字,大约阅读时间需要 6 分钟。

\documentclass{article}\usepackage{listings}\usepackage{fontspec}\newfontfamily\monaco{Monaco}\begin{document}\begin{lstlisting}[language={[ANSI]C},        numbers=left,        numberstyle=\tiny\monaco,        basicstyle=\small\monaco]#include 
#include
#include
#define SIZE 26intmain (int argc, char *argv[]){ int array[SIZE]; int i; char c; for (i = 0; i < SIZE; i++) array[i] = 0; while ((c = getchar ()) != EOF) { if (isupper (c)) { array[c - 'A']++; } } for (i = 0; i < 26; i++) printf ("%c:%5d\n", (char) ('A' + i), array[i]); return 0;}\end{lstlisting}\end{document}复制代码
\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 colorbasicstyle=\footnotesize\monaco, % size of fonts used for the code或改成\small\monaco稍大numbers=left,						 % 设置行号numberstyle=\tiny\monaco,			 % 设置行号字体大小columns=fullflexible,breaklines=true,                 % automatic line breaking only at whitespacecaptionpos=b,                    % sets the caption-position to bottomtabsize=4,commentstyle=\color{mygreen},    % 设置注释颜色escapeinside={\%*}{*)},          % if you want to add LaTeX within your codekeywordstyle=\color{blue},       % 设置keyword颜色stringstyle=\color{mymauve}\monaco,     % string literal styleframe=single,						 % 设置有边框rulesepcolor=\color{red!20!green!20!blue!20},% identifierstyle=\color{red},language=c++,}\begin{document}\begin{lstlisting}inline int gcd(int a, int b) { 	// 如果a

转载地址:http://vnqpl.baihongyu.com/

你可能感兴趣的文章
web 学习资源整理
查看>>
make 参数定义
查看>>
数组排序(冒泡和快速)
查看>>
java从字符串中提取数字
查看>>
Cardinality Feedback
查看>>
Android App Build System
查看>>
Python yield与实现
查看>>
终端中的乐趣:6个有趣的Linux命令行工具
查看>>
【技术贴】TOMCAT,Mysql提示Unknown column 'content' in 'fi
查看>>
EBS xml publisher中文乱码
查看>>
ext-anychart饼图呈现取自数据库中的数据
查看>>
Android深入浅出系列之服务机制—1.Android中的Service
查看>>
zz:彻底解决兼容性问题:Windows 7下载安装 Visual C++ 6.0(VC6)
查看>>
MVC、MVP以及Model2[上篇]
查看>>
面试总结,坚定自己的想法
查看>>
数据库隐式类型转换
查看>>
解决WCF调用多次之后没有响应的问题 转
查看>>
【BZOJ2318】【spoj4060】game with probability Problem 概率DP
查看>>
空格&amp;nbsp在不同浏览器中显示距离不一致问题解决方法
查看>>
Nancy 学习-身份认证(Basic Authentication) 继续跨平台
查看>>