TLegend multiple lines

Hi rooters

I was working with tLegend. I could not figure out if I can write multiple lines for the same entry, for example I have

leg->AddEntry(gr,"The Data","p");

what I want to do is this

leg->AddEntry(gr,"The Data \n slope something \n b something","p");

Here I am assuming that the return character from c++ works, although in reality in doesnt work(or al least in my program)

again, I appreciate any comments,
my rooot vesion is:

  *******************************************
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   3.05/07       10 May 2004   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************
 
FreeType Engine v2.1.3 used to render TrueType fonts.

Instead of:

leg->AddEntry(gr,"The Data \n slope something \n","p"); 

do

leg->AddEntry(gr,"#splitline{The Data }{slope something }","p"); 

see description of TLatex functionality at;
root.cern.ch/root/htmldoc/TLatex.html

Rene

thank you very much, that was what I need, just one extra line,

and thanks for the quick response,

Hi Rene , I tried to nest this in order to get three lines:

#splitline{first line}{#splitline{second line}{third line}}

However it did not work. Is there anyway to split a line in more than two lines ?

Actually nested #splitline works for me. I did:

TLatex tt(.5,.5,"#splitline{first line}{#splitline{second line}{third line}}");
tt.Draw();

and I get:

37

1 Like