在导言区加上这段代码,可以解决提到的所有问题,顺便把我发现的关键字数量不够的问题也解决了
`definecolor{matlab}{RGB}{0,100,0}
definecolor{lingo}{RGB}{128,0,128}
definecolor{darkgreen}{RGB}{0,100,0}
definecolor{mylightgreen}{RGB}{160,180,160}
lstnewenvironment{matlabcode}[1][]
{
lstset{
language=Matlab,
basicstyle=\small\ttfamily,
columns=fullflexible,
keywordstyle=\color{blue}\bfseries,
commentstyle=\color{darkgreen},
stringstyle=\color{matlab},
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
showstringspaces=false,
numbers=left,
numberstyle=\tiny\color{gray},
#1
}
}{}
lstdefinelanguage{LINGO}{%
morekeywords={model, end, sets, endsets, data, enddata, calc, endcalc, init, endinit,
@bin, @gin, @bnd, @free, @sum, @for, @sqr, @sqrt, @exp, @ole, @text,
@abs, @sin, @cos, @tan, @log, @sign, @smax, @smin, @floor, @lgm,
@mod, @pow, @psn, @pps, @pbn, @phg, @pfd, @pcx, @ptd, @rand, @qrand, @peb, @pel, @ppl, @pfs, @psl,
@max, @min, @prod, @in, @size, @index, @wrap},
sensitive=false,
morecomment=[l]{!},
morecomment=[s]{/}{/},
morestring=[b]",
}
lstnewenvironment{lingocode}[1][]
{
lstset{
language=Lingo,
basicstyle=\small\ttfamily,
columns=fullflexible,
keywordstyle=\color{blue}\bfseries,
commentstyle=\color{mylightgreen},
stringstyle=\color{lingo},
breaklines=true,
breakatwhitespace=false,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
showstringspaces=false,
numbers=left,
numberstyle=\tiny\color{gray},
#1
}
}{}`
问 在本站下载的数学建模竞赛论文模板中lstlisting环境不会调参数