0

How can I get a portion of my document that uses the listings package to display in the font that is used in alltt?

Right now I have

\begin{lstlisting}[language = SAS]
proc hpsplit data = autompg2 seed = 123 plots = zoomedtree(nodes = ("0") depth = 2 
     fracprec = 2 predictorprec = 2);
  class origin cylinders;
 model mpg = cylinders displacement weight acceleration year origin;
   output out=mpgout;
    rules file = "\path\mpgrule.txt";
run;

proc means data = mpgout;
 class _NODE_;
 var MPG;
run;
\end{lstlisting}
  • How about {\ttfamily...} ? – Werner Jul 26 '18 at 15:24
  • Thanks for the quick response. Where would I put that? I will add a code sample to my question. – Peter Flom - Reinstate Monica Jul 26 '18 at 15:26
  • 3
    \lstset{basicstyle=\ttfamily} – moewe Jul 26 '18 at 15:35
  • 4
    Try adding the option basicstyle = \ttfamily to the options for your lstlisting environment (or add \lstset{basicstyle = \ttfamily} to your preamble. – Werner Jul 26 '18 at 15:35
  • 1
    @siracusa Added an answer. I'd also be fine with closing as a duplicate, but a (admittedly short) search did not reveal anything except tex.stackexchange.com/q/174892/35864. – moewe Oct 20 '18 at 17:42
2

You can get typewriter font in listings with basicstyle = \ttfamily. To enable this setting globally, you can use

\lstset{basicstyle=\ttfamily}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.