Bugs in tex-mcond
- Subject: Bugs in tex-mcond
- From: Robert Dodier
- Date: Mon, 10 Jan 2011 23:15:14 -0700
I have a different patch for tex-mcond.
I pasted the output into a TeX document and
generated a PDF (attached) from it.
FWIW
Robert Dodier
PS. Here are some example outputs:
(%i2) tex (if x < 0 then foo);
\begin{equation}
\left\{\begin{array}{ll}{\it foo} & \mathrm{if}\; x<
0 \\ \mathbf{false}& \mathrm{otherwise}\end{array}\right.
\end{equation}
(%o2) false
(%i3) tex (if x < 0 then foo else bar);
\begin{equation}
\left\{\begin{array}{ll}{\it foo} & \mathrm{if}\; x<
0 \\ {\it bar}& \mathrm{otherwise}\end{array}\right.
\end{equation}
(%o3) false
(%i4) tex (if x < 0 then foo elseif x > 0 then bar else baz);
\begin{equation}
\left\{\begin{array}{ll}{\it foo} & \mathrm{if}\; x<
0 \\ {\it bar} & \mathrm{if}\; x>0 \\ {\it baz}& \mathrm{otherwise}
\end{array}\right.
\end{equation}
(%o4) false
(%i5) tex (if x < 0 then foo else if x > 0 then bar else baz);
\begin{equation}
\left\{\begin{array}{ll}{\it foo} & \mathrm{if}\; x<
0 \\ \left(\left\{\begin{array}{ll}{\it bar} & \mathrm{if}\; x>0 \\
{\it baz}& \mathrm{otherwise}\end{array}\right.\right)
& \mathrm{otherwise}\end{array}\right.
\end{equation}
PPS. Here's the patch.
--- src/mactex.lisp 22 Nov 2009 04:53:36 -0000 1.71
+++ src/mactex.lisp 14 Nov 2010 08:00:51 -0000
@@ -888,6 +892,11 @@
(defprop mcond tex-mcond tex)
(defprop %mcond tex-mcond tex)
+(setf (get 'mcond 'tex-environment)
+ `(,(format nil "~%\\begin{equation}~%") . ,(format nil
"~%\\end{equation}~%")))
+
+(setf (get '%mcond 'tex-environment) (get 'mcond 'tex-environment))
+
(defprop %derivative tex-derivative tex)
(defun tex-derivative (x l r)
(tex (if $derivabbrev
@@ -939,12 +948,17 @@
(defun tex-mcond (x l r)
(append l
- (tex (cadr x) '("\\mathbf{if}\\;")
- '("\\;\\mathbf{then}\\;") 'mparen 'mparen)
- (if (eql (fifth x) '$false)
- (tex (caddr x) nil r 'mcond rop)
- (append (tex (caddr x) nil nil 'mparen 'mparen)
- (tex (fifth x) '("\\;\\mathbf{else}\\;") r 'mcond rop)))))
+ '("\\left\\{\\begin{array}{ll}")
+ (apply #'append
+ (mapcar
+ #'(lambda (p e)
+ (if (eq p t)
+ (tex e nil '("& \\mathrm{otherwise}") nil nil)
+ (tex-list (list e p) nil '(" \\\\ ") " &
\\mathrm{if}\\; ")))
+ (odds (rest x) 1)
+ (odds (rest x) 0)))
+ '("\\end{array}\\right.")
+ r))
(defprop mdo tex-mdo tex)
(defprop mdoin tex-mdoin tex)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.pdf
Type: application/pdf
Size: 25544 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20110110/2e041c95/attachment-0001.pdf>