lstlisting中的双破折号

7
我在Latex中使用lstlisting命令。我想要使用双破折号"--help",但是Latex连字符会像正常文本一样连接(但这是源代码),我无法使用"-{}-"进行分离。
\begin{lstlisting} 
  $ oc <command> --help
\end{lstlisting}

Could you help me please? Thanks


2
这可能属于TeX StackExchange。它与此帖子相关:http://tex.stackexchange.com/questions/140216/how-to-avoid-double-dash-seem-as-a-continuous-line - Arya McCarthy
1个回答

12

考虑到您正在使用类似终端的代码显示方式,请将 basicstyle 设置为 \ttfamily

在此输入图片描述

\documentclass{article}

\usepackage{listings}
\lstset{basicstyle=\ttfamily}

\begin{document}

\begin{lstlisting} 
$ oc <command> --help
\end{lstlisting}

\end{document}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接