Listings (Lisp) and the > symbol

\documentclass{article}
\usepackage{listings}
\begin{document}
\lstset{language=Lisp,
keywordstyle=\ttfamily\color{keywordcolor},
stringstyle=\ttfamily\color{stringcolor},
identifierstyle=\texttt}
\begin{lstlisting}
(> 3 2)
(a 3 2)
\end{lstlisting}
\end{document}


produces

Notice how the ">" symbol is much larger in this output than it is, say, in the latex file just above. Is there a way to say "just give me the one that looks like it's in the same font as all the other characters in this font"? (Now that I look at it, the numbers seem to be in a different font as well -- less "Courier"-like than I'd expect.)

• Isn't it easier to do basicstyle=\ttfamily than repeating it for every part? Oct 18 '16 at 21:24
• It surely is...but that would have required that I read the whole"listings" doc rather than just editing what someone else had already done. :) Thanks for the tip.
– John
Oct 18 '16 at 22:45

In my opinion it's easier to do basicstyle=\ttfamily than repeating the declaration for each part of the language.

However, you can do it in an indirect way:

\documentclass{article}
\usepackage{listings}

\newcommand{\ttgt}{\texttt{\char\>}}

\lstset{
language=Lisp,
keywordstyle=\ttfamily\color{keywordcolor},
stringstyle=\ttfamily\color{stringcolor},
identifierstyle=\texttt,
literate={>}{\ttgt}1,
}

\begin{document}

\begin{lstlisting}
(> 3 2)
(a 3 2)
\end{lstlisting}

\end{document}


Not sure why preferring numbers in normal font. Here's the other approach:

\documentclass{article}
\usepackage{listings}

\lstset{
language=Lisp,
basicstyle=\ttfamily,
}

\begin{document}

\begin{lstlisting}
(> 3 2)
(a 3 2)
\end{lstlisting}

\end{document}


You need to use a typewriter font that has a nice >, i.e. Source Code Pro:

\documentclass{article}
\usepackage{listings}
\usepackage[default]{sourcecodepro}
\usepackage[T1]{fontenc}
\begin{document}
\lstset{language=Lisp,
keywordstyle=\ttfamily\color{keywordcolor},
stringstyle=\ttfamily\color{stringcolor},
`