Wrong text() adjustment with (math)expression and "\n" (PR#299)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
28 Oct 1999 16:33:40 +0200

maechler@stat.math.ethz.ch writes:

> This is adapted from  partha_bagchi@hgsi.com 's report on R-help:
>      plot(0); title(expression("Bad\n with much much more text")))
> gives something like 
>       Bad
>           with much much more text
> (``newline w/o carriage return'') instead of centering both lines such as
>                Bad
>      with much much more text
> which is produced by (just dropping `expression' from the above)
>       plot(0); title(("Bad\n with much much more text"))
> By the way, the following would need even more attention if one insists on 
> correct behavior:
> plot(0)
> title(expression(paste("Still works with math\n", "with", 
>                        frac(1,sum(x[i], i==1,n)), " and more text")))

I'm not sure I'm buying that this is a bug. To see what is really
going on try something like:


what happens is that the strings get set *individually* as multiline
text with (left,bottom) adjustment. If you look closer, Martin's
example really gives

      with much much more text

We could relatively easily make the adjustment (center,center) I think,
but that isn't very useful, and Partha was expecting the whole thing to
continue on a new line. I think that is rather difficult to achieve
because the relation between the expression as text and as a parse
tree is not linear and things mean different things in different
positions (consider "a\nb"+"a\nb"^"a\nb"). To actually have a formula
title split over several lines, I'd suggest fiddling with mtext().

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch