リーフラテックスドキュメントにMATLABコードを挿入します(中国語のコメント、キーワードの強調表示付き)



Insert Matlab Code Overleaf Latex Document With Chinese Comments



begin {document}の前に挿入

usepackage{listings} usepackage{xcolor} lstset{ language=Matlab, %The code language uses matlab frame=shadowbox,% enclose the code with a shadow box rulesepcolor=color{red!20!green!20!blue!20},% code block border is light cyan keywordstyle=color{blue!90}fseries, %The color of the code keyword is blue, bold commentstyle=color{red!10!green!70} extit,% Set the color of code comments showstringspaces=false,% do not display the space mark in the middle of the code string numbers=left,% show line numbers numberstyle= iny,% line number font stringstyle= tfamily,% Special format of code string breaklines=true,% automatically wrap lines that are too long extendedchars=false, %Solve the problem that Chinese characters such as chapter titles and headers are not displayed when the code is spread across pages escapebegin=egin{CJK*},escapeend=end{CJK*},% Chinese must be added in the code, otherwise an error will be reported texcl=true} lstset{breaklines}% automatically wrap long lines of code lstset{extendedchars=false}% Solve the problem that Chinese characters such as chapter titles and headers are not displayed when the code is spread across pages

ドキュメント内の目的の位置に挿入します



egin{lstlisting} % Your code end{lstlisting}

結果は次のとおりです。
画像
結果はまだ完璧です~~