Questions about Tex output



On 9/1/07, Yigal Asnis <yigalasnis at yahoo.com> wrote:

> 1. I did'nt find Lisp function for Tex output. Is
> there one?

Hi Yigal, the Lisp function TEX1 does all the work
for the Maxima function tex.
You can see in src/mactex.lisp that $TEX calls TEX1 after
maybe binding *STANDARD-OUTPUT*.

> 2. Maxima's Tex function give the output as "false"
> and the Tex-formatted expression as side-effect, so
> tex-formatted-expr: tex(expr);
> or, in Lisp:
> (setf tex-formatted-expr #$tex (expr)$)
> not working. What is the way to assign the
> tex-formatted expression to Maxima's or Lisp's
> variable?

When the 2nd argument of tex = false, then tex returns a Lisp string.
e.g.
my_tex_output : tex (x + y, false);
my_tex_output;
 => $$y+x$$

I see that is not mentioned in the documentation for tex.
I'll fix that.

> 3. Why $tex function is undefined in Clisp, even
> though I can use $parse_string or $file_search, for
> example?

$TEX is not an ordinary Lisp function. It is defined via the DEFMSPEC
macro which assigns an ordinary Lisp function to the MFEXPR*
property of $TEX. The Maxima evaluator does not evaluate
the arguments of DEFMSPEC functions before calling the MFEXPR*
function. The MFEXPR* function for, say, $FOO, expects an expression
like (($FOO) A B C) instead of just the arguments A B C.

>From the user's point of view, a DEFMSPEC function
"quotes its arguments". That is only approximately true:
a DEFMSPEC might call MEVAL to evaluate its arguments anyway,
and it is MEVAL, not the function, which is responsible for argument
evaluation or the lack of it.

So, to get an effect similar to (PUTATIVE-$TEX-FUNCTION FOO) there
are a few possibilities.

(1) (MEVAL `(($TEX) ,FOO))
(2) (FUNCALL (GET '$TEX 'MFEXPR*) `(($TEX) ,FOO))
(3) (LET ((*STANDARD-OUTPUT* <whatever>)) (TEX1 FOO))

For (1) and (2), a 2nd argument NIL tells $TEX to return a string.
For (3) you'll have to bind *STANDARD-OUTPUT* to a string
output stream (which is what $TEX does before calling TEX1).

Hope this helps,
Robert Dodier