\ DocumentClass [UTF . 8 ] Article This article was} { \ usepackage {listings} \ {usepackage Color, xcolor} \ {fontspec usepackage} \ usepackage xeCJK} { \ setmonofont [the Mapping = {}] {%} Monaco quotes like normal display, the equivalent of the English font settings \ setsansfont Monaco} { % set English font Monaco, Consolas, Fantasque Sans Mono \ setmainfont Monaco} { % set English font \ setCJKmainfont {Microsoft elegant black} % Chinese font settings % \ setCJKsansfont {italics}% Chinese font set % \ setCJKmonofont {}% provided Chinese character \ definecolor mygreen {} {} {RGB 0 , 0.6 , 0 } \ {mygray definecolor} {} {RGB 0.5 ,0.5 , 0.5 } \ definecolor {mymauve} {RGB} { 0.58 , 0 , 0.82 } \ lstset { backgroundColor = \ Color {White},% the Choose The background Color basicstyle = \ footnotesize \ Monaco,% size of Fonts Used for The code or changed \ small \ monaco slightly larger than a numbers = left,% set the line number numberstyle = \ Tiny \ monaco,% set the font size for the line number the Columns = fullflexible, breaklines = to true ,% Automatic line Breaking only AT whitespace captionposB =,% The sets caption- position to bottom TabSize = . 4 , from 4% to tab expansion spaces, the default is 8 too commentstyle = \ mygreen Color {},% set annotation color escapeinside = {\% *} { *)},% IF you want to the Add LaTeX WITHIN your code keywordstyle = \ color {Blue},% set keyword color stringstyle = \ color {mymauve} \ Monaco,% String literal style frame = SINGLE,% is provided with a border rulesepcolor = \ Color Red {! 20 is ! Green! 20 is ! Blue! 20 is }, % Identifierstyle = \ Color {Red}, Language = C ++ , } \ the begin {Document} \ the begin {lstlisting} inline int GCD ( int A, int B) { // If a <b, recursively obtain gcd (b, a % b) i.e. gcd (b, a), i.e. the exchange position, the time complexity of 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 \ Document End {}