Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

\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,

share|improve this question
    
What do you want to change it to? –  Werner Feb 5 at 19:44
    
\ttfamily show bigger than default font. –  Onur Sigirci Feb 5 at 19:48

3 Answers 3

The most reliable way is to change the font definitions, applying a magnification factor. I'll do it for the T1 encoding, with a magnification factor of 1.1. Below the similar code for the OT1 encoding.

\documentclass[11pt]{book}
\usepackage[T1]{fontenc}

\makeatletter
\expandafter\let\csname T1/cmtt/m/n/10.95\endcsname\relax
\begingroup
\nfss@catcodes
\DeclareFontFamily{T1}{cmtt}{\hyphenchar \font\m@ne}
\DeclareFontShape{T1}{cmtt}{m}{n}{
        <-9>    s*[1.1] ectt0800
        <9-10>  s*[1.1] ectt0900
        <10-12> s*[1.1] ectt1000
        <12-17> s*[1.1] ectt1200
        <17->   s*[1.1] ectt1728
      }{}
\DeclareFontShape{T1}{cmtt}{m}{it}{
        <-9>    s*[1.1] ecit0800
        <9-10>  s*[1.1] ecit0900
        <10-12> s*[1.1] ecit1000
        <12-17> s*[1.1] ecit1200
        <17->   s*[1.1] ecit1728
      }{}
\DeclareFontShape{T1}{cmtt}{m}{sl}{
        <-9>    s*[1.1] ecst0800
        <9-10>  s*[1.1] ecst0900
        <10-12> s*[1.1] ecst1000
        <12-17> s*[1.1] ecst1200
        <17->   s*[1.1] ecst1728
      }{}
\DeclareFontShape{T1}{cmtt}{m}{sc}{
        <-9>    s*[1.1] ectc0800
        <9-10>  s*[1.1] ectc0900
        <10-12> s*[1.1] ectc1000
        <12-17> s*[1.1] ectc1200
        <17->   s*[1.1] ectc1728
      }{}
\DeclareFontShape{T1}{cmtt}{bx}{n}
       {<->sub  cmtt/m/n}{}
\DeclareFontShape{T1}{cmtt}{bx}{it}
       {<->sub  cmtt/m/it}{}
\DeclareFontShape{T1}{cmtt}{bx}{sl}
       {<->sub  cmtt/m/sl}{}
\DeclareFontShape{T1}{cmtt}{b}{n}
       {<->sub  cmtt/m/n}{}
\DeclareFontShape{T1}{cmtt}{b}{it}
       {<->sub  cmtt/m/it}{}
\DeclareFontShape{T1}{cmtt}{b}{sl}
       {<->sub  cmtt/m/sl}{}
\endgroup
\makeatother

\begin{document}
abc\texttt{def}ghi

\fontencoding{OT1}\selectfont
abc\texttt{def}ghi
\end{document}

The second line is just to show the difference with the original appearance. Apply the magnification factor you think best.

enter image description here

If you prefer sticking with OT1, then you should use the following code:

\makeatletter
\begingroup
\nfss@catcodes
\DeclareFontFamily{OT1}{cmtt}{\hyphenchar \font\m@ne}
\DeclareFontShape{OT1}{cmtt}{m}{n}{
        <-9>    s*[1.1] cmtt8
        <9-10>  s*[1.1] cmtt9
        <10-12> s*[1.1] cmtt10
        <12->   s*[1.1] cmtt12
      }{}
\DeclareFontShape{OT1}{cmtt}{m}{it}{
        <->     s*[1.1] cmitt10
      }{}
\DeclareFontShape{OT1}{cmtt}{m}{sl}{
        <->     s*[1.1] cmsltt10
      }{}
\DeclareFontShape{OT1}{cmtt}{m}{sc}{
        <->     s*[1.1] cmtcsc10
      }{}
\DeclareFontShape{OT1}{cmtt}{m}{ui}
       {<->ssub*cmtt/m/it}{}
\DeclareFontShape{OT1}{cmtt}{bx}{n}
       {<->ssub*cmtt/m/n}{}
\DeclareFontShape{OT1}{cmtt}{bx}{it}
       {<->ssub*cmtt/m/it}{}
\DeclareFontShape{OT1}{cmtt}{bx}{ui}
       {<->ssub*cmtt/m/it}{}
\endgroup
\makeatother
share|improve this answer

If you are willing to change the font, you can use a scalable font for ttfamily.

\documentclass[11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[scaled=0.8]{beramono}

\begin{document}
abc\texttt{def}ghi

\end{document}

enter image description here

share|improve this 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.

share|improve this answer
    
Thanks for your help –  Onur Sigirci Feb 5 at 19:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.