floyd123
floyd123

Reputation: 31

How to italicize a portion of a plot label while keeping the sans-serif font?

Currently I have this: Current plot

I would only like a portion of a label, say c/R_p [-], to be italicized.

This is what I do in MATLAB to get the above upper x-label:

xlabel(ax2, '{\fontfamily{cmss}\selectfont Chord $\mathsf{c/R_p} \, \textsf[-]$}', 'Interpreter', 'latex');

I tried combining \mathsf with \mathit, but, depending on who I use first, either I get no italics or I get italics but in the standard latex font (hence, I lose sans-serif). I know this can be done somehow, as here they managed to do it: What I'm trying to achieve

Thanks for your help!

Upvotes: 1

Views: 360

Answers (1)

Wolfie
Wolfie

Reputation: 30047

With the tex interpreter, you can just use the \it{} command to make italic text:

xlabel( 'Radial Coordinate \it{c/R}', 'Interpreter', 'tex' );
ylabel( 'Pitch Angle \beta [deg]', 'Interpreter', 'tex' );

Note that this uses a sans-serif font (the default font for non-tex labels).

plot with tex labels

Alternatively you can use the latex interpreter which gives you more powerful LaTeX rendering. Note that LaTeX-rendered equations are in italics by default, so just having your italic characters as inline equations like $this$ will cause them to be italicised. The default LaTeX font will be used, which has serifs.

xlabel( 'Radial Coordinate $c/R$', 'Interpreter', 'latex' );
ylabel( 'Pitch Angle $\beta$ [deg]', 'Interpreter', 'latex' );

plot with LaTeX labels

Upvotes: 0

Related Questions