maoc
November 24, 2022, 6:07pm
1
I’m using the symbol latex \lambda in Julia scripts (\lambda = 5). When I plot, I need to put the \lambda symbol in the Title, but it’s not working. I am using the Jupyter Notebook on Chrome!
using Plots
title_ = ["λ =$λ, n = $nn " "" "" "" ""]
I don’t know why the symbol is not showing. Does anyone have any tips on how to resolve this?
You should probably mention what package you are using for plotting, GR through Plots.jl?
1 Like
Use the LaTeXStrings package and LaTeX-like markup.
using LaTeXStrings
title_ = L"\lambda=$λ"
plot(title=title_)
1 Like
empet
November 24, 2022, 7:34pm
4
It displays LaTeX even without LaTeXStrings:
using Plots
λ=5
title_ = "λ=$λ"
plot(title=title_, size=(300, 200))
1 Like
maoc
November 24, 2022, 9:09pm
5
This seems to solve the problem, but other problems appear.
maoc
November 24, 2022, 9:12pm
7
Yes, I believe that the problem should not be Julia’s, but maybe an update is needed. Is that it?
Or
using Latexify
_title=@latexdefine λ
empet
November 24, 2022, 9:38pm
9
I checked it in REPL, and Jupyter Notebook, without any update.
BLI
December 10, 2022, 3:22pm
10
The $
symbol is the standard symbol to “interpolate” in text strings, e.g., with x = 2
, the string "Here, x = $x"
works.
If you use LaTeXStrings
, this will, however, not work because LaTeXStrings
will interpret the $
character as indicating a LaTeX symbol.
Instead, in LaTeXStrings
, you need to use %$
as interpolation symbol. So with x = 2
, the string L"Here, $x = %$(x)
should work.