使用 listing 包,我尝试使用以下代码模拟 Matlab R2016a 环境:
\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[breaklinks=true]{hyperref}
\usepackage{multirow,array}
\usepackage{listings}
\lstdefinestyle{matlab}{
language = Matlab,
basicstyle = \small,
breaklines = true,
numbers = left,
numberstyle = \small,
stepnumber = 1 --,
commentstyle = \color{green!90!black!95}
}
\begin{document}
\begin{lstlisting}[style=matlab]
% Pregunta 1
N = 500;
n = 0:N-1;
x = sin(5*pi*n/358);
p = seqperiod(x)
\end{lstlisting}
\end{document}
在图中您可以看到破折号是如何出现在顶部的,这是通过放置“stepnumber = 1- -”给出的,但这是我发现的唯一可以生成破折号的东西。
有没有办法从顶部删除这些破折号,或者是否有其他选项可以在代码中生成这些破折号?
答案1
这有帮助吗?
\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[breaklinks=true]{hyperref}
\usepackage{multirow,array,xcolor}
\usepackage{listings}
\lstdefinestyle{matlab}{
language = Matlab,
basicstyle = \small,
breaklines = true,
numbers = left,
numberstyle = \small,
stepnumber = 1,
commentstyle = \color{green!90!black!95}
}
\renewcommand\thelstnumber{\arabic{lstnumber}--}
\begin{document}
\begin{lstlisting}[style=matlab]
% Pregunta 1
N = 500;
n = 0:N-1;
x = sin(5*pi*n/358);
p = seqperiod(x)
\end{lstlisting}
\end{document}
正如Andreas Matthias
他已经指出的这个建议comment
....