user-defined TeX output functions
- Subject: user-defined TeX output functions
- From: Robert Dodier
- Date: Sun, 21 Dec 2008 15:04:29 -0700
Hello,
there was a question about user-defined TeX output a few months ago.
I've come up a modification to the existing texput function such that
texput(foo, texfoo) calls a Maxima function texfoo to generate the TeX
output for operator foo.
Seem to work OK. See PS below for a batch script and the attached
png image for the output as rendered by latex + xdvi.
Comments?
Robert Dodier
PS.
S : openw ("/tmp/texfoo.tex");
printf (S, "\\documentclass{article}~%");
printf (S, "\\begin{document}~%");
tex_foo (e) := concat ("\\Phi_{\\upsilon}\\left(", tex1 (first (e)),
"\\right)");
texput (foo, tex_foo);
tex (foo (1), S);
tex (foo (foo (1)), S);
tex (a + 1 + foo (2) / foo (3), S);
tex_if (e):= block ([L : args (e)], concat
("\\left\\{\\begin{array}{ll}", tex1 (L[2]), "&", tex1 (L[1]), "\\\\",
tex1 (L[4]), "&\\mbox{otherwise}\\end{array}\\right."));
texput (verbify ("if"), tex_if);
texput (nounify ("if"), tex_if);
tex (if x > 0 then sin(x) else cos(x), S);
tex (if x > 0 then sin(x) else if x < 0 then cos(x) else 0, S);
tex_diff (e) := block ([a, b, c], [a, b, c] : args (e),
concat ("{\\partial^", tex1 (c), "\\over\\partial ", tex1 (b),
"^", tex1 (c), "}", tex1 (a)));
texput (nounify (diff), tex_diff);
tex ('diff (foo (w), w), S);
tex_integrate (e) := block ([a, b, c, d], [a, b, c, d] : args (e),
concat ("\\int_{", tex1 (c), "}^{", tex1 (d), "}", tex1 (a), "
d\\!", tex1 (b)));
texput (nounify (integrate), tex_integrate);
tex ('integrate (sin(u) / exp(u), u, 0, inf), S);
tex ('if n > 0 then 'diff (foo (z), z, 3) else 'integrate (foo (z), z,
0, 2*%pi), S);
printf (S, "\\end{document}~%");
close (S);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: texfoo.png
Type: image/png
Size: 12100 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20081221/82dc6f83/attachment.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mactex.lisp-texput-patch
Type: application/octet-stream
Size: 2359 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20081221/82dc6f83/attachment.obj