Here are descriptions of some mactex bugs and my fixes. I've
included a diff file for the most recent version of mactex.
I believe patches comply with the proposed Maxima MPR
(minimal patch rule).
My Maxima is 5.6; GCL is 2.4; gcc is 2.91; and OS is RedHat 6.1.
1. ------------------------------
Problem: Missing parens in powers of symbolic summations and products:
(C4) tex((sum(a(k),k,0,n))^2);
$$\sum_{k=0}^{n}{a\left(k\right)}^2$$
(D4) FALSE
(C5)
Fix: Change the tex right binding powers of %sum and %product:
(defprop %sum 110. tex-rbp)
(defprop %product 115. tex-rbp)
2. -------------------------------
Problem: Powers of derivatives, integrals, and "at"
(C1) tex('(diff(f,x))^2);
$$DIFF^2\left(\left(f,x\right)\right)$$
(D1) FALSE
(C2) tex('at(f(x),x=3)^2);
$$%AT^2\left(f\left(x\right),x=3\right)$$
(D2) FALSE
Fix: In tex-mexpt, change
(not (memq f '(%sum %product))) ;; what else? what a hack...
to
(not (memq f '(%sum %product %derivative %integral %at))) ;; what else? what a hack...
3. -------------------------------
Problem: Multiple subscripts:
(C2) tex(f[1][2]);
$$
Error: ((|$f| SIMP ARRAY) 1) is not of type SYMBOL.
Fix: Change tex-array to do the right thing when (eq 'mqapply (caar x)).
New tex-array is (only changed (setq l ...)
(defun tex-array (x l r)
(let ((f))
(if (eq 'mqapply (caar x))
(setq f (cadr x)
x (cdr x)
l (tex f (append l (list "\\left(")) (list "\\right)") 'mparen 'mparen))
(setq f (caar x)
l (tex (texword f) l nil lop 'mfunction)))
(setq
r (nconc (tex-list (cdr x) nil (list "}") ",") r))
(nconc l (list "_{") r )))
4. -------------------------------
Problem: Trailing space missing in some infix operators:
(C3) tex(a <= b);
$$a\leqb$$
(D3) FALSE
Fix: Add the spaces, for example, change
(defprop mgeqp ("\\leq") texsym)
to
(defprop mgeqp ("\\leq ") texsym)
5. --------------------------------
Problem: Double floats:
(C7) tex(1.3d-99);
$$
Error: The function STRCAT is undefined.
Fix: Define strcat for gcl:
#+(or cmu gcl) ;; any others?
(defun strcat (&rest args)
(apply #'concatenate 'string (mapcar #'string args)))
6. --------------------------------
Problem: Typo in (defun tex-d(x dsym) prevents diff operator in numerator
from being \\partial.
Fix: Change
(numer `((mexpt) $|d| ((mplus) ,@ords))) ; d^n numerator
To
(numer `((mexpt) dsym ((mplus) ,@ords))) ; d^n numerator
Also change the comment from
(defun tex-d(x dsym) ;dsym should be $d or "$d\\partial"
to
(defun tex-d(x dsym) ;dsym should be $d or "$\\partial"
My diff file is
-----start of diff; cut here------------------------------
--- mactex.lisp Mon Oct 01 09:09:28 2001
+++ unk_mactex.lisp Mon Oct 01 12:35:42 2001
@@ -2,8 +2,7 @@
;; TeX-printing
;; (c) copyright 1987, Richard J. Fateman
;; small corrections and additions: Andrey Grozin, 2001
-
-
+;; additional corrections: Barton Willis (BLW), October 2001
;; Usage: tex(d8,"/tmp/foo.tex"); tex(d10,"/tmp/foo.tex"); ..
;; to append lines d8 and d10 to the tex file. If given only
@@ -248,7 +247,7 @@
; ((eql l 1) pname)
; (t (concatenate 'string "\\mathrm{" pname "}")))))
-#+cmu
+#+(or cmu gcl) ;; any others?
(defun strcat (&rest args)
(apply #'concatenate 'string (mapcar #'string args)))
@@ -279,10 +278,11 @@
(let ((f))
(if (eq 'mqapply (caar x))
(setq f (cadr x)
- x (cdr x))
- (setq f (caar x)))
- (setq l (tex (texword f) l nil lop 'mfunction)
-
+ x (cdr x)
+ l (tex f (append l (list "\\left(")) (list "\\right)") 'mparen 'mparen))
+ (setq f (caar x)
+ l (tex (texword f) l nil lop 'mfunction)))
+ (setq
r (nconc (tex-list (cdr x) nil (list "}") ",") r))
(nconc l (list "_{") r )))
@@ -439,6 +439,9 @@
(defprop mexpt 140. tex-lbp)
(defprop mexpt 139. tex-rbp)
+(defprop %sum 110. tex-rbp) ;; added by BLW, 1 Oct 2001
+(defprop %product 115. tex-rbp) ;; added by BLW, 1 Oct 2001
+
;; insert left-angle-brackets for mncexpt. a^<n> is how a^^n looks.
(defun tex-mexpt (x l r)
(let((nc (eq (caar x) 'mncexpt))); true if a^^b rather than a^b
@@ -460,7 +463,7 @@
(doit (and
f ; there is such a function
(memq (getchar f 1) '(% $)) ;; insist it is a % or $ function
- (not (memq f '(%sum %product))) ;; what else? what a hack...
+ (not (memq f '(%sum %product %derivative %integral %at))) ;; what else? what a hack...
(or (and (atom expon) (not (numberp expon))) ; f(x)^y is ok
(and (atom expon) (numberp expon) (> expon 0))))))
; f(x)^3 is ok, but not f(x)^-1, which could
@@ -722,7 +725,7 @@
(defun tex-derivative (x l r)
(tex (tex-d x '$|d|) l r lop rop ))
-(defun tex-d(x dsym) ;dsym should be $d or "$d\\partial"
+(defun tex-d(x dsym) ;dsym should be $d or "$\\partial"
;; format the macsyma derivative form so it looks
;; sort of like a quotient times the deriva-dand.
(let*
@@ -730,7 +733,7 @@
(difflist (cddr x)) ;; list of derivs e.g. (x 1 y 2)
(ords (odds difflist 0)) ;; e.g. (1 2)
(vars (odds difflist 1)) ;; e.g. (x y)
- (numer `((mexpt) $|d| ((mplus) ,@ords))) ; d^n numerator
+ (numer `((mexpt) dsym ((mplus) ,@ords))) ; d^n numerator
(denom (cons '(mtimes)
(mapcan #'(lambda(b e)
`(,dsym ,(simplifya `((mexpt) ,b ,e) nil)))
----end of diff; cut here-----------------------------------
Regards,
Barton Willis