How to italicize a portion of a plot label while keeping the sans-serif font?
    8 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Andrea Improta
 il 3 Giu 2024
  
    
    
    
    
    Commentato: Star Strider
      
      
 il 3 Giu 2024
            Hi, currently I have this:

I would only like a portion of a label, say c/R_p [-], to be italicized. 
This is what I do 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:

Thanks for your help!
0 Commenti
Risposta accettata
  Star Strider
      
      
 il 3 Giu 2024
        A lot of the LaTeX options do not work in MATLAB because many of the font options are not supported.  
That aside, use \it to begin the italicized part and \rm to end it — 
ax2 = axes;
plot(ax2, 1:3, [2.1 5.1 4.1])
% xlabel(ax2, '{\fontfamily{cmss}\selectfont Chord $\mathsf{c/R_p} \, \textsf[-]$}', 'Interpreter', 'latex');
xlabel(ax2, '{Chord $\it{c/R_p} \ [-]\rm$}', 'Interpreter', 'latex');
That works, except for the [—] part.  It may not be possible to make that work as well.  (The font is not sans-serif as well here.  Nevertheless, italicising only a part of the string works as intended.)  
.
4 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Axis Labels in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

