我试图在 MATLAB 代码中输入包含我的语言字符的注释,以为它们属于 ANSI 字符,但它们会跳转到注释中的单词开头。
这是代码。我认为它基本上是我从 OverLeaf wiki 获得的示例代码。使用 XeLaTeX 编译。
\documentclass{report}
\usepackage[utf8]{inputenc}
% MATLAB koda bloki
\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{magenta},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
extendedchars=true
}
\lstset{style=mystyle}
\begin{document}
\lstinputlisting[language=Octave]{matlab.m}
\end{document}