|
From: Michael D. <md...@st...> - 2013-05-03 13:17:51
|
On 05/02/2013 03:16 PM, Paul Hobson wrote:
>
> On Thu, May 2, 2013 at 11:19 AM, Michael Droettboom <md...@st...
> <mailto:md...@st...>> wrote:
>
> I think the confusion here stems from the fact that you're mixing
> TeX and non-TeX font commands.
>
> This turns on TeX mode, so all of the text is rendered with an
> external TeX installation:
>
> rc('text', usetex=True)
>
> In this line, setting it to sans-serif will get passed along to
> TeX, but a specific ttf font name can not be used by TeX, so the
> second part (involving Helvetica) is ignored. And setting the
> default body text in TeX does not (by default) change the math
> font. This is (unfortunately standard TeX behavior).
>
> rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
>
> This affects the font set used by matplotlib's internal mathtext
> renderer, and has no effect on TeX:
>
> rc('mathtext', fontset='stixsans')
>
> The solution I use when I want all sans-serif out of TeX is to use
> the cmbright package, which can be turned on by adding:
>
> rc('text.latex', preamble=r'\usepackage{cmbright}')
>
> That may require installing the cmbright LaTeX package if you
> don't already have it.
>
> I know all this stuff is confusing, but providing a flat interface
> over both the internal text rendering and the TeX rendering isn't
> really possible -- they have different views of the world -- and
> I'm actually not sure it's desirable. Though I wonder if we
> couldn't make it more obvious (somehow) when the user is mixing
> configuration that applies to the different contexts.
>
> Mike
>
>
> Mike,
>
> Thanks for the guidance. I know this stuff is complicated and the work
> everyone has put into it to make it work is fantastic.
>
> I now see that this was more of TeX issue than an MPL configuration
> issue. Your help prompted me to find this solution (similar to yours):
> mpl.rcParams['text.latex.preamble'] = [
> r'\usepackage{siunitx}', # i need upright \micro symbols, but
> you need...
> r'\sisetup{detect-all}', # ...this to force siunitx to
> actually use your fonts
> r'\usepackage{helvet}', # set the normal font here
> r'\usepackage{sansmath}', # load up the sansmath so that math
> -> helvet
> r'\sansmath'] # <- tricky! -- gotta actually tell tex to use!
Wow. That's some serious TeX voodoo magic! Want to work that into an
example that we could include in the docs?
Cheers,
Mike
|