我正在尝试让间距和字体在lstlisting
输出窗口中看起来干净整洁。现在,如果我启用该columns=fullflexible
选项,它会使字体真正等宽,并且完美对齐括号。不幸的是,这会使字体在输出文本时看起来很糟糕。
另一方面,如果我禁用此选项,字体看起来会好得多,但括号会完全错位。
有没有办法可以兼得两全其美,即对齐括号,但没有大的无字距调整问题?
口粮:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{newtxtext, pifont, newtxmath, tcolorbox}
\renewcommand{\ttfamily}{\fontencoding{T1}\fontfamily{lmtt}\selectfont}
\tcbuselibrary{listings, skins, breakable}
\lstdefinelanguage{Scheme}{
columns=fullflexible, % <--- Disabling this gets the bad font but proper bracket alignment
sensitive=true,
basicstyle=\scriptsize\ttfamily,
keywordstyle=\ttfamily\color[rgb]{0,.3,.7},
frameshape={RYR}{Y}{Y}{RYR}
}
\title{Font Tests}
\begin{document}
\maketitle
Here is some text without the typewriter font. \texttt{Here is some using it.} Below is code in a verbatim block.
\begin{verbatim}
(define value-of-function
(lambda (exp env)
\end{verbatim}
\begin{lstlisting}[language=Scheme]
(define value-of-function
(lambda (exp env)
(let ([name (cadr exp)]
[formals (get-formals (cddr exp))]
[body (list (get-body exp))])
...)))
\end{lstlisting}
\end{document}