Latex fonts on axis and labels in Makie

I would like to use LaTeX fonts for every text of a Makie figure.
It’s easy to apply them to labels as LaTeXStrings can be used. For other texts, in particular axis tick labels, it a bit less trivial.
I was once told to use this:

using GLMakie 
using MathTeXEngine
Makie.update_theme!( fonts = (regular = texfont(), bold = texfont(:bold), italic = texfont(:italic))) 

This indeeds successfully replaces the fonts by the LaTeX ones and allows to homogenize fonts over a figure that uses LaTeXStrings.
Nevertheless, the installation of MathTeXEngine appears problematic on some machines.
Is there any other workaround in order to activate LaTeX fonts everywhere on a figure?
Thanks!

edit: crossed out the statement about installation of MathTextEngine since it’s not the cause of the problem (see below)

It might be the same under the hood, but I always use the LaTeX theme: Predefined themes | Makie

Does it? It looks like an ordinary Julia package to me, so I wouldn’t expect any problems (and never faced any myself).

2 Likes

thanks for the suggestion !
With this approach the difference is that the whole figure apparently needs to be wrapped up into a function. This does the job nevertheless.

yes, we’re current developing a package and one contributor gets issues of that kind:

MathTexEngine is innocent here, I think. Is it possible that the active package, RheologyCalculator, restricts the version of LinearAlgebra to the range 1.11.0-1, while running a Julia version with LinearAlgebra version 1.10.3? That’s how I read the error at least.

Ah OK… But why does the installation of MathTeXEngine has anything to do with LinearAlgebra ? That’s confusing…

My guess is that Pkg resolves all package versions when adding any package. RheologyCalculator depends on LinearAlgebra, so a version for LinearAlgebra is being resolved. I am not sure why the error pops up now instead of when LinearAlgebra was added as a dependency. Maybe the package was originally developed with Julia 1.11, and later on that user started using Julia 1.10?

However, you can test this hypothesis by running ] resolve (instead of ] add MathTexEngine). My expectation is it’ll fail too.

You can also run ] status --compat. It should display the restriction on LinearAlgebra versions. I bet you can than go ahead and just loosen it or remove it from Project.toml. Likely, you have something like

[compat]
LinearAlgebra = "1.11"

You can try removing that line, or maybe changing 1.111 to allow any version 1.x.x.

Thank you so much for your suggestions. I’ll pass that on to my colleagues, this will likely help fixing the issue. Meanwhile I edited the original post since the mention of an installation problem of MathTexEngine was incorrect.