This question asked about setting the output of tex1
for a numerical fraction (i.e. x
where ratnump(x) = true
); however, this does not seem to cover all objects that are printed as a fraction, e.g. 1/x
or diff(ln(x),x))
.
Following this answer, I tried using :lisp $x
to query the lisp form, and I get ((MEXPT SIMP) $X -1)
for 1/x
and ((%DERIVATIVE SIMP) (($LN SIMP) $X) $X 1)
for diff(ln(x),x)
; however, I have no idea how to use this info with texput
to specify the desired formatting.
Although I don't think it is necessarily relevant to the question, I wanted to call on a different LaTeX function, instead of \frac
(e.g. \tfrac
).
It's a long story, but it turns out the operator to be displayed is MQUOTIENT. Try this:
texput (?mquotient, lambda([e], printf (false, "\\tfrac{~a}{~a}", tex1(num(e)), tex1(denom(e)))));
Then I get:
(%i12) tex1(1/x);
(%o12) \tfrac{1}{x}
(%i13) tex1(y/x);
(%o13) \tfrac{y}{x}
(%i14) tex1((1+a/b)/(1-c/d));
(%o14) \tfrac{\tfrac{a}{b}+1}{1-\tfrac{c}{d}}
PS. ln
isn't recognized by Maxima (unless you created a function named ln
). The logarithm to the base e is log
. Also log10
isn't recognized (again, unless you created such a function).