# LaTeX not working in Makie

I am trying to figure out how to use Makie.
As a simple test, I decided to run the following code snippet:

using CairoMakie, LaTeXStrings

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


However, I get the following error:

ArgumentError: regex matching is only available for the String type; use String(s) to convert

Stacktrace:
[1] match(r::Regex, s::LaTeXString, i::Int64)
@ Base ./regex.jl:317
[2] match(r::Regex, s::LaTeXString)
@ Base ./regex.jl:316
[3] iswhitespace(str::LaTeXString)
@ Makie.MakieLayout ~/.julia/packages/Makie/c5WJV/src/makielayout/lineaxis.jl:412

Is it some kind of bug or am I doing something wrong?

The version of Makie.jl in your environment is probably the old v0.13.14. In that case, I was able to confirm that the same error you reported occurs.

How to check the version of Makie.jl:

using Pkg
Pkg.status("Makie"; mode=PKGMODE_MANIFEST)


In my environment

• CairoMakie v0.6.3
• Makie v0.15.0
• LaTeXStrings v1.2.1

Please upgrade CairoMakie.jl and Makie.jl respectively to v0.6.3 and v0.15.0 or higher.

The actual work I did is essentially the following: Start Julia in an empty directory and run

pkg> activate .
pkg> st


And then, run your code snippet.

3 Likes

Yes, you are right, I have the older version installed.

Do you know if there is a way to force the installation of a new version in my current non-empty environment? Like, force the installation and see what dependency conflicts does it lead to.

Ok. I solved this. As it turns out, the culprit was WebIO.jl because it bounded Observables.jl. I removed WebIO, Interact and PlotlyJS and managed to update CairoMakie after that.

No. I also don’t know how to do it.

Ordinarily, I have essentially the following way to register packages.

• In ~/.julia/environments/v1.6/{Project.toml, Manifest.toml} (default), register those packages that are always used and do not cause harmful version down of other packages.

• In /path/of/specific/project/{Project.toml, Manifest.toml}, only register packages that cause harmful version downs of other packages, but are necessary for the specific project.

For instance, in Makie.jl's github page, the latest version is v0.15.0.
Believe that what you ask may be achieved by:

] add Makie@0.15.0


and check if there any conflicts?

Ok. Thank you. I did not know how to specify the version. I used ] add CairoMakie#master instead.

Just a side note unrelated to the question, sin(pi*x) is better written in Julia as sinpi(x), it’s more efficient and accurate. So, you could write sinpi.(xs) instead in your case.

1 Like