Based on the previous macro, this version might have more compassion towards source-code reader:
using REPL
macro lvar_str(s::AbstractString)
if !haskey(REPL.REPLCompletions.latex_symbols, "\\"*s)
throw(ArgumentError("expecting relevant latex"))
end
new_s = REPL.REPLCompletions.latex_symbols["\\"*s]
sym = Meta.parse(unescape_string(new_s))
sym isa Symbol || throw(ArgumentError("expecting a single symbol"))
return esc(sym)
end
julia> lvar"mu"
3
julia> lvar"pi"
π = 3.1415926535897...