Latex sqrt problem

Dear Expert,

I have the following code:

{
  TLatex * l1 = new TLatex(0.2,0.5,"CMS PbPb #sqrt{s_{NN}} = 2.76 TeV");
  l1->Draw();
  c1->SaveAs("l1.pdf");
}

On lxplus with root 5.32/00, I got l1_lxplus.pdf (12.2 KB).
On my Mac with root 5.34/18, I got l1_mac.pdf (12.3 KB).
No rootlogon.C was loaded.
The display of sqrt is so different.
It is so ugly on my Mac.
What could be wrong?

Thanks,

Ok, I tested on lxplus with root 5.34/10.
It looks like l1_lxplus2.pdf (12.3 KB).
This is so annoying.

Hi All,

I tried to replace #sqrt with \sqrt.
The result for 5.32/00 is the same.
However, for 5.34/18 and 5.34/10 both on my Mac and lxplus, I got different results by SaveAs pdf and png:
PDF: l1_mac.pdf (12.2 KB)
PNG:



The sqrt actually looks normal, although other text are TMathText.
I am completely lost.
How the hell is it possible!~

With ROOT version supporting TMathText when you replace #sqrt by \sqrt then you get the whole string drawn with tmathtext. The sqrt is a real character. With normal TLatex #sqrt is drawn with lines.

I found it is related to the root build config.
I was using brew root on my Mac.
The latest official build 5.34/14 is ok for me.
But it is using X11, the color alpha is so messed up.

Yes the cocoa version has its own way of managing fonts. It might show a slightly different result.
What do you mean by “color alpha is so messed up”? … are you using transparency ?

also note:
root.cern.ch/drupal/content/saving-canvas-tex

Yes, I mean transparency.
X11 doesn’t support that.
Do we have an official build with cocoa?
And, ideally, it shouldn’t depend on X11 or cocoa when SaveAs pdf.

[quote=“couet”]Yes the cocoa version has its own way of managing fonts. It might show a slightly different result.
What do you mean by “color alpha is so messed up”? … are you using transparency ?

also note:
root.cern.ch/drupal/content/saving-canvas-tex[/quote]

I tried this SaveAs tex, it doesn’t fit my need.
I would like plots saved in pdf so we can use in ppt or something else.
This is basically unusable situation.
I can only reverse to X11, and check the output pdf manually every time I plot something with transparency.
Hope it will be fixed soon.

The transparency is available also with the latest version via opengl. It might be better for you.
The way to do it is to do in $ROOTSYS/etc/system.rootrc:

# Flag to set CanvasPreferGL via gStyle
OpenGL.CanvasPreferGL:                      1

and also good to have:

Canvas.MoveOpaque:          true
Canvas.ResizeOpaque:        true
# Flag to set CanvasPreferGL via gStyle
OpenGL.CanvasPreferGL:                      1

Good to learn this.
OpenGL indeed shows some transparency.
But it also breaks lots of other thinks, like some symbols are not shown properly, formatting issues etc…
I will just switch back to X11, which I really hate.
Hope cocoa can be fixed in the later releases.

[quote=“betterwang”]
I will just switch back to X11, which I really hate.
Hope cocoa can be fixed in the later releases.[/quote]

Hello, thanks for you faith in the Cocoa’s back-end. Indeed, the problem will be fixed either this month or in May. It’s not a Cocoa’s problem actually, it’s a problem of TText and related classes who misuse/abuse font metrics and rely on some hacks/crutches - for example, even if on screen square root looks differently with Cocoa, it’s obvious that this MUST NOT affect a resulting pdf output, but IT DOES and that’s a really annoying problem/sloppy coding in TText and graf2d.

Also, the fact that TMathText is not saved in pdf correctly - has nothing to do with Cocoa.

TMathText is not supported in PDF.

[quote=“betterwang”]Dear Expert,

I have the following code:

{
  TLatex * l1 = new TLatex(0.2,0.5,"CMS PbPb #sqrt{s_{NN}} = 2.76 TeV");
  l1->Draw();
  c1->SaveAs("l1.pdf");
}

On lxplus with root 5.32/00, I got l1_lxplus.pdf.
On my Mac with root 5.34/18, I got l1_mac.pdf.
[/quote]

I’m currently trying to improve the latex rendering with the Cocoa back-end. That’s how your example looks now (see attachment) - I think it’s a bit better and closer to X11 version now.
c1.pdf (12.3 KB)


Hi,

I am using ROOT 6.05/01 in OSX 10.10.4. If I run the next lines

[code]{
TH1F *h = new TH1F(“h”,"#sqrt{3223}",100, -10, 10);
h->FillRandom(“gaus”,10000);

h->Draw();

}[/code]
I get wrong_sqrt.pdf, which is definitely not going to go in a thesis or a paper. I assume that this is using TLatex. However if I follow what you said and I do:

[code]{
TH1F *h = new TH1F(“h”,"\sqrt{3223}",100, -10, 10);
h->FillRandom(“gaus”,10000);

h->Draw();

}[/code]

I get good_sqrt.eps, which looks good to me. As was already mentioned, we cant save in pdf, because the equation dissapears when doing so. However I can save as eps, gif and ps, all of them retain the equation. I think the best format is eps. I then try to include it in LaTex, however that is not straightforward and I so I have in OSX (not sure about Linux) the option to do

epstopdf good_sqrt.eps

which gives me good_sqrt.pdf which finally can be included in my document using latex. So yes, its a pain.
wrong_sqrt.pdf (14.2 KB)

[quote=“rooter_03”]Hi,

I am using ROOT 6.05/01 in OSX 10.10.4. If I run the next lines

[code]{
TH1F *h = new TH1F(“h”,"#sqrt{3223}",100, -10, 10);
h->FillRandom(“gaus”,10000);

h->Draw();

}[/code]
I get wrong_sqrt.pdf, which is definitely not going to go in a thesis or a paper. I assume that this is using TLatex. However if I follow what you said and I do:

[code]{
TH1F *h = new TH1F(“h”,"\sqrt{3223}",100, -10, 10);
h->FillRandom(“gaus”,10000);

h->Draw();

}[/code]

I get good_sqrt.eps, which looks good to me. As was already mentioned, we cant save in pdf, because the equation dissapears when doing so. However I can save as eps, gif and ps, all of them retain the equation. I think the best format is eps. I then try to include it in LaTex, however that is not straightforward and I so I have in OSX (not sure about Linux) the option to do

which gives me good_sqrt.pdf which finally can be included in my document using latex. So yes, its a pain.[/quote]

By the way:

[code]
#!/bin/bash

for file in ls *.eps;do

epstopdf $file 2>/dev/null

echo “INFO::Converted $file to PDF”

done[/code]

should convert all the eps files to PDF at once, it can be put in a file called eps_pdf which can be put in a $HOME/scripts directory, which can be added to the $PATH variable so that you can just do eps_pdf in the terminal and get all the files converted.