Super/subscript placement messes up when font size changes


I am using root 5.34.22 (or 21, same issue) with the atlasstyle-00-03-05 package for my plots. There are various text settings for things like labels, legends etc, and basically the only thing that changes between them is the font size.

My problem is that when I have super/subscripts in my labels, the placement (kerning) of these gets all messed up as the font size changes. E.g. for SetTextSize(0.03) the placement of these is fine, but for a larger size the placement of the super/subscripts gets all messed up. (we are using SetTextFont(42)).

Is there any way to fix this? I can’t change the font size as it needs to match the guidelines, and I’m not particularly keen on individually setting the kerning on a number of labels on over a hundred plots by hand.


Can you provide a small macro showing this issue ?
On which platform are you running ?

Sure. I’m running on Mavericks, locally compiled. It’s just a basic script to plot existing histograms, so I do things like:

	Zm_TrackMETNominal_x->GetXaxis()->SetTitle("(p,E)_{x}^{miss} [GeV]");
	ATLASLabel(0.2,0.88,"#kern[-0.1]{work in progress}");
	myText(      0.2,0.80,1,"#sqrt{s} = 8 TeV, 20.3 fb^{-1}");
	myText(      0.2,0.72,1,processlabelZmm);
	myMarkerText(0.7,0.85,col1,mar1, "Data 2012 Nominal p_{T}^{miss}",1);
	... etc

where (part of AtlasStyle):

void myText(Double_t x,Double_t y,Color_t color, const char *text) {

  Double_t tsize=0.04;
  TLatex l; //l.SetTextAlign(12);

void myMarkerText(Double_t x,Double_t y,Int_t color,Int_t mstyle, const char *text,Float_t msize)
  Double_t tsize=0.03;
  TMarker *marker = new TMarker(x-(0.4*tsize),y,8);
  marker->SetMarkerColor(color);  marker->SetNDC();

  TLatex l; l.SetTextAlign(12); //

Attached is the plot - you can see the super/subscripts are fine in the smaller font in the legend, but are misplaced in the luminosity and x axis title.
Validation_Zmm_x_rootsupport.eps (16 KB)

Edit: seems that the board doesn’t like the .eps format or something, here’s a link to the plot: … sp=sharing

do you know if you are using the X11 backend or the Cocoa one ?
some issues with text were recently fixed with the Cocoa one.

I ran the following macro on Yosemite using both the cocoa and X11 backend. and I get a correct output.

   TCanvas *c1 = new TCanvas("c1", "c1",1024,22,700,530);
   TLatex *   tex = new TLatex(0.4482759,0.5889831,"Data 2012 Nominal p_{T}^{miss}");

I don’t know what cocoa is, so probably not :slight_smile: I’m just using the terminal app right now, but it does the same on x11 (xquartz).

I tried your macro and it came out fine - at least on the screen. After a bunch of messing around with various things I now think that the problem is coming when I am saving the file.

Right now I do:

    std::ostringstream ostr_root;

    ...<plot the histo, etc> ...

    ostr_root.clear(); ostr_root.str("");
    ostr_root << savepath <<  "whatever.eps";

and I think that it’s at this point that the formatting goes crazy. Is there a better way for me to save the files as .eps?


Using the X11 backend fixed the issue. Still there is a problem with the PDF/PS file generated when running the cocoa backend. The following macro shows the problem. Note that the issue disappear when running in batch mode.

void test(){
   TCanvas *c1 = new TCanvas("c1", "c1",1024,22,700,530);
   TLatex *   tex = new TLatex(0.2,0.5,"Data 2012 Nominal p_{T}^{miss} ");

Thanks very much for the help!

This is now fixed.
Thanks for reported.