2026-10-26 18:31:04 +08:00
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
%% code listings
|
|
|
|
|
|
%% 代码块设定
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
\RequirePackage{listings,verbatim}
|
|
|
|
|
|
|
2026-10-26 22:50:19 +08:00
|
|
|
|
% 代码配色不在这里定义,统一来自 cls/color.cls:
|
|
|
|
|
|
% codecolorkeywords = 海大蓝 codecolorcomments = 苍松绿
|
|
|
|
|
|
% codecolorstrings = 海大红 codecolortypes = 海大天蓝
|
|
|
|
|
|
% codecolorframe = 专银 codecolorbg = 极浅中性底
|
2026-10-26 18:31:04 +08:00
|
|
|
|
|
|
|
|
|
|
\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,
|
2026-10-26 22:50:19 +08:00
|
|
|
|
rulecolor=\color{codecolorframe},
|
2026-10-26 18:31:04 +08:00
|
|
|
|
abovecaptionskip=0pt,
|
|
|
|
|
|
belowcaptionskip=5pt,
|
|
|
|
|
|
aboveskip=5pt,
|
2026-10-26 22:50:19 +08:00
|
|
|
|
backgroundcolor=\color{codecolorbg},
|
2026-10-26 18:31:04 +08:00
|
|
|
|
% Code design
|
|
|
|
|
|
keywordstyle=\color{codecolorkeywords},
|
|
|
|
|
|
commentstyle=\color{codecolorcomments},
|
|
|
|
|
|
stringstyle=\color{codecolorstrings},
|
2026-10-26 22:50:19 +08:00
|
|
|
|
numberstyle=\small\color{oucmuted},
|
2026-10-26 18:31:04 +08:00
|
|
|
|
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}
|
|
|
|
|
|
|
2026-10-26 22:50:19 +08:00
|
|
|
|
%% 命令行(bash 示例):浅海大蓝底 + 粗左侧海大蓝竖线
|
2026-10-26 18:31:04 +08:00
|
|
|
|
\lstdefinestyle{bashstyle}{
|
2026-10-26 22:50:19 +08:00
|
|
|
|
backgroundcolor=\color{oucblue!10!white},
|
2026-10-26 18:31:04 +08:00
|
|
|
|
basicstyle=\linespread{1.2}\ttfamily,
|
|
|
|
|
|
keepspaces=true,
|
|
|
|
|
|
numbers=none,
|
|
|
|
|
|
numbersep=10pt,
|
|
|
|
|
|
frame=l,
|
|
|
|
|
|
framerule=2pt,
|
|
|
|
|
|
framesep=5pt,
|
|
|
|
|
|
framexleftmargin=3pt,
|
|
|
|
|
|
framextopmargin=-5pt,
|
|
|
|
|
|
xleftmargin=10pt,
|
2026-10-26 22:50:19 +08:00
|
|
|
|
rulecolor=\color{oucblue},
|
2026-10-26 18:31:04 +08:00
|
|
|
|
% Code
|
|
|
|
|
|
tabsize=4,
|
|
|
|
|
|
showspaces=false,
|
|
|
|
|
|
showstringspaces=false,
|
|
|
|
|
|
showtabs=false,
|
|
|
|
|
|
breaklines=true,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-26 22:50:19 +08:00
|
|
|
|
%% 命令行输出:中性极浅底 + 专银左侧竖线
|
|
|
|
|
|
% 说明:输出是"机器吐出来的东西",语义上不该比命令更醒目,
|
|
|
|
|
|
% 所以颜色比 bashstyle 退一档,用专银而不是海大蓝。
|
2026-10-26 18:31:04 +08:00
|
|
|
|
\lstdefinestyle{bashoutputstyle}{
|
2026-10-26 22:50:19 +08:00
|
|
|
|
backgroundcolor=\color{codecolorbg},
|
2026-10-26 18:31:04 +08:00
|
|
|
|
basicstyle=\linespread{1.2}\ttfamily,
|
|
|
|
|
|
keepspaces=true,
|
|
|
|
|
|
numbers=none,
|
|
|
|
|
|
numbersep=10pt,
|
|
|
|
|
|
frame=l,
|
|
|
|
|
|
framerule=2pt,
|
|
|
|
|
|
framesep=5pt,
|
|
|
|
|
|
framexleftmargin=3pt,
|
|
|
|
|
|
framextopmargin=-5pt,
|
|
|
|
|
|
xleftmargin=10pt,
|
2026-10-26 22:50:19 +08:00
|
|
|
|
rulecolor=\color{codecolorframe},
|
2026-10-26 18:31:04 +08:00
|
|
|
|
% Code
|
|
|
|
|
|
tabsize=4,
|
|
|
|
|
|
showspaces=false,
|
|
|
|
|
|
showstringspaces=false,
|
|
|
|
|
|
showtabs=false,
|
|
|
|
|
|
breaklines=true,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%% 代码列表标题
|
|
|
|
|
|
\RequirePackage{caption}
|
|
|
|
|
|
\DeclareCaptionFormat{codecaptionformat}{%
|
|
|
|
|
|
%%\colorbox{black!20}{
|
|
|
|
|
|
%% \parbox{\textwidth}{#1#2\ttfamily#3}
|
|
|
|
|
|
%%}
|
2026-10-26 22:50:19 +08:00
|
|
|
|
\parbox{\textwidth}{\textcolor{ouccaption}\faCode~\textcolor{ouccaption}{#1#2}\hspace{.5em}\fzkai#3}
|
2026-10-26 18:31:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
\captionsetup[lstlisting]{format=codecaptionformat}
|