5

I am trying to match the font between the line that says: reg [8:0] data_saved [0:3]; // memory declaration

and the rest of the lines that are inside lstlisting. Here is what I get:

enter image description here

My code looks like this:

\documentclass [11pt] {article}
\usepackage{epsfig}
\usepackage{enumitem}
\usepackage{url}
\usepackage{epstopdf}
\usepackage{listings}
\input std-defs
\input EECE2323-header
\begin{document}
\noindent
\lab{3}{LAB3 - Arithmetic and Logic Unit Part II and Register File}

    \texttt{reg [8:0] data\_saved [0:3]; // memory declaration }

and then initialize its values with the \texttt{initial} declaration:


\begin{lstlisting}[xleftmargin=10em]
// Initialize Inputs Stimulus
initial
  begin
     data_saved[0] = 9'b000000001;
     data_saved[1] = 9'b000000010;
     data_saved[2] = 9'b000000011;
     data_saved[3] = 9'b000000100;
     end
\end{lstlisting}


\textbf{Use alu\_reg\_file\_tb.v as your Testbench template.}

\end{document}

But if I try to add \texttt to the lstlisting than I just see the word \texttt in the text.

Any ideas? Thanks!

  • 6
    Add the options basicstyle=\ttfamily and columns=fullflexible to \lstset. – egreg Apr 5 '15 at 23:42
  • @egreg, I added the options you mentioned and I see no change in the pdf.. – Tlalit Apr 6 '15 at 17:02
  • 2
    @Tlalit In that case please incorporate it into the example, so that we see what exactly is going on. – yo' Apr 6 '15 at 17:20
8

You should have a \lstset instruction in your preamble:

\documentclass [11pt] {article}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{url}
\usepackage{epstopdf}
\usepackage{listings}
%\input std-defs
%\input EECE2323-header

\lstset{
  basicstyle=\ttfamily,
  columns=fullflexible,
}

\begin{document}

%\noindent
%\lab{3}{LAB3 - Arithmetic and Logic Unit Part II and Register File}

    \texttt{reg [8:0] data\_saved [0:3]; // memory declaration }

and then initialize its values with the \texttt{initial} declaration:


\begin{lstlisting}[xleftmargin=10em]
// Initialize Inputs Stimulus
initial
  begin
     data_saved[0] = 9'b000000001;
     data_saved[1] = 9'b000000010;
     data_saved[2] = 9'b000000011;
     data_saved[3] = 9'b000000100;
     end
\end{lstlisting}


\textbf{Use alu\_reg\_file\_tb.v as your Testbench template.}

\end{document}

I have commented out the parts that I can't use (the two \input instructions and the line with the \lab macro), but for the rest I didn't touch the file, apart from changing the call to epsfig into the call to graphicx. The former package is obsolete and should not be used in new documents.

enter image description here

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.