Files
ouc-report-latex-template/cls/code.cls
T
2022-05-15 23:32:13 +08:00

129 lines
3.7 KiB
OpenEdge ABL

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% code listings
%% 代码块设定
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{listings,verbatim}
\definecolor{codecolorkeywords}{rgb}{0,0,1}
\definecolor{codecolorcomments}{rgb}{0,0.5,0}
\definecolor{codecolorxmlcomments}{rgb}{0.5,0.5,0.5}
\definecolor{codecolorstrings}{rgb}{0.64,0.08,0.08}
\definecolor{codecolortypes}{rgb}{0.17,0.57,0.68}
\lstdefinelanguage{JavaScript}{
keywords={do, if, in, for, let, new, try, var, case, else, enum, eval, null, this, true, void, with, await, break, catch, class, const, false, super, throw, while, yield, delete, export, import, public, return, static, switch, typeof, default, extends, finally, package, private, continue, debugger, function, arguments, interface, protected, implements, instanceof},
sensitive=true,
comment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]"
}
\lstdefinelanguage{TypeScript}{
keywords={abstract, break, case, catch, class, const, continue, debugger, default, delete, do, else, enum, export, extends, false, finally, for, function, if, import, in, instanceof, new, null, return, super, switch, this, throw, true, try, typeof, var, void, while, with, as, implements, interface, let, package, private, protected, public, static, yield, any, boolean, constructor, declare, get, module, require, number, set, string, symbol, type, from, of},
sensitive=true,
comment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]"
}
\lstdefinelanguage{golang}{
keywords={break, default, func, interface, select, case, defer, go, map, struct, chan, else, goto, package, switch, const, fallthrough, if, range, type, continue, for, import, return, var},
sensitive=true,
comment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]"
}
\lstdefinestyle{mystyle}{
% Basic design
basicstyle=\linespread{1.2}\ttfamily,
frame=tb,
framesep=5pt,
framerule=.5pt,
framexleftmargin=10pt,
rulecolor=\color{black},
abovecaptionskip=0pt,
belowcaptionskip=5pt,
aboveskip=5pt,
backgroundcolor=\color{black!5!white},
% Code design
keywordstyle=\color{codecolorkeywords},
commentstyle=\color{codecolorcomments},
stringstyle=\color{codecolorstrings},
numberstyle=\small\color{gray},
breakatwhitespace=false,
breaklines=true,
captionpos=t,
keepspaces=true,
% Line numbers
numbers=none,
numbersep=15pt,
xleftmargin=10pt,
stepnumber=1,
firstnumber=1,
numberfirstline=true,
% Code
tabsize=4,
showspaces=false,
showstringspaces=false,
showtabs=false,
breaklines=true,
}
\lstset{style=mystyle}
%% 命令行
\lstdefinestyle{bashstyle}{
backgroundcolor=\color{NavyBlue!10!white},
basicstyle=\linespread{1.2}\ttfamily,
keepspaces=true,
numbers=none,
numbersep=10pt,
frame=l,
framerule=2pt,
framesep=5pt,
framexleftmargin=3pt,
framextopmargin=-5pt,
xleftmargin=10pt,
rulecolor=\color{NavyBlue},
% Code
tabsize=4,
showspaces=false,
showstringspaces=false,
showtabs=false,
breaklines=true,
}
%% 命令行输出
\lstdefinestyle{bashoutputstyle}{
backgroundcolor=\color{black!10!white},
basicstyle=\linespread{1.2}\ttfamily,
keepspaces=true,
numbers=none,
numbersep=10pt,
frame=l,
framerule=2pt,
framesep=5pt,
framexleftmargin=3pt,
framextopmargin=-5pt,
xleftmargin=10pt,
rulecolor=\color{black!70!white},
% Code
tabsize=4,
showspaces=false,
showstringspaces=false,
showtabs=false,
breaklines=true,
}
%% 代码列表标题
\RequirePackage{caption}
\DeclareCaptionFormat{codecaptionformat}{%
%%\colorbox{black!20}{
%% \parbox{\textwidth}{#1#2\ttfamily#3}
%%}
\parbox{\textwidth}{\textcolor{violet}\faCode~\textcolor{violet}{#1#2}\hspace{.5em}\fzkai#3}
}
\captionsetup[lstlisting]{format=codecaptionformat}