[Matplotlib-users] Set text.latex.preamble in style sheet

Thibaut Appel t.appel17 at imperial.ac.uk
Sat Nov 21 19:18:07 EST 2020


Dear matplotlib developers,

Suppose I define a style sheet 'foo.mplstyle' as

text.usetex : True
font.family  : serif

and setting the LaTeX preamble in the following MWE:

import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["text.latex.preamble"] = r"\usepackage{newpxtext} 
\usepackage{eulervm}"

plt.style.use('foo')

x = np.linspace(0.0,1.0,50)
y = x

plt.plot(x,y)
plt.show()

This works fine with matplotlib 3.3.0.

But the MWE fails when I try to set the LaTeX preamble directly in the 
style sheet. What's the correct syntax for 'text.latex.preamble'? I tried

text.latex.preamble : r"\usepackage{newpxtext} \usepackage{eulervm}"

text.latex.preamble : "\usepackage{newpxtext}, \usepackage{eulervm}"

text.latex.preamble : \usepackage{newpxtext},\usepackage{eulervm}

without success, despite seeing the API change notice 
<https://matplotlib.org/3.3.3/api/prev_api_changes/api_changes_3.3.0.html> 
about the parameter.

System info:

Ubuntu 20.10 Linux 5.8.0-29-generic x86_64
matplotlib 3.3.0 installed with apt
ghostscript 9.52
texlive 2020

Thanks for the support,

Thibaut


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/matplotlib-users/attachments/20201122/23f9fbf3/attachment.html>


More information about the Matplotlib-users mailing list