______________________________________________________________________________
TLatex : to draw Mathematical Formula
This class has been implemented by
Nicolas Brun .
========================================================
TLatex's purpose is to write mathematical equations
The syntax is very similar to the Latex one :
** 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).
p
** 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.
** splitting a line in two lines
--------------------------------
A text can be split in two lines via the command #splitline
For example #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.
ex: #sqrt{10} #sqrt[3]{10}
** Mathematical Symbols
-----------------------
TLatex can make 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 :
#Box draw a square
#perp draw the perpendicular symbol
#odot draw odot
#hbar draw h-bar (Planck constant divided by 2*Pi)
#parallel draw the parallel symbol
** Delimiters
-------------
You can produce 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".
#alpha #beta #chi #delta #varepsilon #phi #gamma #eta #iota #varphi #kappa #lambda
#mu #nu #omicron #pi #theta #rho #sigma #tau #upsilon #varomega #omega #xi #psi #zeta
#Alpha #Beta #Chi #Delta #Epsilon #Phi #Gamma #Eta #Iota #vartheta
#Kappa #Lambda #Mu #Nu #Omicron #Pi #Theta #Rho #Sigma #Tau
#Upsilon #varsigma #Omega #Xi #Psi #Zeta #varUpsilon #epsilon
** Putting One Thing Above Another
----------------------------------
Symbols in a formula are sometimes placed on above another. TLatex provides
special commands for doing this.
** Accents
----------
#hat{a} = hat
#check = inversed hat
#acute = acute
#grave = agrave
#dot = derivative
#ddot = double derivative
#tilde = tilde
#slash special sign. Draw a slash on top of the text between brackets
for example #slash{E}_{T} generates "Missing ET"
#dot #ddot #hat #check #acute #grave #tilde
** Changing Style in Math Mode
------------------------------
You can change the font and the text color at any moment using :
#font[font-number]{...} and #color[color-number]{...}
** Example1
-----------
The following macro (tutorials/latex.C) produces the following picture:
{
gROOT->Reset();
TCanvas c1("c1","Latex",600,700);
TLatex l;
l.SetTextAlign(12);
l.SetTextSize(0.04);
l.DrawLatex(0.1,0.8,"1) C(x) = d #sqrt{#frac{2}{#lambdaD}} #int^{x}_{0}cos(#frac{#pi}{2}t^{2})dt");
l.DrawLatex(0.1,0.6,"2) C(x) = d #sqrt{#frac{2}{#lambdaD}} #int^{x}cos(#frac{#pi}{2}t^{2})dt");
l.DrawLatex(0.1,0.4,"3) R = |A|^{2} = #frac{1}{2}(#[]{#frac{1}{2}+C(V)}^{2}+#[]{#frac{1}{2}+S(V)}^{2})");
l.DrawLatex(0.1,0.2,"4) F(t) = #sum_{i=-#infty}^{#infty}A(i)cos#[]{#frac{i}{t+i}}");
}
** Example2
-----------
The following macro (tutorials/latex2.C) produces the following picture:
{
gROOT->Reset();
TCanvas c1("c1","Latex",600,700);
TLatex l;
l.SetTextAlign(23);
l.SetTextSize(0.1);
l.DrawLatex(0.5,0.95,"e^{+}e^{-}#rightarrowZ^{0}#rightarrowI#bar{I}, q#bar{q}");
l.DrawLatex(0.5,0.75,"|#vec{a}#bullet#vec{b}|=#Sigmaa^{i}_{jk}+b^{bj}_{i}");
l.DrawLatex(0.5,0.5,"i(#partial_{#mu}#bar{#psi}#gamma^{#mu}+m#bar{#psi}=0#Leftrightarrow(#Box+m^{2})#psi=0");
l.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}");
}
** Example3
-----------
The following macro (tutorials/latex3.C) produces the following picture:
{
gROOT->Reset();
TCanvas c1("c1");
TPaveText pt(.1,.5,.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();
}
** 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 in the following example:
{
gROOT->Reset();
TCanvas c1("c1","c1",600,500);
c1.SetGrid();
c1.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.033);
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");
}
______________________________________________________________________________