LaTeX Bold Typewriter Font

From Exterior Memory
Jump to: navigation, search

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:

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

\texttt{Normal and \textbf{bold Typewriter.}}


Different Font for Monospace using TFM Fonts

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


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:


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:

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

Instead of:

\setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\setmonofont[SmallCapsFont={* Caps}]{Latin Modern Mono}
Personal tools