[Tex/LaTex] Change typeface of verbatim environment


I am new here and the following code is what I am testing. Is it possible to change the typeface of the words from a .txt file? Thank you for any kind help!




\section{Test section}
\subsection{Test section}
\subsubsection{Test section}
\paragraph{Test section}
\setlength{\parindent}{0pt}This document is for testing.


Best Answer

From the verbatim package documentation (section 2.2 The interfaces, p 4):

Let us start with the simple things. Sometimes it may be necessary to use a special typeface for your verbatim text, or perhaps the usual computer modern typewriter shape in a reduced size. You may select this by redefining the macro \verbatim@font. This macro is executed at the beginning of every verbatim text to select the font shape. Do not use it for other purposes; ...

There is no interface provided to change this, so you can include


in your document preamble and then use \verbatimfont{<font>} to set the font as needed. Here's a small example:

enter image description here

\usepackage{verbatim}% http://ctan.org/pkg/verbatim

\usepackage{filecontents}% http://ctan.org/pkg/filecontents
This is some verbatim text in an external file.