Hi Stephen, I have implemented a new vertical alignment option in TLatex to support what you want. I have modified the default vertical alignment (1) to be what you want and introduce a new vertical alignment (0) to behave like the previous vertical alignment. I have updated the CVS repository and generated the corresponding html documentation with an example of all cases at: http://root.cern.ch/root/html/TLatex.html Rene Brun Stephen Bailey wrote: > > OK. For a single TLatex::DrawLatex command the alignment is good > within that command. My problem is trying to align several DrawLatex > commands. Initially I was aligning commands like: > > latex.DrawLatex(0.1, 0.8, "B^{0} #rightarrow J/#psi K^{*0}"); > latex.DrawLatex(0.4, 0.8, "Preliminary Result"); > > They aligned as I expected (and wanted), with the baselines vertically > aligned even though letters like #psi and y extended below the baseline. > But when I went to make another plot with a different label: > > latex.DrawLatex(0.1, 0.6, "B_{s} #rightarrow J/#psi K_{S}"); > latex.DrawLatex(0.4, 0.6, "Preliminary Result"); > > my baseline were no longer aligned and I had to adjust the vertical > position of the first command in order to get it to align the baseline > with the second one. I had expected the subscripts s and S to extend > below the baseline just as the tail of the #psi and y did in the first > example. I find it inconvenient to have to adjust the vertical position > of my TLatex commands based upon whether they have subscripts or not. > > I like the internal alignment of a single command. If you could adjust > the overall alignment such that > > latex.DrawLatex(0.1, 0.8, "K_{S}"); > latex.DrawLatex(0.2, 0.8, "K^{*0}"); > > would produce the same vertical alignment between the two K's as > > latex.DrawLatex(0.1, 0.1, "K_{S} K^{*0}"); > > does, I think that would be great. Is that possible? > > Thanks. > > Stephen > > On Wed, 9 Aug 2000, Rene Brun wrote: > > > Hi Stephen, > > Root produces the same output as LateX. See macro below where you can play > > with the vertical text alignment. > > > > Rene Brun > > > > { > > gROOT->Reset(); > > TCanvas c1("c1"); > > c1.SetGrid(); > > TH2F h("h","",2,0,1,2,0,1); > > h.Draw(); > > TLatex latex; > > latex.SetTextSize(0.04); > > latex.SetTextAlign(12); > > latex.DrawLatex(0.1, 0.8, "K_{S}"); > > latex.DrawLatex(0.1, 0.6, "K^{*0}"); > > latex.DrawLatex(0.4, 0.6, "K_{S} K^{*0}"); > > latex.DrawLatex(.1,.4,"#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)"); > > latex.DrawLatex(.1,.1,"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)"); > > } > > > > > > Stephen Bailey wrote: > > > > > > Hi Rene. > > > > > > Hmm. Good question. I answer it by finding out how LaTeX > > > would format it: to me, if LaTeX has formatted it, it is by > > > definition correctly formatted. I LaTeX'ed the following > > > and attached it as a .eps file. > > > > > > \documentclass{article} > > > \begin{document} > > > \pagestyle{empty} > > > $K_{S}$ ... $K^{*0}$ ... > > > ${2s \over \pi \alpha^2} {d \sigma \over d \cos \theta} > > > (e^+ e^- \to f \bar f) = \left| {1 \over 1 - \Delta \alpha} \right|^2 > > > (1 + \cos^2\theta)$ > > > \end{document} > > > > > > The bottom of the two K 's are aligned with each other and the bottom > > > of the e^+ e^- ... The fraction bars are centered on the middle of > > > the height of the lowercase letters that sit on the baseline. I agree > > > that there are infinitely cascading subtlties as the formulas get > > > more complicated. Short of entirely reproducing LaTeX, it is impossible > > > to anticipate them all. But if ROOT ever switches to a Postscript based > > > graphics rendering that can easily embed .eps files on a canvas, I'm > > > writing a class that will run LaTeX to produce an .eps file and embed > > > it... But I guess for now, I suggest: > > > > > > * TLatex output be aligned to some baseline that normal letters "sit" > > > on and super/sub-scripts go up and down from there. > > > * In the case of fractions, the line is vertically aligned somewhere > > > above the baseline, and their text sits on baselines above and below > > > that. > > > * In the case of complicated structures like fractions, etc. there be > > > some rule such that the equation can never overlap itself. e.g. if > > > there is a superscript in the denominator of a fraction, the baseline > > > for the denominator is low enough that the superscript doesn't hit > > > the fraction line. > > > > > > I don't know how realistic or easy these requests are, or what > > > other subtlties might come up. But for now, I'd be happy to be > > > able to align "basic" structures like K_{S} and the K^{*0}. > > > > > > Thanks. > > > > > > Stephen > > > > > > On Tue, 8 Aug 2000, Rene Brun wrote: > > > > > > > Hi Stephen, I understand your point in this particular example, but > > > > your proposal would have plenty of side effects. For example, what > > > > would you propose for the 3rd Tlatex string in my macro below? > > > > > > > > Rene Brun > > > > > > > > { > > > > gROOT->Reset(); > > > > TCanvas c1("c1"); > > > > c1.SetGrid(); > > > > TH2F h("h","",2,0,1,2,0,1); > > > > h.Draw(); > > > > TLatex latex; > > > > latex.DrawLatex(0.1, 0.5, "K_{S}"); > > > > TLatex *l=(TLatex*)latex.DrawLatex(0.1, 0.3, "K^{*0}"); > > > > latex.DrawLatex(.1,.1,"#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)"); > > > > } > > > > > > > > > > > > > > > > Stephen Bailey wrote: > > > > > > > > > > Hi Rooters, > > > > > > > > > > TLatex appears to vertically align text based upon > > > > > the lowest/highest element drawn, including sub/superscripts. > > > > > e.g. > > > > > > > > > > TLatex latex; > > > > > latex.SetNDC(); > > > > > latex.DrawLatex(0.5, 0.5, "K_{S}"); > > > > > latex.DrawLatex(0.6, 0.5, "K^{*0}"); > > > > > > > > > > aligns the bottom of the subscripted "S" with the bottom of the > > > > > other K. I would prefer the alignment to be based upon the bottom > > > > > of the normal script, i.e. have the two K aligned and have the > > > > > S be lowered from there and the *0 be raised. > > > > > > > > > > Do others agree? Would this be easily possible? > > > > > > > > > > Thanks. > > > > > > > > > > Stephen > > > > > > > > > > -------------------------------------------------------------------------------- > > > > > > Name: temp.eps > > > temp.eps Type: Postscript Document (APPLICATION/PostScript) > > > Encoding: BASE64 > >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:31 MET