使用 listings.sty 修复标点符号(如逗号和句号)的空格

使用 listings.sty 修复标点符号(如逗号和句号)的空格

我的标签如下:

\documentclass{book}
\usepackage{listings}

\lstset{
    language=java, emph={},
    mathescape=false, escapechar=`,
%   backgroundcolor=\color{lightgray},
    commentstyle=\color{darkgray},
    keywordstyle=\color{darkergray}\bfseries,
    basicstyle=\normalsize\sffamily,
    numberstyle=\normalsize\sffamily,
    emphstyle=\bfseries,
    numbers=left, stepnumber=1,
    numberblanklines=false,
    %numberstyle=\tiny,
    numbersep=3pt,
    frame=none, framexleftmargin=3pt, framexrightmargin=0pt,
    %xleftmargin=15pt, xrightmargin=4pt,
    columns=flexible, breaklines=true,
    showspaces=false, showstringspaces=false, showtabs=false, tabsize=2,
    escapeinside={(*@}{@*)},
    morekeywords={grammar, lambda, define, car, cdr, cons, null?, list,
    let, fork, lock, unlock  },
}
\begin{document}

\begin{lstlisting}[numbers=none]
"Nail is missing..."
"For want of a nail, the shoe was lost."
"For want of a shoe, the horse was lost."
"For want of a horse, the rider was lost."
"For want of a rider, the message was lost."
"For want of a message, the battle was lost."
"For want of a battle, the kingdom was lost."
"And all for the want of a horseshoe nail."
\end{lstlisting}

\end{document}

输出

在此处输入图片描述

句号和逗号等标点符号前的空格显示不均匀,我已经知道如果我们改变columns=fullflexible就会解决这个问题,但出于某种原因我应该使用columns=flexible,但需要修复标点符号是否符合标准?可以修复吗?请指教...

至少需要修复间距问题commaperiod这是一个可选的......

相关内容