Hi, I want to write Sβ_{L} in the legend of my histogram, how can I put the prime symbol using TLatex in ROOT ?

*ROOT Version:* 5.34/09

*Platform:* Scientific Linux

Hi, I want to write Sβ_{L} in the legend of my histogram, how can I put the prime symbol using TLatex in ROOT ?

*ROOT Version:* 5.34/09

*Platform:* Scientific Linux

```
root [0] auto t = new TLatex(.5,.5,"this is prime: '")
root [1] t->Draw()
```

But, this is the same as apostrophe.

I want like this S^\prime_L

Is there anyway to write this in TLatex ?

```
auto t = new TLatex(.5,.5,"S^{'}_{L}")
```

```
auto t = new TLatex(.5,.5,"S^{\\prime}_{L}")
```

or:

```
auto t = new TLatex(.5,.5,"S_{L}\\prime")
```

indeed simply use what you would use in LaTex.

Can βS^{\prime}_{L}β be written inside legend->AddEntry() ?

Yes sure. Note you need 2 β\β:

```
S^{\\prime}_{L}
```

```
{
TCanvas *c2 = new TCanvas("c2","c2",500,300);
TLegend* leg = new TLegend(0.2, 0.2, .8, .8);
TH1* h = new TH1F("", "", 1, 0, 1);
leg->AddEntry(h, "Histogram \"h\"", "l");
leg->AddEntry((TObject*)0, "", "");
leg->AddEntry((TObject*)0, "Some text", "");
leg->AddEntry((TObject*)0, "", "");
leg->AddEntry(h, "Histogram \"h\" again", "l");
leg->AddEntry(h, "TMathText: S^{\\prime}_{L}", "l");
leg->Draw();
}
```

Note the TMathText limitation: TMathText rendering is not implemented for the PDF output. PostScript output should be used instead.

Thanks for the showing the command to write prime in the the legend of the histogram.

But, there is one problem I am facing with this command is that - the statement that is written prior to S^{\\prime}_{L} gets printed in italics format and without any spaces like the one in the following picture. Is there a way to mitigate this problem ?

TMathText renders text as Latex Math formulae. So it follows the Latex Math formulae rules (see a Latex manual). So yes, it is always italic, and yes the spaces are ignored. To make spaces you can for instance do:

```
leg->AddEntry(h, "After\\;Mass\\;Cut, S^{\\prime}_{L}", "l");
```

As a suggestion/alternative idea:

When I want full latex control, what I usually follow is Saving Canvas as TeX - ROOT

For the βitalicsβ issue, what I would do in that case is something like

```
"\\mathrm{After\\,Mass\\,Cut},\\;S^{\\prime}_{L}"
```

1 Like

Instead of β`S_{L}^{\\prime}`

β, you may like β`S_{L}{\\!\\!\\prime}`

β or β`S_{L}{\\!\\!\\'`

}β.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.