[Tex/LaTex] Change typeface of verbatim environment

fontstypefacesverbatim

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!

\documentclass[a4paper]{article}
\usepackage{titling}
\newcommand{\subtitle}[1]{%
  \posttitle{%
    \par\end{center}
    \vskip5em
    \begin{center}\LARGE#1\end{center}
    \vskip5em}%
}

\usepackage{palatino}
\usepackage[utf8x]{inputenc}
\usepackage[top=1in,bottom=1in,left=1in,right=1in]{geometry}
\usepackage{indentfirst}
\usepackage{lipsum}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{booktabs,multirow} 
\usepackage{amsmath,amssymb}
\usepackage{xcolor}
\usepackage{cite}

\begin{document}

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

\end{document}

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

\makeatletter
\newcommand{\verbatimfont}[1]{\def\verbatim@font{#1}}%
\makeatother

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

enter image description here

\documentclass{article}
\usepackage{verbatim}% http://ctan.org/pkg/verbatim
\makeatletter
\newcommand{\verbatimfont}[1]{\def\verbatim@font{#1}}%
\makeatother

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

\begin{document}
\verbatiminput{file.tex}

\verbatimfont{\itshape\ttfamily}
\verbatiminput{file.tex}

\verbatimfont{\scshape}
\verbatiminput{file.tex}

\end{document}