# Makie: mismatch between LaTeX and non-LaTeX font sizes

**URL:** <https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [August 20, 2021, 1:42pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734 "2021-08-20T13:42:30Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [August 20, 2021, 1:42pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/1 "2021-08-20T13:42:30Z")

</div>

I have created the following example with `CairoMakie.jl`:

```julia
using CairoMakie, LaTeXStrings

xs = 0.0:0.01:2.0
lines(xs, sin.(π.*xs), axis=(title=L"\sin{x}",))

```

 ![example](https://global.discourse-cdn.com/julialang/original/3X/d/0/d09909a3d3cb981ba3be06f05bd990505899265b.png)

According to the documentation, the font sizes for title and tick labels are all the same and equal to 16. I have not specified the fontsizes in the provided example, so the default values are used. **Why the size of the title is noticeably smaller than the size of the ticklables?** The only difference is that the title was generated from LaTeX.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 20, 2021, 2:26pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/2 "2021-08-20T14:26:35Z")

</div>

Could either be that the font size we get from latex plots is wrong, or that the latex font just has smaller glyphs. Both are possible. Could you check how normal text looks if you set it to the latex font? It is somewhere in MathTeXEngine I think.

---

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [August 20, 2021, 2:37pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/3 "2021-08-20T14:37:20Z")

</div>

> [@jules](#):
>
> Could you check how normal text looks if you set it to the latex font?

What do you mean by that?

If I don’t use LaTeX, I get

```julia
using CairoMakie, LaTeXStrings

xs = 0.0:0.01:2.0
lines(xs, sin.(π.*xs), axis=(title="sin(x)",))

```

 ![example](https://global.discourse-cdn.com/julialang/original/3X/c/f/cfe3cb1aa7e1a97f7664268a35ef131e6b36c95b.png)  
Now, the title looks bigger.

Can you recreate it on your machine? I am using `v0.6.3` of `CairoMakie`.

---

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [August 20, 2021, 2:56pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/4 "2021-08-20T14:56:57Z")

</div>

Actually, if I change `titlesize` in my example, the size of the LaTeX output is changed as well. The problem is, the precise scaling factor between LaTeX and non-LaTeX text is unknown.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 20, 2021, 4:33pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/5 "2021-08-20T16:33:09Z")

</div>

I want to know if the latex font itself is so much smaller than dejavu sans. So you could find the path to the font file in MathTeXEngine and use it for a normal text label, then compare to the dejavu version.

---

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [August 20, 2021, 5:02pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/6 "2021-08-20T17:02:47Z")

</div>

I produced two pdfs and magnified them to do the comparison. The left one is base font, the right one — MathTeXEngine font.  
The sizes are the same (Of course, these are different fonts, so the sizes are a tiny bit different).

 ![Screenshot_20210820_190133](https://global.discourse-cdn.com/julialang/original/3X/8/3/83f7df74c8081969b54e4c6fcf3f10b2de1187b9.png)

---

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [August 20, 2021, 6:30pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/7 "2021-08-20T18:30:27Z")

</div>

I also made the following plot

```julia
using CairoMakie, LaTeXStrings

xs = 0.0:0.01:2.0
lines(xs, sin.(π.*xs), axis=(title=L"12345\sin{(x)}",yticklabelfont = "~/.julia/packages/MathTeXEngine/b206G/assets/fonts/NewCM-Regular.otf"))

```

I added numbers to LaTeX generated title, and switched the yticklabelfont to MathTeXEngine font.  
Here is a comparison of numbers in the title (left) with numbers from ytick label (right)

 ![Screenshot_20210820_202430](https://global.discourse-cdn.com/julialang/original/3X/b/8/b85869bf7d9599eeaa8ee08b543781e68b1aba44.png)  
There is another thing: letters are smaller than numbers:  
 ![Screenshot_20210820_203002](https://global.discourse-cdn.com/julialang/original/3X/b/1/b13f67103040c30870f093a33ad7a36d6b33f8c5.png)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 20, 2021, 6:34pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/8 "2021-08-20T18:34:14Z")

</div>

that doesn’t seem to be the right font, given that the 1 looks different. Can you find the same font and see if there’s a size difference?

---

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [August 20, 2021, 6:53pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/9 "2021-08-20T18:53:48Z")

</div>

Yeah, you are right, I mixed things up.  
Here is comparison between text with base Makie font (left) and text with MathTeXEngine font (right)

 ![Screenshot_20210820_205038](https://global.discourse-cdn.com/julialang/original/3X/c/b/cba8ee0d474b84b187aac6a073bb94d77a8db9e2.png)

Here is comparison between text with MathTeXEngine font (left) and processed LaTeXString (right).

 ![Screenshot_20210820_204526](https://global.discourse-cdn.com/julialang/original/3X/8/c/8c572b62efd395f12e901016db3aca0e5874a46e.png)

So, MathTeXEngine symbols are smaller, and then the text itself is smaller than the numbers.  
May I also ask a somewhat stupid question: do you know why MathTeXEngine does not use LaTeX directly?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 20, 2021, 7:14pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/10 "2021-08-20T19:14:54Z")

</div>

Ok so the font is just smaller. Which means that one needs to increase the font size to match other content, or maybe the font can be switched to one that is comparable in size to other fonts like dejavu.

MathTeXEngine is an approximation of LateX because that is really slow, you need at least half a second for one equation. So that would make it impossible to use math in interactive scenarios. There is also MakieTeX which adds “real” LaTeX but I’m not sure if it still works, and it’s not as nicely integrated to use it for labels etc

---

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [August 20, 2021, 7:22pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/11 "2021-08-20T19:22:19Z")

</div>

> [@jules](#):
>
> MathTeXEngine is an approximation of LateX because that is really slow, you need at least half a second for one equation.

I guess, for interactive use it makes sense. If it is interactive use, you don’t need everything to look perfect  
On the other hand, if you want to produce the plots for a scientific publication, you don’t care about the speed much, but the quality means everything.

> [@jules](#):
>
> There is also MakieTeX which adds “real” LaTeX but I’m not sure if it still works

Was it abandoned?

> [@jules](#):
>
> and it’s not as nicely integrated to use it for labels etc

Were there some principal problems preventing it from integration?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [August 20, 2021, 7:34pm UTC](https://discourse.julialang.org/t/makie-mismatch-between-latex-and-non-latex-font-sizes/66734/12 "2021-08-20T19:34:03Z")

</div>

Always a question of time and needs. If people want something, they build it. I haven’t kept track of MakieTeX but I’ve seen it work. Integrating it so that you can just do `ax.label = something_triggering_makietex` is much more work that seemingly hasn’t been worth it to anybody so far.
