# L strings not working in Makie

**URL:** https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366
**Category:** General Usage
**Tags:** makie, glmakie, latexstrings
**Created:** [September 16, 2022, 1:17pm UTC](https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366 "2022-09-16T13:17:03Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Thomas\_Mikaelsen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thomas_mikaelsen/32/42736_2.png) [@Thomas\_Mikaelsen](https://discourse.julialang.org/u/Thomas_Mikaelsen)
#### Post date: [September 16, 2022, 1:17pm UTC](https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366/1 "2022-09-16T13:17:03Z")

</div>

Hello. First post on this forum so I apologize if I fall short of the conventions.

I can’t get L strings to work with Makie on Jupyter Notebook. I just installed Makie, CairoMakie and MakieTeX. I couldn’t get my own examples to work, so I just copied one of the examples from the [tutorial](https://github.com/JuliaPlots/MakieTeX.jl), which also doesn’t work:

First, if I just do as quoted in the code (see below), I get the error: `LoadError: UndefVarError: @L_str not defined in expression starting at In[3]:6`

```julia
using Makie, MakieTeX
using CairoMakie

fig = Figure()
l1 = Label(
    fig[1, 1], L"A \emph{convex} function $f \in C$ is \textcolor{blue}{denoted} as \tikz{\draw[line width=1pt, >->] (0, -2pt) arc (-180:0:8pt);}";
    tellwidth = false, tellheight = true
)
ax1 = Axis(
    fig[2, 1];
    xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
    ytickformat = x -> latexstring.(string.(x)),
    ylabel = L"\displaystyle \Phi(\vec x) = f(\vec x) + g(V)",
)
heatmap!(ax1, Makie.peaks())
fig

```

If I use LaTexStrings, the error goes away, but the L strings don’t seem to work:

```julia
using Makie, MakieTeX
using CairoMakie, LaTeXStrings

fig = Figure()
l1 = Label(
    fig[1, 1], L"A \emph{convex} function $f \in C$ is \textcolor{blue}{denoted} as \tikz{\draw[line width=1pt, >->] (0, -2pt) arc (-180:0:8pt);}";
    tellwidth = false, tellheight = true
)
ax1 = Axis(
    fig[2, 1];
    xtickformat = x -> latexstring.("a_{" .* string.(x) .* "}"),
    ytickformat = x -> latexstring.(string.(x)),
    ylabel = L"\displaystyle \Phi(\vec x) = f(\vec x) + g(V)",
)
heatmap!(ax1, Makie.peaks())
fig

```

 ![Skærmbillede 2022-09-16 kl. 15.15.35](https://global.discourse-cdn.com/julialang/original/3X/d/7/d72f4b296e2fc3e7f4f3dae8024a427529211b32.png)

Thanks a lot for any help.

---

<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: [September 16, 2022, 2:38pm UTC](https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366/2 "2022-09-16T14:38:45Z")

</div>

You do not need MakieTeX, which was a different attempt at adding LaTeX capabilities to Makie. Now, this is built-in via the dependency MathTeXEngine.jl. I assume you got an old version of Makie due to installing MakieTeX. Just remove that, update, and you should be good to go.

---

<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: [September 16, 2022, 2:40pm UTC](https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366/3 "2022-09-16T14:40:39Z")

</div>

However, I note that you use complex expressions using tikz etc in your L-strings, this is not supported by MathTeXEngine, which is merely an approximation of LaTeX but doesn’t actually use it. That was a benefit of the old MakieTeX approach, however it was quite slow due to the roundtrip. MathTeXEngine, while limited, also works for interactive figures with GLMakie.

---

<div class="post-metadata">

### Author: ![Thomas\_Mikaelsen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thomas_mikaelsen/32/42736_2.png) [@Thomas\_Mikaelsen](https://discourse.julialang.org/u/Thomas_Mikaelsen)
#### Post date: [September 16, 2022, 4:29pm UTC](https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366/5 "2022-09-16T16:29:55Z")

</div>

Thanks a lot. I managed to update to new versions, but I still get the error `LoadError: UndefVarError: @L_str not defined` when running the following simple code

```julia
using Makie, CairoMakie

# Asset poliy function
f = Figure()
ax = Axis(f[1, 1], 
    title = L"Asset policy function $g(a,s)$",
    xlabel = "a",
    ylabel = "g(a,s)"
)
vlines!(ax, 0, color = :black)
hlines!(ax, 0, color = :black)

for i in 1:length(R.S)
    s = round(R.S[i],digits=2)
    X = R.asset_grid
    Y = R.g[:,i]
    lines!(ax, X, Y, label = "s = $s")
end
axislegend()
f

```

---

<div class="post-metadata">

### Author: ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)
#### Post date: [September 16, 2022, 6:33pm UTC](https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366/6 "2022-09-16T18:33:34Z")

</div>

~~You do still need a `using LaTeXStrings` line.  
 `MakieTeX` is the only one that needs to be removed.~~

---

<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: [September 16, 2022, 6:36pm UTC](https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366/7 "2022-09-16T18:36:48Z")

</div>

You do not need `using LaTeXStrings`, the `L"` macro is re-exported by Makie. What version are you on? Latest is `Makie v0.17.13`.

And in case you didn’t, you need to restart Julia after updating versions so you actually get the new one.

---

<div class="post-metadata">

### Author: ![Thomas\_Mikaelsen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thomas_mikaelsen/32/42736_2.png) [@Thomas\_Mikaelsen](https://discourse.julialang.org/u/Thomas_Mikaelsen)
#### Post date: [September 18, 2022, 2:05pm UTC](https://discourse.julialang.org/t/l-strings-not-working-in-makie/87366/8 "2022-09-18T14:05:59Z")

</div>

This solved my issue, thanks a lot!
