-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcpphighlight.sty
46 lines (43 loc) · 2.26 KB
/
cpphighlight.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
\usepackage{listings}
\usepackage{xcolor}
% 定义可能使用到的颜色
\definecolor{CPPLight} {HTML} {686868}
\definecolor{CPPSteel} {HTML} {888888}
\definecolor{CPPDark} {HTML} {262626}
\definecolor{CPPBlue} {HTML} {4172A3}
\definecolor{CPPGreen} {HTML} {487818}
\definecolor{CPPBrown} {HTML} {A07040}
\definecolor{CPPRed} {HTML} {AD4D3A}
\definecolor{CPPViolet} {HTML} {7040A0}
\definecolor{CPPGray} {HTML} {B8B8B8}
\newcommand*{\framemargin}{3ex}
\lstdefinestyle{mycpp}{
columns=fixed,
numbers=left, % 在左侧显示行号
frame=trbl, % 不显示背景边框
showtabs=true,
tab=,
tabsize=2,
backgroundcolor=\color[RGB]{245,245,244}, % 设定背景颜色
keywordstyle=\color[RGB]{40,40,255}, % 设定关键字颜色
numberstyle=\footnotesize\color{darkgray}, % 设定行号格式
commentstyle=\it\color[RGB]{0,96,96}, % 设置代码注释的格式
stringstyle=\rmfamily\slshape\color[RGB]{128,0,0}, % 设置字符串格式
showstringspaces=false, % 不显示字符串中的空格
language=c++, % 设置语言
morekeywords={alignas,continute,friend,register,true,alignof,decltype,goto,
reinterpret_cast,try,asm,defult,if,return,typedef,auto,delete,inline,short,
typeid,bool,do,int,signed,typename,break,double,long,sizeof,union,case,
dynamic_cast,mutable,static,unsigned,catch,else,namespace,static_assert,using,
char,enum,new,static_cast,virtual,char16_t,char32_t,explict,noexcept,struct,
void,export,nullptr,switch,volatile,class,extern,operator,template,wchar_t,
const,false,private,this,while,constexpr,float,protected,thread_local,
const_cast,for,public,throw,std},
emph={map,set,multimap,multiset,unordered_map,unordered_set,
unordered_multiset,unordered_multimap,vector,string,list,deque,
array,stack,forwared_list,iostream,memory,shared_ptr,unique_ptr,
random,bitset,ostream,istream,cout,cin,endl,move,default_random_engine,
uniform_int_distribution,iterator,algorithm,functional,bing,numeric,},
emphstyle=\color{CPPViolet},
}
\lstnewenvironment{cpp}[1][]{\lstset{style=mycpp}}{}