# LaTeX Bold Typewriter Font

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In LaTeX, normal typewriter and bold typewriter (bold monospaced) font look the same.

This is a property of the standard LaTeX typewriter font, Computer Modern, which is also inherited by derivates of Computer Modern such as Latin Modern and Computer Modern Unicode.

The solution is to change the font variant that is associated with typewriter bold. This can be done by either changing the font variant of the typewriter bold series, or by simply changing the whole font for the typewriter family. The details of using a different font altogether depends if you use TFM fonts (regular LaTeX) or OpenType/TrueType fonts (using xetex/fontspec).

## Change the Monospace Bold Variant

If you use Latin Modern:

\DeclareFontFamily{T1}{lmtt}{}
\DeclareFontShape{T1}{lmtt}{m}{n}{<-> ec-lmtl10}{}
\DeclareFontShape{T1}{lmtt}{m}{\itdefault}{<-> ec-lmtlo10}{}
\DeclareFontShape{T1}{lmtt}{\bfdefault}{n}{<-> ec-lmtk10}{}
\DeclareFontShape{T1}{lmtt}{\bfdefault}{\itdefault}{<-> ec-lmtko10}{}


(source: An exploration of the Latin Modern fonts by Will Robertson)

If you use Computer Modern, you can declare cmttb10 as a boldface version of cmtt and then use it with the standard \texttt and \textbf commands:

\documentclass{article}
\DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}
\begin{document}
\texttt{Normal and \textbf{bold Typewriter.}}
\end{document}


## Different Font for Monospace using TFM Fonts

To change the font for Monospace series, use \renewcommand:

\renewcommand{\ttdefault}{pcr}


The above sets the font to pcr, which is commonly know as Courier. The courier package does exactly this, but in a much more readable and user-friendly way:

\usepackage{courier}


## Different Font for Monospace using OpenType/TrueType Fonts

If you use TrueType fonts, simply choose a TrueType fonts which has better distinction between plain and bold. If you use Computer Modern, it is recommended to use Latin Modern, as it contains a Light and Dark variant, so that the distinction between plain and bold is more clear.

For example:

\usepackage{fontspec}
\setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\setmonofont[SmallCapsFont={Latin Modern Mono Caps}]{Latin Modern Mono Light}


\usepackage{fontspec}