I like the way the verbatim environment looks, and I want to make my lstlistings look like it.
I've tried setting the basic style to \ttfamily
, but the letter kerning and line spacing seem to be different. Is there any way in getting it look like verbatim?
Here is a complete example:
\documentclass[a4paper]{report}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}
\begin{document}
This is lstlisting:
\begin{lstlisting}
: paxos.learn ( addr n v -- Ethernet packet )
2 paxos.pack32 ( addr n v -- addr payload )
paxos.eth_type.learn ( addr payload -- addr payload ethtype )
swap paxos.eth_packet ; ( addr payload ethtype -- ethernet_packet )
\end{lstlisting}
This is verbatim (and what I want):
\begin{verbatim}
: paxos.learn ( addr n v -- Ethernet packet )
2 paxos.pack32 ( addr n v -- addr payload )
paxos.eth_type.learn ( addr payload -- addr payload ethtype )
swap paxos.eth_packet ; ( addr payload ethtype -- ethernet_packet )
\end{verbatim}
\end{document}
which looks like:
Edit
I tried setting the option columns=flexible
, but then listings will ignore important spaces in the source code.
columns=fullflexible,keepspaces=true
\lstset{basicstyle=\ttfamily, columns=fullflexible, keepspaces=true}
are necessary: PDF and TEX.