[Tex/LaTex] All \ttfamily font change font size

fontsizetypewriter

\documentclass[11pt]{book}

This code shows default font size.
I want to change font size all \ttfamily font in document (only for \ttfamily font). Other fonts not change.

How can I do?
Thanks,

Best Answer

You can update the definition of \ttfamily to include the font changes that you need. For example, below \ttfamily has been updated to always use \LARGE (say). Here is the default definition of \ttfamily from latex.ltx:

\DeclareRobustCommand\ttfamily
        {\not@math@alphabet\ttfamily\mathtt
         \fontfamily\ttdefault\selectfont}

Here is an updated version in the form of a minimal example:

enter image description here

\documentclass[11pt]{article}
\makeatletter
% Definition of \ttfamily from latex.ltx
\DeclareRobustCommand\ttfamily
        {\not@math@alphabet\ttfamily\mathtt
         \fontfamily\ttdefault\LARGE\selectfont}
\makeatother
\begin{document}
Some normal text.

{\ttfamily Some typewriter text.\par}

Some normal and \texttt{typewriter} text.
\end{document}

The above example also shows why this should not be done.