# Can I change the latex font using LatexString package?

**URL:** https://discourse.julialang.org/t/can-i-change-the-latex-font-using-latexstring-package/97113
**Category:** Visualization
**Tags:** question
**Created:** [April 5, 2023, 2:06pm UTC](https://discourse.julialang.org/t/can-i-change-the-latex-font-using-latexstring-package/97113 "2023-04-05T14:06:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![quantum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quantum/32/48798_2.png) [@quantum](https://discourse.julialang.org/u/quantum)
#### Post date: [April 5, 2023, 2:06pm UTC](https://discourse.julialang.org/t/can-i-change-the-latex-font-using-latexstring-package/97113/1 "2023-04-05T14:06:55Z")

</div>

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.

```julia
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](https://global.discourse-cdn.com/julialang/original/3X/8/a/8a8f0fe5bc039ae54d0b4a8a579801439718652d.png)

---

<div class="post-metadata">

### Author: ![TS-CUBED](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ts-cubed/32/25292_2.png) [@TS-CUBED](https://discourse.julialang.org/u/TS-CUBED)
#### Post date: [April 5, 2023, 3:09pm UTC](https://discourse.julialang.org/t/can-i-change-the-latex-font-using-latexstring-package/97113/2 "2023-04-05T15:09:55Z")

</div>

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](https://global.discourse-cdn.com/julialang/original/3X/f/9/f906b48a26f18b05d8ae5bedc212b3ddb9ac82a6.png)

```julia
plotlyjs()

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

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

```
