# Change Verbatim Font To PCR

I'm writing a document using LaTeX, and I would like to use the PCR font inside of a verbatim block. This question is almost identical to mine, but when I try to apply it to use PCR, I can't get it to work.

This is what I am trying:

% From the question I linked above:
\makeatletter
\newcommand{\verbatimfont}[1]{\def\verbatim@font{#1}}%
\makeatother

...

\verbatimfont{pcr}
\begin{verbatim}
This should be in pcr.
\end{verbatim}


It simply outputs:

pcrThis should be in pcr.

It works fine with \verbatimfont{\scshape}, but I can't get it to work with an actual custom font. Do I need to make my own \pcr command to achieve this?

-

pcr is the family name, it is used with \fontfamily, e.g.:

\documentclass{article}

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

\begin{document}
\verbatimfont{\fontfamily{pcr}\selectfont}
\begin{verbatim}
This should be in pcr.
\end{verbatim}
\end{document}


Or

\documentclass{article}

\makeatletter
\newcommand{\verbatimfontfamily}[1]{%
\def\verbatim@font{\fontfamily{#1}\selectfont}%
}%
\makeatother

\begin{document}
\verbatimfontfamily{pcr}
\begin{verbatim}
This should be in pcr.
\end{verbatim}
\end{document}


Or with a \pcr command:

\documentclass{article}

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

\newcommand*{\pcr}{\fontfamily{pcr}\selectfont}

\begin{document}
\verbatimfont{\pcr}
\begin{verbatim}
This should be in pcr.
\end{verbatim}
\end{document}


-
Ah! Thanks. That worked magnificently. It says I can accept the answer in 10 minutes. :D I like that modification to the original command, too. – Jonn Apr 21 '14 at 13:22

Verbatim environments and macros in the verbatimbox package accept optional arguments that can change the font, font size, etc.

\documentclass{article}
\usepackage{verbatimbox}
\begin{document}
\begin{verbnobox}[\scriptsize]
Testing scriptsize cmtt verbatim
\end{verbnobox}
\begin{verbnobox}[\fontfamily{pcr}\selectfont]
Testing pcr verbatim
\end{verbnobox}
\end{document}


-
Thanks! I'll have to look into that package. I've seen it around, but I haven't tried it. – Jonn Apr 21 '14 at 13:33