GR.jl icon indicating copy to clipboard operation
GR.jl copied to clipboard

odd spacing with LaTeXStrings with \textrm

Open lmiq opened this issue 3 years ago • 5 comments

example:

julia> using GR, LaTeXStrings

julia> x = rand(10)
       y = rand(10)
       plot(x[1:10], y, xlabel=L"\textrm{This is } \alpha")

image

adding tildes ~ solves the lack of spacing between words, but there is still an odd spacing between the captial T and the text that follows:

julia> x = rand(10)
       y = rand(10)
       plot(x[1:10], y, xlabel=L"\textrm{This~is~}\alpha")

image

(jl_6ruBxL) pkg> st
      Status `/tmp/jl_6ruBxL/Project.toml`
  [28b8d3ca] GR v0.62.1

lmiq avatar Nov 09 '21 16:11 lmiq

In the meantime, you can mix normal and math text: xlabel="This is \\alpha"):

Screenshot 2021-11-09 at 17 22 54

Is this what you want?

jheinen avatar Nov 09 '21 16:11 jheinen

Thanks, quoted the alternative on the discourse thread: https://discourse.julialang.org/t/issue-with-plots-latex/71045/13

(it was not my specific problem now)

lmiq avatar Nov 09 '21 16:11 lmiq

It is actually a problem I am facing. With normal math text, \alpha looks fine, though other characters look 'weird', compared to LaTeX, in particular the space between subindices: image

tomas-budi-ors avatar Nov 09 '21 16:11 tomas-budi-ors

It is actually a problem I am facing. With normal math text, \alpha looks fine, though other characters look 'weird', compared to LaTeX, in particular the space between subindices:

This may not be the exact same issue. Can you provide a MWE? I cannot reproduce that here.

lmiq avatar Nov 09 '21 17:11 lmiq

That's how it looks with up-to-date versions (GR.jl 0.62.1 and GR run-time 0.62.0):

using GR
plot(randn(10),xlabel="Bilateral Trade Costs \\tau_{rlj}")
Screen Shot 2021-11-09 at 21 13 14

jheinen avatar Nov 09 '21 20:11 jheinen