Search code examples
maxima

How to output every `log` as `ln` in tex output in maxima?


So I tried

texput(%e, "\e"); texput(log, "\\ln");

But if I call the tex function:

tex(%e*log(3));

This gives:

$$\e\,\log 3$$

But I actually expected:

$$\e\,\ln 3$$

So my question is how to output every log as ln in tex output in maxima? Is that possible with texput?


Solution

  • Two things here, which are both completely not obvious; sorry about that. (1) Need to say nounify(log) and not just log in the call to texput. This is because log(3) is a so-called noun expression (as opposed to a verb expression). (2) Need to say prefix in the call to texput since log is typeset as a prefix operator in TeX.

    (%i1) texput (nounify(log), "\\ln", prefix);
    (%o1)                                 \ln
    (%i2) tex(log(3));
    $$\ln3$$
    (%o2)                                false
    

    Oh, looks like we need a trailing space to separate the \ln from the 3.

    (%i3) texput (nounify(log), "\\ln ", prefix);
    (%o3)                                \ln 
    (%i4) tex(log(3));
    $$\ln 3$$
    (%o4)                                false
    

    That seems to work as expected.