Exporting examples for use in other applications



On 11/12/2012 09:57 PM, Dan wrote:
> On Mon, 12 Nov 2012, Leo Butler wrote:
>
>> Hello Christian, Maxima has the tex command, which will produce a tex
>> string representing the maxima object. This can be heavily customized
>> via the texput command.
>
> Are there any published "standard" sets of texput commands?  I'd be
> particularly interested in one that typesets its output using the
> LaTeX macros.
>
I don't know. But if you are interested in getting LaTeX rather than 
plain TeX output, I think a better thing to do would be to create a 
latex command using src/mactex.lisp copying with some modifications. For 
example, in mactex.lisp you will find this function:

(defun tex-mquotient (x l r)
   (if (or (null (cddr x)) (cdddr x)) (wna-err (caar x)))
   (setq l (tex (cadr x) (append l '("{{")) nil 'mparen 'mparen)
                                         ;the divide bar groups things
         r (tex (caddr x) (list "}\\over{") (append '("}}")r) 'mparen 
'mparen))
   (append l r))

We can replace it like this:

(%i5) to_lisp();

Type (to-maxima) to restart, ($quit) to quit Maxima.

MAXIMA> (defun tex-mquotient (x l r)
   (if (or (null (cddr x)) (cdddr x)) (wna-err (caar x)))
   (setq l (tex (cadr x) (append l '("\\frac{")) nil 'mparen 'mparen)
         r (tex (caddr x) (list "}{") (append '("}")r) 'mparen 'mparen))
   (append l r))
STYLE-WARNING: redefining MAXIMA::TEX-MQUOTIENT in DEFUN

TEX-MQUOTIENT
MAXIMA> (to-maxima)
Returning to Maxima

(%i6) tex(('diff(f,x)-a)/b);
$$\frac{\frac{d}{d\,x}\,f-a}{b}$$

It would be really nice to have a latex() function and even amslatex().
Regards,
Jaime