Search code examples
matlabplotfontslatexaxis-labels

MATLAB plot - use standard font and latex font in xlabel


When generating MATLAB plots, I use:

plot(x,y)
xlabel('$x$','Interpreter','Latex')

Then, x is displayed in the Latex font.

Now I want both, normal text and maths symbol as xlabel, say: time (t). So, the word time should be a standard font (say the MATLAB font when I don't use an interpreter) and the symbol t in brackets should be in the Latex font. But my attempts like:

xlabel('$\mathrm{time} (t)$','Interpreter','Latex')
xlabel('$\text{time} (t)$','Interpreter','Latex')
xlabel('time ($t$)','Interpreter','Latex')

all failed. Any ideas on how to mix the standard font with Latex font for xlabel in MATLAB?


Solution

  • The standard MATLAB font seems to be Arial, so when using the Latex interpreter I specified the text font with setting the x- and the y-labels as

    xlabel('{\fontfamily{Arial}\selectfont Time} $t$', 'Interpreter',"latex");
    
    ylabel('{\fontfamily{Arial}\selectfont Efficiency} $\varepsilon$', 'Interpreter',"latex");
    

    Like this I can have the \varepsilon as well as the standard font.