A problem when convert to Tex
- Subject: A problem when convert to Tex
- From: Raymond Toy
- Date: Wed, 09 Feb 2005 10:28:00 -0500
>>>>> "Andrei" == Andrei Zorine writes:
Andrei> Try to change not texnumformat, but write a function
Andrei> (defun numneedsparen(atom)
Andrei> (let (r exponent)
Andrei> (cond ((integerp atom) nil)
Andrei> (t (setq r (exploden atom)
Andrei> exponent (member 'e r :test #'string-equal))
Andrei> exponent)))
Andrei> and change tex-mexpt as follows:
Andrei> (defun tex-mexpt (x l r)
Andrei> (let((nc (eq (caar x) 'mncexpt))) ; true if a^^b rather than a^b
Andrei> (cond ;; this whole clause
Andrei> [snip]
Andrei> (cond (doit
Andrei> [snip]
Andrei> ))
Andrei> (t nil))))) ; won't doit. fall through
Andrei> ;; changes here! Write parens if a number needs it!
Andrei> (t (setq l (cond ((and (numberp (cadr x))
Andrei> (numneedsparen (cadr x)))
Andrei> (tex (cadr x) (cons "\left(" l) '("\right)") lop
Andrei> (caar x)))
Andrei> (t (tex (cadr x) l nil lop (caar x))))
Andrei> r ( ;;; leave untouched
This seems to work:
(%i48) tex(5.6e99^x);
$$left({5.6 \times 10^{+99}}right)^{x}$$
(%i49) tex(47.5^y);
$$47.5^{y}$$
Any reason not to apply this?
Ray