I spent some time googling my question but merely found answers related to ROOT vX with X<6 or answers that were not really related to my question. Apologies in case I still missed if this discussion has been answered some place else (given that it is quite obvious). For completeness: I am using ROOT v6.08.
I would like to ask if it was possible to use the LaTeX symbol \ell in a TH1 axis title or label.
For ROOTv5 a colleague of mine has found a way to use the symbol in a TMathText environment (though italic I found it to be displayed in an unusually strong inclination), but of course not for the axis, but only for a text element in the plot.
As I understood from [1] and past posts in this forum, TLatex (and therefore the TH1 axes) implement a subset of the math symbols available in LaTeX but I frankly do not see the logic in the selection of this subset. E.g. \ell is a quite common symbol for leptons and it would be well appreciated if this could be used in the axis titles. Also, I do see that \slash (as in ETmiss, which is barely used as people have moved to pTmiss) is implemented but \mathcal isn’t, which would be good for, e.g., branching fraction symbols.
Bottomline my question is: is \ell still not implemented in ROOTv6 and if yes will it be implemented in one of the upcoming versions? Alternatively, I’d like to ask if there is a way fo emulate the symbol \ell? I’ve played around with TTF, but haven’t been successful (yet). Obviously, I’d like to avoid (for now) painting a TMathText with solid fill color over the axis title.
The solution by couet works if I open ROOT directly and build a histogram there.
But if I want to use \ell in pyROOT it does not seem to work. I.e. my syntax is
h.GetXaxis().SetTitle("M_{\\ell\\ell}")
This merely results in #ell#ell (as subscript to M) being written in the axis.
It is needed, so in a python string you’d put \ to have one .
For a short period of time I thought \ was required by ROOT and therefore I put \\, which results in ##ell.
Hm, maybe its just the wrong data type after all and it needs some more C++ conform type…
python is very relaxed regarding escaping, it seems, so it accepts \e as such and doesn’t raise an error. But yeah, I forgot the escaping in my post. Note that you can use “raw strings” in python, which don’t do backslash escaping, to make it a bit more readable (note the r in front of the string):
The problem is a different one: \\ell works perfectly fine also in my script.
The problem occurs when exporting to pdf. In png and eps I can see the ell properly
but the pdf places an #ell rather than the ell symbol.
Is this expected and if yes, how can I overcome it?