Yes, that’s right. Within a raw string, the backslash is (mostly) ignored, so it won’t try to translate \m in \mu into something non-existing. Compare for an escape code that does exist, e.g. "a\nb" vs raw"a\nb", the latter being equivalent to "a\\nb"
Thanks to @stevengj, I’m able to display what I need, i.e., 𝜇mol, on Juypter by doing this: LaTeXString(a * b).
Unfortunately, when this string is sent to GMT to plot my colorbar label, it became this on my map: “Variable ($\mu$mol)”
Not sure if this is a Julia or GMT issue, but I certainly did not expect such a simple issue would become so complicated. Will it be possible to use the Unicode point # (e.g., U+003BC in this case) to get the desired results, i.e., 𝜇mol?
Presumably GMT doesn’t support LaTeX equations in plots. LaTeXStrings.jl doesn’t do any rendering — it is just a convenient way to type LaTeX equations in Julia strings without lots of escaping — and ultimately the plotting software (or the Jupyter notebook, in the case of cell output) is responsible for detecting that $...$ is a LaTeX equation and sending it to a math renderer (e.g. the MathTeXEngine package or MathJax). Only a few plotting packages currently support this.
Sure, have you tried just using "µmol" as your label string? (Note that you can easily type Unicode math symbols in the Julia REPL or Jupyter notebooks by using tab completion, e.g. type "\mu, hit the tab key, and then type mol". You can also type "\u03BCmol" if you know the codepoint you want, but it’s a lot nicer to type, tab-complete, or cut-and-paste the Unicode directly — Julia has excellent Unicode support!)
This should work as long as your plotting software has fonts that include the Unicode characters you want (or supports fallback fonts for text rendering). However, GMT is apparently based on the old Postscript fonts and may require some tweaking to get it to render Unicode characters.
PS. Note that the “micro” symbol is technically distinct from the Greek character “mu” — micro in Unicode is U+00B5, and it can be typed on a Mac keyboard by option-m. In many fonts, however, mu (μ) and micro (µ) are rendered with an identical (or nearly identical) glyph.
PPS. Note that 𝜇 is U+1D707, italic mu, which is generally not what you would want for a micro symbol, even in LaTeX.
Yes, GMT started to support LaTeX since last version (GMT6.2.0) but one need to have LaTeX installed. I had troubles with it on Windows when I refused to install the gigantic full LaTeX package and so never tried it nor tried to get some more julian syntax in GMT.jl. This is something I want o tackle someday but preferably it should be something similar to what Makie start doing also recently. Meanwhile to use LaTeX equations one must use the pure GMT syntax, i.e. pass text strings to the frame option or in the text module.
It turns out to be a GMT issue. I finally figured this out, with some help from the GMT experts:
You want to use @~ for special characters, @+ for superscripts and @- for subscripts. In my example, it would be written this way: (@~\155@~mol kg@+-1@+) .