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

I have created the following example with CairoMakie.jl:

using CairoMakie, LaTeXStrings

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


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.

1 Like

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.

What do you mean by that?

If I don’t use LaTeX, I get

using CairoMakie, LaTeXStrings

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


Now, the title looks bigger.

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

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.

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.

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).

I also made the following plot

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)

There is another thing: letters are smaller than numbers:

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?

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

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

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?

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

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.

Was it abandoned?

Were there some principal problems preventing it from integration?

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.