Bugs in tex-mcond
- Subject: Bugs in tex-mcond
- From: Mark H Weaver
- Date: Tue, 11 Jan 2011 15:10:36 -0500
Robert,
I like your version of tex-mcond very much! It is far superior to the
old style of display, and ideal for beautiful display of piecewise
functions.
There are some contexts, e.g. large procedural function definitions,
where we might want MCONDs displayed in the old style, except with
automatic line breaks and indentation.
I agree that there should be a global variable to switch to the old
style if desired, but my preference is that your MCOND display style
should be the default.
Mark
Robert Dodier <robert.dodier at gmail.com> writes:
> 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)