It appears that TCanvas::SaveAs(.pdf) converts all escaped TMathText symbols to TLatex, which, of course, fails when TLatex encounters a symbol it doesn’t know, resulting in literal strings of LaTeX code displayed in the file. This seems to only happen with .pdf files; .eps and .png files, for example, work fine. Reproducer below.
can = ROOT.TCanvas()
df = ROOT.RDataFrame(10).Define('e', 'rdfentry_')
h = df.Histo1D('e')
h.SetTitle(r'\mathcal{B}_\text{foo}') # example of TMathText that cannot be TLatex
h.Draw()
can.SaveAs('example.pdf') # displays Title as "#mathcal{B}_#text{foo}"
can.SaveAs('example.png') # displays Title properly
There are publication requirements mandating that I produce .pdf files. Currently, I work around this by converting to .pdf after the fact, but I cannot simply use .ps files.
I will make a pull request adding this known limitation to the documentation.
Ah, thank you. I made an independent pull request adding the documentation to TPad::SaveAs, TPad::Print as well. I think both are important. Thanks again.
@couet can you please write “short summary” about difference between EPS, PS and PDF files produced by ROOT ? Do we need something like: ROOT.SaveAs (“ps or ?eps?”) => ps2pdf => publication ? Which option is best for publication in journal ?
PS is PostScript, one can have several pages in the same file. It supports TMathText. EPS does also support it. It is Encapsulated PostScript and only one page is allowed in it. It is meant to be included in LaTex documents (for instance). PDF is classic PDF and does not support TMathText. You can also generate TeX natives file to be included in LaTeX documents and of course full LaTeX is supported there.