Can I change the latex font using LatexString package?

My computer is Mac OX m1. I use the package LatexSting to render the latex. This is the code and output figure. I was wondering if I can change the font of latex. However, I don’t want to change the font of text because I think it is OK.

using Plots
using LaTeXStrings
x = -2*π:0.01:2*π
y = @. sin(x)


default(tickfontsize=12, guidefontsize=13,
        legendfontsize=12)
plot(x, y)
xlabel!(L"$xxx$ variable")
ylabel!(L"YY\pi")

plot

There are a few open issues on the LatexStrings and related packages. Currently the only font that’s supported is CM Serif, unfortunately.

So I use either of these solutions:

  1. use the PGFPlotsX backend for Plots.jl. Creates LaTeX figures, which, if you use LaTeX, will use the fonts you use in the LaTeX document. You can also choose fonts and export to pdf/svg or png.

  2. change the main figure font to CM Serif, but you state that you like to use the sans serif font, so that may not be an option for you.

  3. don’t use LatexStrings, but use the unicode symbols - this works fine if all you need are, e.g., \alpha, or such.

  4. as 3.) but also use HTML super- and subscript features. This requires the use of an HTML backend, like PlotlyJS, but you can export to png or svg:

Screenshot from 2023-04-05 16-03-00

plotlyjs()

plot(x,y, xlabel="test α<sup>2</sup>")

Plots.svg("plot.svg")
Plots.png("plot.png")