Search code examples
texmaximawxmaxima

(wx)Maxima: texput for powers of expressions


I have used texput to set the tex1 output of log(x) to be \ln(x) with

texput('log, lambda([e],[a]:args(e), printf(false, "\\ln(~a)", tex1(a))));

and am wondering if it is possible to also set the output for something like (log(x))^n? In particular I'd like to use the \ln^n(x) convention.


Solution

  • The strangeness around TeX output for log is a bug, which I'm working on. But here is a work around which gets the behavior you want, I think.

    Here I'm calling both texput(log, "\\ln ") and texput(log, "\\ln ", prefix), to set the TeX output for log in different contexts, and also :lisp (push log *tex-mexpt-trig-like-fns*) to have log treated similarly to trig functions.

    (%i1) stringdisp: true $
    (%i2) map (tex1, [log(x), log(x+1), log(x)^n]);                              
    (%o2)   ["\log x", "\log \left(x+1\right)", "\left(\log x\right)^{n}"]
    (%i3) texput (log, "\\ln ");
    (%o3)                               "\ln "
    (%i4) texput (log, "\\ln ", prefix);
    (%o4)                               "\ln "
    (%i5) map (tex1, [log(x), log(x+1), log(x)^n]); 
    (%o5)           ["\ln x", "\ln \left(x+1\right)", "\ln x^{n}"]
    

    Hmm, that's not quite enough. Oh, that's right, I forgot the bit about trig functions.

    (%i6) :lisp (push '%log *tex-mexpt-trig-like-fns*)
    (%LOG %SIN %COS %TAN %SINH %COSH %TANH %ASIN %ACOS %ATAN %ASINH %ACOSH %ATANH)
    (%i6) map (tex1, [log(x), log(x+1), log(x)^n]); 
    (%o6)           ["\ln x", "\ln \left(x+1\right)", "\ln ^{n}x"]
    

    Does that seem right?