# Which font am I using

I am creating many figures for my LaTeX document using matplotlib with `'text.usetex': True`.

My full preamble looks like this:

``````rc('font', **{'family':'serif', 'serif':['Computer Modern Roman']})
params = {'backend': 'pdf',
'axes.labelsize': 12,
'text.fontsize': 12,
'legend.fontsize': 12,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'text.usetex': True,
'figure.figsize': fig_size,
'axes.unicode_minus': True}
matplotlib.rcParams.update(params)
``````

In the plot I also use `\texttt{}`, which should match the formatting in the latex document. However it doesnt (compare legend and caption, both 12pt).

I assume I have to add something like `'family':'typewriter', 'typewriter':['Some font']`. So my questions:

• how can I find out which font and weight is used in the LaTeX document for `\texttt`
• How to tell matplotlib to use the exact same font
-
–  Torbjørn T. Aug 15 '12 at 10:01

Matplotlib apparently uses Courier as default, my LaTeX uses Computer Modern Typewriter.

I found some font specification examples here.

So changing the first line of my preamble to

``````rc('font', **{'family':'serif', 'serif':['Computer Modern Roman'],
'monospace': ['Computer Modern Typewriter']})
``````

renders the `\texttt{}` the same way LaTeX does.

-