Using many typewriter fonts in a single document
If you want to run a test document which includes the typewriter font alongside other styles (e.g. to test how well a particular typewriter font works with a serif used for body text) or you just don't like typing, this example provides a couple of commands for convenience:
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\newcommand*\ttfontstotry{cmtt,cmvtt,lcmtt,lmvtt,pcr,txtt}% add additional families here, separated by commas
\makeatletter
\newcommand*\myttfontstest{% defines the actual test command
\@for \xx:=\ttfontstotry \do {% loops through the families
\par family: \xx\par
\renewcommand*\ttdefault{\xx}%
\input{test}%
}%
}
\makeatother
\begin{filecontents}{test.tex}% just for testing
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
Oh, jinxed quartz of black sphinx, go hear my vow!
{\ttfamily
ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz
Oh, jinxed quartz of black sphinx, go hear my vow!}
\end{filecontents}
\begin{document}
\myttfontstest% try them out!
\end{document}
You can just use the font family without making it the default. For the packages you need to check their documentation the name of the font family used, then use it in the same way.
\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
{\fontfamily{cmtt}\selectfont abcdef 123}
{\fontfamily{cmvtt}\selectfont abcdef 123}
{\fontfamily{lcmtt}\selectfont abcdef 123}
{\fontfamily{lmvtt}\selectfont abcdef 123}
{\fontfamily{pcr}\selectfont abcdef 123}
{\fontfamily{txtt}\selectfont abcdef 123}
\end{document}
David Carlisle's answer is about changing current font. The answer from cfr changes \ttdefault
.
I cannot call my solution complete because I couldn't make it for all the fonts. Looking for font families names took me some time. So I put them in my own answer.
\documentclass[a4paper,11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
% Store the default font
\edef\oldtt{\ttdefault}
% Fonts from packages
\usepackage{ascii}
\usepackage[scale=1.05,ttdefault=true]{AnonymousPro}
\usepackage[scaled=0.84]{beramono}
\usepackage[scaled=1.04]{couriers}
\usepackage[scaled=0.9]{DejaVuSansMono}
\usepackage[defaultmono]{droidmono}
\usepackage[scaled=0.95]{inconsolata}
%\usepackage{kpfonts}
% ! LaTeX Error: Option clash for package textcomp.
%\ifkp@text\ifkp@textcomp\RequirePackage[full]{textcomp}\fi\fi
\usepackage[nomath,notext]{kpfonts}
\usepackage{lmodern}
\usepackage[scaled=0.84]{luximono} % getnonfreefonts luximono
\usepackage[zerostyle=d,scaled=0.96]{newtxtt}
%\usepackage{ocr}
\usepackage[scaled=.93]{newtxtext}
%\usepackage{pxfonts}
%\usepackage{txfonts}
\usepackage{tgcursor}
\usepackage[scaled=0.92]{ulgothic} % getnonfreefonts lettergothic
\usepackage[scaled=1.20,proportional,lightcondensed]{zlmtt}
\addtolength{\voffset}{-1.5cm}
\addtolength{\hoffset}{-2.0cm}
\addtolength{\textheight}{3.0cm}
\addtolength{\textwidth}{4.0cm}
\begin{document}
% The last one
\ttdefault\\ % why do I get zlmvtt?
\input{testtt}
% Back to default
\renewcommand{\ttdefault}{\oldtt}
Default\\
\input{testtt}
pcr\\
{\renewcommand{\ttdefault}{pcr} \input{testtt}}
cmtt\\
{\renewcommand{\ttdefault}{cmtt} \noindent\input{testtt}}
cmvtt\\
{\renewcommand{\ttdefault}{cmvtt} \noindent\input{testtt}}
lcmtt\\
{\renewcommand{\ttdefault}{lcmtt} \noindent\input{testtt}}
lmvtt\\
{\renewcommand{\ttdefault}{lmvtt} \noindent\input{testtt}}
txtt\\
{\renewcommand{\ttdefault}{txtt} \noindent\input{testtt}}
AnonymousPro\\
{\renewcommand{\ttdefault}{AnonymousPro} \noindent\input{testtt}}
Beramono\\
{\renewcommand{\ttdefault}{fvm} \noindent\input{testtt}} % Beramono
% Courier == pcr
Scaled Courier\\
{\renewcommand{\ttdefault}{pcrs} \noindent\input{testtt}} % Scaled Courier
DejaVuSansMono\\
{\renewcommand{\ttdefault}{DejaVuSansMono-TLF} \noindent\input{testtt}}
Droid Mono\\
{\renewcommand{\ttdefault}{fdm} \noindent\input{testtt}} % Droid Mono
Inconsolata\\
{\renewcommand{\ttdefault}{zi4} \noindent\input{testtt}} % inconsolata
KP tt\\
{\renewcommand{\ttdefault}{jkptt} \noindent\input{testtt}} % KP tt
Latin Modern\\
{\renewcommand{\ttdefault}{lmtt} \noindent\input{testtt}} % latin modern
LuxiMono\\
{\renewcommand{\ttdefault}{ul9} \noindent\input{testtt}} % LuxiMono
New TXTT\\
{\renewcommand{\ttdefault}{newtxtt} \noindent\input{testtt}} % New TXTT
% Optical Character Recognition Font B ?
% PX Font tt == TX Fonts == txtt ?
New TX\\
{\renewcommand{\ttdefault}{ntxtt} \noindent\input{testtt}} % New TX
qcr\\
{\renewcommand{\ttdefault}{qcr} \noindent\input{testtt}} % gyre cursor looks like courier ?
Letter Gothic\\
{\renewcommand{\ttdefault}{ulg} \noindent\input{testtt}} % Letter Gothic
zlmtt\\
{\renewcommand{\ttdefault}{zlmtt} \noindent\input{testtt}} % Latin Modern Typewriter Z
ascii\\
{\asciifamily \noindent\input{test}} % No file T1ascii.fd
\end{document}
Fo the testtt.tex
file (File test.tex
for ascii is without {\ttfamily ... }
)
{\ttfamily
Normal {\bfseries Bold}
{\slshape Slanted} {\bfseries\slshape Slanted\&Bold}
{\itshape Italic} {\bfseries\itshape Italic\&Bold}
Z2 lI1 S5 O0}
I get the following font comparison (attention, some fonts are scaled!).