class TLatex: public TText, public TAttLine


TLatex : to draw Mathematical Formula

TLatex's purpose is to write mathematical equations The syntax is very similar to the Latex one. It provides several functionalities:

Subscripts and Superscripts

Subscripts and superscripts are made with the _ and ^ commands. These commands can be combined to make complicated subscript and superscript expressions. You may choose how to display subscripts and superscripts using the 2 functions SetIndiceSize(Double_t) and SetLimitindiceSize(Int_t).

Examples:

   x^{2y} :    x^{2y} x_{2y} :    x^{2y}
   x^{y^{2}} : x^{y^{2}} x^{y_{1}} : x^{y_{1}}
   x^{y}_{1} : x^{y}_{1} x_{1}^{y} : x_{1}^{y}

Fractions

Fractions denoted by the / symbol are made in the obvious way. The #frac command is used for large fractions in displayed formula; it has two arguments: the numerator and the denominator.

Examples:

   x = #frac{y+z/2}{y^{2}+1} : x = #frac{y+z/2}{y^{2}+1}

Splitting Lines

A text can be split in two lines via the command #splitline.

Examples:

   #splitline{21 April 2003}{14:02:30} : #splitline{21 April 2003}{14:02:30}

Roots

The #sqrt command produces the square root of its argument; it has an optional first argument for other roots.

Examples:

   #sqrt{10} : #sqrt{10} #sqrt[3]{10} : #sqrt[3]{10}

Mathematical Symbols

TLatex can display dozens of special mathematical symbols. A few of them, such as + and > , are produced by typing the corresponding keyboard character. Others are obtained with the commands in the following table:
output of MACRO_TLatex_15_mathsymb
{
   TCanvas *Ms = new TCanvas("mathsymb","Mathematical Symbols",500,600);

   TLatex Tl;
   Tl.SetTextSize(0.03);

   // Draw First Column
   Tl.SetTextAlign(12);
   float y, step, x1, x2;
   y = 0.96; step = 0.0465; x1 = 0.02; x2 = x1+0.04;
               Tl.DrawLatex(x1, y, "#club")           ; Tl.DrawText(x2, y, "#club");
   y -= step ; Tl.DrawLatex(x1, y, "#voidn")          ; Tl.DrawText(x2, y, "#voidn");
   y -= step ; Tl.DrawLatex(x1, y, "#leq")            ; Tl.DrawText(x2, y, "#leq");
   y -= step ; Tl.DrawLatex(x1, y, "#approx")         ; Tl.DrawText(x2, y, "#approx");
   y -= step ; Tl.DrawLatex(x1, y, "#in")             ; Tl.DrawText(x2, y, "#in");
   y -= step ; Tl.DrawLatex(x1, y, "#supset")         ; Tl.DrawText(x2, y, "#supset");
   y -= step ; Tl.DrawLatex(x1, y, "#cap")            ; Tl.DrawText(x2, y, "#cap");
   y -= step ; Tl.DrawLatex(x1, y, "#ocopyright")     ; Tl.DrawText(x2, y, "#ocopyright");
   y -= step ; Tl.DrawLatex(x1, y, "#trademark")      ; Tl.DrawText(x2, y, "#trademark");
   y -= step ; Tl.DrawLatex(x1, y, "#times")          ; Tl.DrawText(x2, y, "#times");
   y -= step ; Tl.DrawLatex(x1, y, "#bullet")         ; Tl.DrawText(x2, y, "#bullet");
   y -= step ; Tl.DrawLatex(x1, y, "#voidb")          ; Tl.DrawText(x2, y, "#voidb");
   y -= step ; Tl.DrawLatex(x1, y, "#doublequote")    ; Tl.DrawText(x2, y, "#doublequote");
   y -= step ; Tl.DrawLatex(x1, y, "#lbar")           ; Tl.DrawText(x2, y, "#lbar");
   y -= step ; Tl.DrawLatex(x1, y, "#arcbottom")      ; Tl.DrawText(x2, y, "#arcbottom");
   y -= step ; Tl.DrawLatex(x1, y, "#downarrow")      ; Tl.DrawText(x2, y, "#downarrow");
   y -= step ; Tl.DrawLatex(x1, y, "#leftrightarrow") ; Tl.DrawText(x2, y, "#leftrightarrow");
   y -= step ; Tl.DrawLatex(x1, y, "#Downarrow")      ; Tl.DrawText(x2, y, "#Downarrow");
   y -= step ; Tl.DrawLatex(x1, y, "#Leftrightarrow") ; Tl.DrawText(x2, y, "#Leftrightarrow");
   y -= step ; Tl.DrawLatex(x1, y, "#void8")          ; Tl.DrawText(x2, y, "#void8");
   y -= step ; Tl.DrawLatex(x1, y, "#hbar")           ; Tl.DrawText(x2, y, "#hbar");

   // Draw Second Column
   y = 0.96; step = 0.0465; x1 = 0.27; x2 = x1+0.04;
               Tl.DrawLatex(x1, y, "#diamond")        ; Tl.DrawText(x2, y, "#diamond");
   y -= step ; Tl.DrawLatex(x1, y, "#aleph")          ; Tl.DrawText(x2, y, "#aleph");
   y -= step ; Tl.DrawLatex(x1, y, "#geq")            ; Tl.DrawText(x2, y, "#geq");
   y -= step ; Tl.DrawLatex(x1, y, "#neq")            ; Tl.DrawText(x2, y, "#neq");
   y -= step ; Tl.DrawLatex(x1, y, "#notin")          ; Tl.DrawText(x2, y, "#notin");
   y -= step ; Tl.DrawLatex(x1, y, "#subseteq")       ; Tl.DrawText(x2, y, "#subseteq");
   y -= step ; Tl.DrawLatex(x1, y, "#cup")            ; Tl.DrawText(x2, y, "#cup");
   y -= step ; Tl.DrawLatex(x1, y, "#copyright")      ; Tl.DrawText(x2, y, "#copyright");
   y -= step ; Tl.DrawLatex(x1, y, "#void3")          ; Tl.DrawText(x2, y, "#void3");
   y -= step ; Tl.DrawLatex(x1, y, "#divide")         ; Tl.DrawText(x2, y, "#divide");
   y -= step ; Tl.DrawLatex(x1, y, "#circ")           ; Tl.DrawText(x2, y, "#circ");
   y -= step ; Tl.DrawLatex(x1, y, "#infty")          ; Tl.DrawText(x2, y, "#infty");
   y -= step ; Tl.DrawLatex(x1, y, "#angle")          ; Tl.DrawText(x2, y, "#angle");
   y -= step ; Tl.DrawLatex(x1, y, "#cbar")           ; Tl.DrawText(x2, y, "#cbar");
   y -= step ; Tl.DrawLatex(x1, y, "#arctop")         ; Tl.DrawText(x2, y, "#arctop");
   y -= step ; Tl.DrawLatex(x1, y, "#leftarrow")      ; Tl.DrawText(x2, y, "#leftarrow");
   y -= step ; Tl.DrawLatex(x1, y, "#otimes")         ; Tl.DrawText(x2, y, "#otimes");
   y -= step ; Tl.DrawLatex(x1, y, "#Leftarrow")      ; Tl.DrawText(x2, y, "#Leftarrow");
   y -= step ; Tl.DrawLatex(x1, y, "#prod")           ; Tl.DrawText(x2, y, "#prod");
   y -= step ; Tl.DrawLatex(x1, y, "#Box")            ; Tl.DrawText(x2, y, "#Box");
   y -= step ; Tl.DrawLatex(x1, y, "#parallel")       ; Tl.DrawText(x2, y, "#parallel");

   // Draw Third Column
   y = 0.96; step = 0.0465; x1 = 0.52; x2 = x1+0.04;
               Tl.DrawLatex(x1, y, "#heart")          ; Tl.DrawText(x2, y, "#heart");
   y -= step ; Tl.DrawLatex(x1, y, "#Jgothic")        ; Tl.DrawText(x2, y, "#Jgothic");
   y -= step ; Tl.DrawLatex(x1, y, "#LT")             ; Tl.DrawText(x2, y, "#LT");
   y -= step ; Tl.DrawLatex(x1, y, "#equiv")          ; Tl.DrawText(x2, y, "#equiv");
   y -= step ; Tl.DrawLatex(x1, y, "#subset")         ; Tl.DrawText(x2, y, "#subset");
   y -= step ; Tl.DrawLatex(x1, y, "#supseteq")       ; Tl.DrawText(x2, y, "#supseteq");
   y -= step ; Tl.DrawLatex(x1, y, "#wedge")          ; Tl.DrawText(x2, y, "#wedge");
   y -= step ; Tl.DrawLatex(x1, y, "#oright")         ; Tl.DrawText(x2, y, "#oright");
   y -= step ; Tl.DrawLatex(x1, y, "#AA")             ; Tl.DrawText(x2, y, "#AA");
   y -= step ; Tl.DrawLatex(x1, y, "#pm")             ; Tl.DrawText(x2, y, "#pm");
   y -= step ; Tl.DrawLatex(x1, y, "#3dots")          ; Tl.DrawText(x2, y, "#3dots");
   y -= step ; Tl.DrawLatex(x1, y, "#nabla")          ; Tl.DrawText(x2, y, "#nabla");
   y -= step ; Tl.DrawLatex(x1, y, "#downleftarrow")  ; Tl.DrawText(x2, y, "#downleftarrow");
   y -= step ; Tl.DrawLatex(x1, y, "#topbar")         ; Tl.DrawText(x2, y, "#topbar");
   y -= step ; Tl.DrawLatex(x1, y, "#arcbar")         ; Tl.DrawText(x2, y, "#arcbar");
   y -= step ; Tl.DrawLatex(x1, y, "#uparrow")        ; Tl.DrawText(x2, y, "#uparrow");
   y -= step ; Tl.DrawLatex(x1, y, "#oplus")          ; Tl.DrawText(x2, y, "#oplus");
   y -= step ; Tl.DrawLatex(x1, y, "#Uparrow")        ; Tl.DrawText(x2, y, "#Uparrow");
   y -= step ; Tl.DrawLatex(x1, y-0.01, "#sum")       ; Tl.DrawText(x2, y, "#sum");
   y -= step ; Tl.DrawLatex(x1, y, "#perp")           ; Tl.DrawText(x2, y, "#perp");

   // Draw Fourth Column
   y = 0.96; step = 0.0465; x1 = 0.77; x2 = x1+0.04;
               Tl.DrawLatex(x1, y, "#spade")          ; Tl.DrawText(x2, y, "#spade");
   y -= step ; Tl.DrawLatex(x1, y, "#Rgothic")        ; Tl.DrawText(x2, y, "#Rgothic");
   y -= step ; Tl.DrawLatex(x1, y, "#GT")             ; Tl.DrawText(x2, y, "#GT");
   y -= step ; Tl.DrawLatex(x1, y, "#propto")         ; Tl.DrawText(x2, y, "#propto");
   y -= step ; Tl.DrawLatex(x1, y, "#notsubset")      ; Tl.DrawText(x2, y, "#notsubset");
   y -= step ; Tl.DrawLatex(x1, y, "#oslash")         ; Tl.DrawText(x2, y, "#oslash");
   y -= step ; Tl.DrawLatex(x1, y, "#vee")            ; Tl.DrawText(x2, y, "#vee");
   y -= step ; Tl.DrawLatex(x1, y, "#void1")          ; Tl.DrawText(x2, y, "#void1");
   y -= step ; Tl.DrawLatex(x1, y, "#aa")             ; Tl.DrawText(x2, y, "#aa");
   y -= step ; Tl.DrawLatex(x1, y, "#/")              ; Tl.DrawText(x2, y, "#/");
   y -= step ; Tl.DrawLatex(x1, y, "#upoint")         ; Tl.DrawText(x2, y, "#upoint");
   y -= step ; Tl.DrawLatex(x1, y, "#partial")        ; Tl.DrawText(x2, y, "#partial");
   y -= step ; Tl.DrawLatex(x1, y, "#corner")         ; Tl.DrawText(x2, y, "#corner");
   y -= step ; Tl.DrawLatex(x1, y, "#ltbar")          ; Tl.DrawText(x2, y, "#ltbar");
   y -= step ; Tl.DrawLatex(x1, y, "#bottombar")      ; Tl.DrawText(x2, y, "#bottombar");
   y -= step ; Tl.DrawLatex(x1, y, "#rightarrow")     ; Tl.DrawText(x2, y, "#rightarrow");
   y -= step ; Tl.DrawLatex(x1, y, "#surd")           ; Tl.DrawText(x2, y, "#surd");
   y -= step ; Tl.DrawLatex(x1, y, "#Rightarrow")     ; Tl.DrawText(x2, y, "#Rightarrow");
   y -= step ; Tl.DrawLatex(x1, y-0.015, "#int")      ; Tl.DrawText(x2, y, "#int");
   y -= step ; Tl.DrawLatex(x1, y, "#odot")           ; Tl.DrawText(x2, y, "#odot");

   return Ms;
}

Delimiters

TLatex provides 4 kinds of proportional delimiters:
   #[]{....} or "a la" Latex #left[.....#right] : big square brackets
   #{}{....} or              #left{.....#right} : big curly brackets
   #||{....} or              #left|.....#right| : big absolute value symbol
   #(){....} or              #left(.....#right) : big parenthesis

Greek Letters

The command to produce a lowercase Greek letter is obtained by adding a # to the name of the letter. For an uppercase Greek letter, just capitalize the first letter of the command name. Some letter have two representations. The name of the second one (the "variation") starts with "var". The following table gives the complete list:
output of MACRO_TLatex_17_greek
{
   TCanvas *Gl = new TCanvas("greek","greek",500,700);

   TLatex Tl;
   Tl.SetTextSize(0.03);

   // Draw the columns titles
   Tl.SetTextAlign(22);
   Tl.DrawLatex(0.165, 0.95, "Lower case");
   Tl.DrawLatex(0.495, 0.95, "Upper case");
   Tl.DrawLatex(0.825, 0.95, "Variations");

   // Draw the lower case letters
   Tl.SetTextAlign(12);
   float y, x1, x2;
   y = 0.90; x1 = 0.07; x2 = x1+0.2;
                 Tl.DrawLatex(x1, y, "alpha : ")   ; Tl.DrawLatex(x2, y, "#alpha");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "beta : ")    ; Tl.DrawLatex(x2, y, "#beta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "gamma : ")   ; Tl.DrawLatex(x2, y, "#gamma");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "delta : ")   ; Tl.DrawLatex(x2, y, "#delta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "epsilon : ") ; Tl.DrawLatex(x2, y, "#epsilon");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "zeta : ")    ; Tl.DrawLatex(x2, y, "#zeta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "eta : ")     ; Tl.DrawLatex(x2, y, "#eta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "theta : ")   ; Tl.DrawLatex(x2, y, "#theta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "iota : ")    ; Tl.DrawLatex(x2, y, "#iota");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "kappa : ")   ; Tl.DrawLatex(x2, y, "#kappa");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "lambda : ")  ; Tl.DrawLatex(x2, y, "#lambda");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "mu : ")      ; Tl.DrawLatex(x2, y, "#mu");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "nu : ")      ; Tl.DrawLatex(x2, y, "#nu");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "xi : ")      ; Tl.DrawLatex(x2, y, "#xi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "omicron : ") ; Tl.DrawLatex(x2, y, "#omicron");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "pi : ")      ; Tl.DrawLatex(x2, y, "#pi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "rho : ")     ; Tl.DrawLatex(x2, y, "#rho");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "sigma : ")   ; Tl.DrawLatex(x2, y, "#sigma");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "tau : ")     ; Tl.DrawLatex(x2, y, "#tau");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "upsilon : ") ; Tl.DrawLatex(x2, y, "#upsilon");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "phi : ")     ; Tl.DrawLatex(x2, y, "#phi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "chi : ")     ; Tl.DrawLatex(x2, y, "#chi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "psi : ")     ; Tl.DrawLatex(x2, y, "#psi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "omega : ")   ; Tl.DrawLatex(x2, y, "#omega");

   // Draw the upper case letters
   y = 0.90; x1 = 0.40; x2 = x1+0.2;
                 Tl.DrawLatex(x1, y, "Alpha : ")   ; Tl.DrawLatex(x2, y, "#Alpha");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Beta : ")    ; Tl.DrawLatex(x2, y, "#Beta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Gamma : ")   ; Tl.DrawLatex(x2, y, "#Gamma");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Delta : ")   ; Tl.DrawLatex(x2, y, "#Delta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Epsilon : ") ; Tl.DrawLatex(x2, y, "#Epsilon");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Zeta : ")    ; Tl.DrawLatex(x2, y, "#Zeta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Eta : ")     ; Tl.DrawLatex(x2, y, "#Eta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Theta : ")   ; Tl.DrawLatex(x2, y, "#Theta");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Iota : ")    ; Tl.DrawLatex(x2, y, "#Iota");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Kappa : ")   ; Tl.DrawLatex(x2, y, "#Kappa");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Lambda : ")  ; Tl.DrawLatex(x2, y, "#Lambda");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Mu : ")      ; Tl.DrawLatex(x2, y, "#Mu");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Nu : ")      ; Tl.DrawLatex(x2, y, "#Nu");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Xi : ")      ; Tl.DrawLatex(x2, y, "#Xi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Omicron : ") ; Tl.DrawLatex(x2, y, "#Omicron");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Pi : ")      ; Tl.DrawLatex(x2, y, "#Pi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Rho : ")     ; Tl.DrawLatex(x2, y, "#Rho");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Sigma : ")   ; Tl.DrawLatex(x2, y, "#Sigma");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Tau : ")     ; Tl.DrawLatex(x2, y, "#Tau");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Upsilon : ") ; Tl.DrawLatex(x2, y, "#Upsilon");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Phi : ")     ; Tl.DrawLatex(x2, y, "#Phi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Chi : ")     ; Tl.DrawLatex(x2, y, "#Chi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Psi : ")     ; Tl.DrawLatex(x2, y, "#Psi");
   y -= 0.0375 ; Tl.DrawLatex(x1, y, "Omega : ")   ; Tl.DrawLatex(x2, y, "#Omega");

   // Draw the variations
   x1 = 0.73; x2 = x1+0.2;
   y = 0.7500 ; Tl.DrawLatex(x1, y, "varepsilon : ") ; Tl.DrawLatex(x2, y, "#varepsilon");
   y = 0.6375 ; Tl.DrawLatex(x1, y, "vartheta : ")   ; Tl.DrawLatex(x2, y, "#vartheta");
   y = 0.2625 ; Tl.DrawLatex(x1, y, "varsigma : ")   ; Tl.DrawLatex(x2, y, "#varsigma");
   y = 0.1875 ; Tl.DrawLatex(x1, y, "varUpsilon : ") ; Tl.DrawLatex(x2, y, "#varUpsilon");
   y = 0.1500 ; Tl.DrawLatex(x1, y, "varphi : ")     ; Tl.DrawLatex(x2, y, "#varphi");
   y = 0.0375 ; Tl.DrawLatex(x1, y, "varomega : ")   ; Tl.DrawLatex(x2, y, "#varomega");

   return Gl;
}

Accents

Several kind of accents are available:
   #hat    = #hat{a}
   #check  = #check{a}
   #acute  = #acute{a}
   #grave  = #grave{a}
   #dot    = #dot{a}
   #ddot   = #ddot{a}
   #tilde  = #tilde{a}

The special sign: #slash draws a slash on top of the text between brackets:
   #slash{E}_{T} : #slash{E}_{T}

Bar and vectors sign are done the following way:
   #bar{a}: #bar{a}
   #vec{a}: #vec{a}

Changing Style

One can change the font, the text color, or the text size at any time using : #font[font-number]{...}, #color[color-number]{...} and #scale[scale-factor]{...}

Examples:

   #font[12]{Times Italic} and #font[22]{Times bold} : #font[12]{Times Italic} and #font[22]{Times bold}
   #color[2]{Red} and #color[4]{Blue} : #color[2]{Red} and #color[4]{Blue}
   #scale[1.2]{Bigger} and #scale[0.8]{Smaller} : #scale[1.2]{Bigger} and #scale[0.8]{Smaller}

Alignment Rules

The TText alignment rules apply to the TLatex objects with one exception concerning the vertical alignment:
  • if the vertical alignment = 1 , subscripts are not taken into account
  • if the vertical alignment = 0 , the text is aligned to the box surrounding the full text with sub and superscripts
This is illustrated by the following example:
output of MACRO_TLatex_36_Tlva
{
   TCanvas Tlva("Tlva","Tlva",500,500);
   Tlva.SetGrid();
   Tlva.DrawFrame(0,0,1,1);
   const char *longstring = "K_{S}... K^{*0}... #frac{2s}{#pi#alpha^{2}}
   #frac{d#sigma}{dcos#theta} (e^{+}e^{-} #rightarrow f#bar{f} ) =
   #left| #frac{1}{1 - #Delta#alpha} #right|^{2} (1+cos^{2}#theta)";

   TLatex latex;
   latex.SetTextSize(0.025);
   latex.SetTextAlign(13);  //align at top
   latex.DrawLatex(.2,.9,"K_{S}");
   latex.DrawLatex(.3,.9,"K^{*0}");
   latex.DrawLatex(.2,.8,longstring);

   latex.SetTextAlign(12);  //centered
   latex.DrawLatex(.2,.6,"K_{S}");
   latex.DrawLatex(.3,.6,"K^{*0}");
   latex.DrawLatex(.2,.5,longstring);

   latex.SetTextAlign(11);  //default bottom alignment
   latex.DrawLatex(.2,.4,"K_{S}");
   latex.DrawLatex(.3,.4,"K^{*0}");
   latex.DrawLatex(.2,.3,longstring);

   latex.SetTextAlign(10);  //special bottom alignment
   latex.DrawLatex(.2,.2,"K_{S}");
   latex.DrawLatex(.3,.2,"K^{*0}");
   latex.DrawLatex(.2,.1,longstring);

   latex.SetTextAlign(12);
   latex->SetTextFont(72);
   latex->DrawLatex(.1,.80,"13");
   latex->DrawLatex(.1,.55,"12");
   latex->DrawLatex(.1,.35,"11");
   latex->DrawLatex(.1,.18,"10");
   return Tlva;
}

Examples

output of MACRO_TLatex_38_ex1
{
   TCanvas ex1("ex1","Latex",500,600);
   TLatex Tl;
   Tl.SetTextAlign(12);
   Tl.SetTextSize(0.04);
   Tl.DrawLatex(0.1,0.8,"1)   C(x) = d #sqrt{#frac{2}{#lambdaD}}  #int^{x}_{0}cos(#frac{#pi}{2}t^{2})dt");
   Tl.DrawLatex(0.1,0.6,"2)   C(x) = d #sqrt{#frac{2}{#lambdaD}}  #int^{x}cos(#frac{#pi}{2}t^{2})dt");
   Tl.DrawLatex(0.1,0.4,"3)   R = |A|^{2} = #frac{1}{2}(#[]{#frac{1}{2}+C(V)}^{2}+#[]{#frac{1}{2}+S(V)}^{2})");
   Tl.DrawLatex(0.1,0.2,"4)   F(t) = #sum_{i=-#infty}^{#infty}A(i)cos#[]{#frac{i}{t+i}}");
   return ex1;
}
output of MACRO_TLatex_39_ex2
{
   TCanvas ex2("ex2","Latex",500,300);
   TLatex Tl;
   Tl.SetTextAlign(23);
   Tl.SetTextSize(0.08);
   Tl.DrawLatex(0.5,0.95,"e^{+}e^{-}#rightarrowZ^{0}#rightarrowI#bar{I}, q#bar{q}");
   Tl.DrawLatex(0.5,0.75,"|#vec{a}#bullet#vec{b}|=#Sigmaa^{i}_{jk}+b^{bj}_{i}");
   Tl.DrawLatex(0.5,0.5,"i(#partial_{#mu}#bar{#psi}#gamma^{#mu}+m#bar{#psi}=0#Leftrightarrow(#Box+m^{2})#psi=0");
   Tl.DrawLatex(0.5,0.3,"L_{em}=eJ^{#mu}_{em}A_{#mu} , J^{#mu}_{em}=#bar{I}#gamma_{#mu}I , M^{j}_{i}=#SigmaA_{#alpha}#tau^{#alphaj}_{i}");
   return ex2;
}
output of MACRO_TLatex_40_ex3
{
   TCanvas ex3("ex3","Latex",500,300);
   TPaveText pt(.1,.1,.9,.9);
   pt.AddText("#frac{2s}{#pi#alpha^{2}}  #frac{d#sigma}{dcos#theta} (e^{+}e^{-} #rightarrow f#bar{f} ) = ");
   pt.AddText("#left| #frac{1}{1 - #Delta#alpha} #right|^{2} (1+cos^{2}#theta");
   pt.AddText("+ 4 Re #left{ #frac{2}{1 - #Delta#alpha} #chi(s) #[]{#hat{g}_{#nu}^{e}#hat{g}_{#nu}^{f}
   (1 + cos^{2}#theta) + 2 #hat{g}_{a}^{e}#hat{g}_{a}^{f} cos#theta) } #right}");
   pt.SetLabel("Born equation");
   pt.Draw();
   return ex3;
}

Function Members (Methods)

public:
TLatex()
TLatex(const TLatex& text)
TLatex(Double_t x, Double_t y, const char* text)
virtual~TLatex()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidCopy(TObject& text) const
virtual voidTObject::Delete(Option_t* option = "")MENU
Int_tTAttLine::DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
virtual Int_tTText::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
TLatex*DrawLatex(Double_t x, Double_t y, const char* text)
virtual TText*TText::DrawText(Double_t x, Double_t y, const char* text)
virtual TText*TText::DrawTextNDC(Double_t x, Double_t y, const char* text)
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTText::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual voidGetBoundingBox(UInt_t& w, UInt_t& h, Bool_t angle = kFALSE)
virtual voidTText::GetControlBox(Int_t x, Int_t y, Double_t theta, Int_t* cBoxX, Int_t* cBoxY)
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
Double_tGetHeight() const
virtual const char*TObject::GetIconName() const
virtual Color_tTAttLine::GetLineColor() const
virtual Style_tTAttLine::GetLineStyle() const
virtual Width_tTAttLine::GetLineWidth() const
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual Short_tTAttText::GetTextAlign() const
virtual Float_tTAttText::GetTextAngle() const
virtual voidTText::GetTextAscentDescent(UInt_t& a, UInt_t& d, const char* text) const
virtual Color_tTAttText::GetTextColor() const
virtual voidTText::GetTextExtent(UInt_t& w, UInt_t& h, const char* text) const
virtual Font_tTAttText::GetTextFont() const
virtual Float_tTAttText::GetTextSize() const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
Double_tTText::GetX() const
Double_tGetXsize()
Double_tTText::GetY() const
Double_tGetYsize()
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTText::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual voidTAttText::Modify()
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidPaint(Option_t* option = "")
virtual voidTText::PaintControlBox(Int_t x, Int_t y, Double_t theta)
virtual voidPaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char* text)
virtual voidTText::PaintText(Double_t x, Double_t y, const char* text)
virtual voidTText::PaintTextNDC(Double_t u, Double_t v, const char* text)
virtual voidTObject::Pop()
virtual voidTText::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
virtual voidTAttLine::ResetAttLine(Option_t* option = "")
virtual voidTAttText::ResetAttText(Option_t* toption = "")
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTAttLine::SaveLineAttributes(ostream& out, const char* name, Int_t coldef = 1, Int_t stydef = 1, Int_t widdef = 1)
virtual voidSavePrimitive(ostream& out, Option_t* option = "")
virtual voidTAttText::SaveTextAttributes(ostream& out, const char* name, Int_t alidef = 12, Float_t angdef = 0, Int_t coldef = 1, Int_t fondef = 61, Float_t sizdef = 1)
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidSetIndiceSize(Double_t factorSize)
virtual voidSetLimitIndiceSize(Int_t limitFactorSize)
virtual voidTAttLine::SetLineAttributes()MENU
virtual voidTAttLine::SetLineColor(Color_t lcolor)
virtual voidTAttLine::SetLineStyle(Style_t lstyle)
virtual voidTAttLine::SetLineWidth(Width_t lwidth)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
virtual voidTText::SetNDC(Bool_t isNDC = kTRUE)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTText::SetText(Double_t x, Double_t y, const char* text)MENU
virtual voidTAttText::SetTextAlign(Short_t align = 11)
virtual voidTAttText::SetTextAngle(Float_t tangle = 0)MENU
virtual voidTAttText::SetTextAttributes()MENU
virtual voidTAttText::SetTextColor(Color_t tcolor = 1)
virtual voidTAttText::SetTextFont(Font_t tfont = 62)
virtual voidTAttText::SetTextSize(Float_t tsize = 1)
virtual voidTAttText::SetTextSizePixels(Int_t npixels)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidTText::SetX(Double_t x)MENU
virtual voidTText::SetY(Double_t y)MENU
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
TLatexFormSizeAnal1(TextSpec_t spec, const Char_t* t, Int_t length)
TLatexFormSizeAnalyse(Double_t x, Double_t y, TextSpec_t spec, const Char_t* t, Int_t length)
Int_tCheckLatexSyntax(TString& text)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidDrawCircle(Double_t x1, Double_t y1, Double_t r, TextSpec_t spec)
voidDrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec)
voidDrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec)
TLatexFormSizeFirstParse(Double_t angle, Double_t size, const Char_t* text)
voidTObject::MakeZombie()
TLatex&operator=(const TLatex&)
TLatexFormSizeReadfs()
voidSavefs(TLatexFormSize* fs)

Data Members

public:
enum { kTextNDC
};
enum TText::[unnamed] { kTextNDC
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
const Char_t*fError!error code
Double_tfFactorPos!Relative position of subscripts and superscripts
Double_tfFactorSize!Relative size of subscripts and superscripts
Int_tfLimitFactorSizelower bound for subscripts/superscripts size
Color_tTAttLine::fLineColorline color
Style_tTAttLine::fLineStyleline style
Width_tTAttLine::fLineWidthline width
TStringTNamed::fNameobject identifier
Double_tfOriginSizeFont size of the starting font
Int_tfPos!Current position in array fTabSize;
Bool_tfShow!is true during the second pass (Painting)
Int_tfTabMax!Maximum allocation for array fTabSize;
FormSize_t*fTabSize!array of values for the different zones
Short_tTAttText::fTextAlignText alignment
Float_tTAttText::fTextAngleText angle
Color_tTAttText::fTextColorText color index
Font_tTAttText::fTextFontText font number
Float_tTAttText::fTextSizeText size
TStringTNamed::fTitleobject title
Double_tTText::fXX position of text (left,center,etc..)
Double_tTText::fYY position of text (left,center,etc..)

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TLatex(const TLatex& text)
 Default constructor.
TLatex(Double_t x, Double_t y, const char* text)
 Normal constructor.
~TLatex()
 Destructor.
TLatex(const TLatex& text)
 Copy constructor.
TLatex& operator=(const TLatex& )
assignment operator
void Copy(TObject& text) const
 Copy this TLatex object to another TLatex.
TLatexFormSize Anal1(TextSpec_t spec, const Char_t* t, Int_t length)
 Analyse function.
TLatexFormSize Analyse(Double_t x, Double_t y, TextSpec_t spec, const Char_t* t, Int_t length)
  Analyse and paint the TLatex formula

  It is called twice : first for calculating the size of
  each portion of the formula, then to paint the formula.
  When analyse finds an operator or separator, it calls
  itself recursively to analyse the arguments of the operator.
  when the argument is an atom (normal text), it calculates
  the size of it and return it as the result.
  for example : if the operator #frac{arg1}{arg2} is found :
  Analyse(arg1) return the size of arg1 (width, up, down)
  Analyse(arg2) return the size of arg2
  now, we know the size of #frac{arg1}{arg2}  :
  width = max(width_arg1, width_arg2)
  up = up_arg1 + down_arg1
  down = up_arg2 + down_arg2
  so, when the user wants to paint a fraction at position (x,y),
  the rect used for the formula is : (x,y-up,x+width,y+down)

 return size of zone occupied by the text/formula
 t : chain to be analyzed
 length : number of chars in t.
TLatex * DrawLatex(Double_t x, Double_t y, const char* text)
 Make a copy of this object with the new parameters
 And copy object attributes
void DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2, TextSpec_t spec)
 Draw a line in a Latex formula
void DrawCircle(Double_t x1, Double_t y1, Double_t r, TextSpec_t spec)
 Draw an arc of ellipse in a Latex formula (right or left parenthesis)
void DrawParenthesis(Double_t x1, Double_t y1, Double_t r1, Double_t r2, Double_t phimin, Double_t phimax, TextSpec_t spec)
 Draw an arc of ellipse in a Latex formula (right or left parenthesis)
void Paint(Option_t* option = "")
 Paint.
void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char* text)
 Main drawing function

 Warning: Unlike most others "XYZ::PaintXYZ" methods, PaintLatex modifies
          the TLatex data members.
Int_t CheckLatexSyntax(TString& text)
 Check if the Latex syntax is correct
TLatexFormSize FirstParse(Double_t angle, Double_t size, const Char_t* text)
 First parsing of the analyse sequence
Double_t GetHeight()
 Return height of current pad in pixels
Double_t GetXsize()
 Return size of the formula along X in pad coordinates
void GetBoundingBox(UInt_t& w, UInt_t& h, Bool_t angle = kFALSE)
 Return text size in pixels
Double_t GetYsize()
 Return size of the formula along Y in pad coordinates
TLatexFormSize Readfs()
 Read fs in fTabSize
void Savefs(TLatexFormSize* fs)
 Save fs values in array fTabSize
void SavePrimitive(ostream& out, Option_t* option = "")
 Save primitive as a C++ statement(s) on output stream out
void SetIndiceSize(Double_t factorSize)
 Set relative size of subscripts and superscripts
void SetLimitIndiceSize(Int_t limitFactorSize)
 Set limit for text resizing of subscipts and superscripts

Author: Nicolas Brun 07/08/98
Last change: root/graf:$Id: TLatex.h 20882 2007-11-19 11:31:26Z rdm $
Last generated: 2008-06-25 08:47
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.