(%i1) declare(z, complex)$
(%i2) tex(conjugate(z)^2);
$$a^\star^2$$
Workaround:
texput(conjugate, lambda([conje], sconcat(tex1(first(conje)), "^*")))$
texput("^", lambda([e], block(
[base : first(e), pow : second(e)],
if atom(base) then
sconcat(tex1(base), "^*")
else if op(base) # conjugate then
sconcat("\\left(", tex1(base), "\\right)^", pow)
else
sconcat(tex1(first(base)), "^{*", pow, "}"))))$
Note i also changed \star
to plain *
in my workaround.
Sorry, the workaround in the original bug report does not take into account the case when there is some expression in the power of conjugate(...). A workaround that works for that case is:
Thanks for this bug report. I've reworked the TeX output for conjugate so that it interacts correctly with exponents. See commit [ d188f74 ]. Closing this bug as fixed.
The TeX output system infers whether parentheses are needed from the so-called left and right binding powers (i.e., operator precedence). In this case I was able to convince
tex
to output parentheses by reducing the binding powers (i.e., lowering the precedence).Thanks for your fix! Your solution is rather elegant, but I should say it's not ideal, at least to my taste.
declare(a, complex)$ tex(conjugate(a^2))
gives $$\left(a^{\ast}\right)^2$$, while I would prefer $$a^{\ast2}$$. The latter is what my re-definition of "^" achieves.