A problem when convert to Tex



No, in TeX  $${5.6 \times 10^{+99}}^{x}$$ means 5.6 10^(99^x) and not
(5.6 10^99)^x.  Something like your idea

(defun texnumformat(atom)
  (let (r firstpart exponent)
    (cond ((integerp atom)
           atom)
          (t
           (setq r (exploden atom))
           (setq exponent (member 'e r :test #'string-equal)) ;; is it 
ddd.ddde+EE
           (cond ((null exponent)
                  ;; it is not. go with it as given
                  atom)
                 (t
                  (setq firstpart
                        (nreverse (cdr (member 'e (reverse r) :test 
#'string-equal))))
                  (strcat "\\left(" (apply #'strcat firstpart )
                          " \\times 10^{"
                          (apply #'strcat (cdr exponent))
                          "}" "\\right)")))))))

eliminates the bug, BUT this code gratuitously puts parens around all 
floats.

(%i10) tex(5.6e99^x);
$$\left(5.6 \times 10^{+99}\right)^{x}$$
(%o10)                                      false
(%i11) tex(5.6e99);
$$\left(5.6 \times 10^{+99}\right)$$
(%o11)                                      false

I think texnumformat doesn't have enough information to know if the
parens are needed---maybe texnumformat needs more arguments?

With gcl, there is the ugly +99 (instead of just  99) as well ...

Barton




Raymond Toy 
Sent by: maxima-admin@math.utexas.edu
01/27/2005 09:15 AM

 
        To:     Barton Willis 
        cc:     zycentre-sub@yahoo.com.cn, maxima@math.utexas.edu
        Subject:        Re: [Maxima] A problem when convert to Tex



Here is a simple solution.  The very end of texnumformat could be
replaced with

                  (strcat "{"
                                                   (apply #'strcat 
firstpart )
                                                   " \\times 10^{"
                                                   (apply #'strcat (cdr 
exponent))
                                                   "}"
                                                   "}")

This places an extra set of braces around the number.  That causes tex
to produce 

(%i4) tex(5.6e99^x);
$${5.6 \times 10^{+99}}^{x}$$
(%o4) false

That should be ok, right?  (Hmm, why does my version of maxima say +99
instead of just 99?)  Also, the (%o4) line is actually on the same
line as the tex output.  I don't think that's what we want.  Some
recent change in maxima?

Ray

_______________________________________________
Maxima mailing list
Maxima@www.math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima