Incorporating LaTexStrings.jl elsewhere
Closed this issue · 3 comments
I had added support for the LaTex names to the more Swift-style string literal macro (in https://github.com/ScottPJones/StringUtils.jl/tree/spj/format) that I've been working on,
i.e. u"\{euro}" == "€"
,
and I just came across this nice package.
I was wondering if 1) it would be possible to have the u" "
incorporate LaTexStrings.jl,
2) do you think it would be useful for people, and
3) if so, what do you think would be best for the syntax?
Something like the lines of: u"This is some latex: \l{1 + \alpha^2}"
maybe?
It sounds like what you want may be quite different: you want to automatically turn things like u"\alpha"
into "α"
(right?), whereas for LaTeXStrings I need to leave them in ASCII form (e.g. so that the LaTeX will be rendered by MathJax in IJulia or Matplotlib/PyPlot). (In general, unfortunately, mixing LaTeX and arbitrary Unicode seems to be asking for trouble, because most LaTeX renderers seem to be non-unicode-aware.)
I don't know what you mean by "incorporating" LaTeXStrings.jl into u"..."
. LaTeXStrings doesn't actually do very much except (a) make it so you don't have to escape \
and $
in LaTeX code and (b) make a wrapper type with a writemime("text/latex")
method so that the LaTeX renders in Jupyter.
Yes, what I'm doing now is simply taking the LaTex character/string definitions, that you can use in the REPL with , and putting the actual Unicode character(s) into the string, which can be useful if you want to keep your source code ASCII, but still have Unicode characters in output, without having to look up the hex numbers.
About incorporating LaTexStrings.jl, in u"..."
, you wouldn't have to worry about escaping $
anyway, as it uses Swift style string interpolation, i.e. \(expr)
, so only the handling of \
would need to be dealt with,
and also figure out what character could be used to bracket the part that should be handled as LaTex syntax. May have just been a silly idea, but I wanted to hear from an expert if it might be useful at all.
Thanks!
No problem.