Created
February 25, 2017 10:51
-
-
Save walsvid/97fca030e08771cc87ad80491ef12da3 to your computer and use it in GitHub Desktop.
Highlight-C++-LaTeX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
documentclass{ctexart} | |
\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} | |
\lstset{ | |
columns=fixed, | |
numbers=left, % 在左侧显示行号 | |
frame=none, % 不显示背景边框 | |
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}, | |
} | |
\begin{document} | |
{\setmainfont{Courier New Bold} % 设置代码字体 | |
\begin{lstlisting} | |
#include <iostream> | |
#include <array> | |
int main() | |
{ | |
constexpr int MAX = 100; | |
std::array<int, MAX> arr; | |
} | |
\end{lstlisting}} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment