sin(x)^2 的 Maxima 排版
Maxima typesetting of sin(x)^2
如何告诉 Maxima 将 sin(x)^2
排版为 $$\sin(x)^2$$
(或 $$\sin\left(x\right)^2$$
)而不是 $$\sin^2 x$$
?
(this question 的公认答案建议使用
:lisp (setf (get '%sin 'tex) nil)
删除 sin
函数的特殊 TeX 处理程序。完成后,我们得到 $$\sin^2\left(x\right)$$
,但上标的位置没有改变。)
src/mactex.lisp
中的一些挖掘产生了以下似乎有效的结果。首先删除 TEX
和 TEX-RBP
(right-binding 幂——与优先级有关)属性。然后核对 special-cases trig-like 函数 TEX-MEXPT (处理指数)的函数。
(%i1) :lisp (mapcar #'(lambda (x) (setf (get x 'tex) nil) (setf (get x 'tex-rbp) nil)) *tex-mexpt-trig-like-fns*)
(%i1) :lisp (defun maybe-tex-mexpt-trig-like (&rest a) (declare (ignore a)))
让我们看看 Maxima 认为的 trig-like 个函数列表。
(%i1) :lisp *tex-mexpt-trig-like-fns*
(%SIN %COS %TAN %SINH %COSH %TANH %ASIN %ACOS %ATAN %ASINH %ACOSH %ATANH)
好的,让我们通过它们看看我们得到的 TeX 输出。
(%i1) for f in [sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh]
do tex(f(x)^2);
$$\sin \left(x\right)^2$$
$$\cos \left(x\right)^2$$
$$\tan \left(x\right)^2$$
$$\sinh \left(x\right)^2$$
$$\cosh \left(x\right)^2$$
$$\tanh \left(x\right)^2$$
$$\arcsin \left(x\right)^2$$
$$\arccos \left(x\right)^2$$
$$\arctan \left(x\right)^2$$
$${\rm asinh}\; \left(x\right)^2$$
$${\rm acosh}\; \left(x\right)^2$$
$${\rm atanh}\; \left(x\right)^2$$
(%o1) done
我猜 \;
的 asinh
输出等有点不对劲。如果您需要,我们也可以解决这个问题。
tex
输出代码是启发式算法的集合,大部分时间都有效。如您所见,如何获得不同的输出并不总是很明显。
这里是 Robert Dodier 回答的一个小补充。我将 Maxima 与 STACK 系统结合使用以进行 computer-aided 评估(来自文件 stacktex.lisp
的 home page, Github). Because STACK modifies the behaviour of Maxima's TeX system, a different approach is needed in that context. One possibility is to delete this clause(其中有一条附加评论建议您删除它)。完成后,它如 Robert Dodier 的回答一样,对于删除正确的绑定能力注释仍然有用,否则你将得到 (\sin(x))^2
而不是 \sin(x)^2
.
如何告诉 Maxima 将 sin(x)^2
排版为 $$\sin(x)^2$$
(或 $$\sin\left(x\right)^2$$
)而不是 $$\sin^2 x$$
?
(this question 的公认答案建议使用
:lisp (setf (get '%sin 'tex) nil)
删除 sin
函数的特殊 TeX 处理程序。完成后,我们得到 $$\sin^2\left(x\right)$$
,但上标的位置没有改变。)
src/mactex.lisp
中的一些挖掘产生了以下似乎有效的结果。首先删除 TEX
和 TEX-RBP
(right-binding 幂——与优先级有关)属性。然后核对 special-cases trig-like 函数 TEX-MEXPT (处理指数)的函数。
(%i1) :lisp (mapcar #'(lambda (x) (setf (get x 'tex) nil) (setf (get x 'tex-rbp) nil)) *tex-mexpt-trig-like-fns*)
(%i1) :lisp (defun maybe-tex-mexpt-trig-like (&rest a) (declare (ignore a)))
让我们看看 Maxima 认为的 trig-like 个函数列表。
(%i1) :lisp *tex-mexpt-trig-like-fns*
(%SIN %COS %TAN %SINH %COSH %TANH %ASIN %ACOS %ATAN %ASINH %ACOSH %ATANH)
好的,让我们通过它们看看我们得到的 TeX 输出。
(%i1) for f in [sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh]
do tex(f(x)^2);
$$\sin \left(x\right)^2$$
$$\cos \left(x\right)^2$$
$$\tan \left(x\right)^2$$
$$\sinh \left(x\right)^2$$
$$\cosh \left(x\right)^2$$
$$\tanh \left(x\right)^2$$
$$\arcsin \left(x\right)^2$$
$$\arccos \left(x\right)^2$$
$$\arctan \left(x\right)^2$$
$${\rm asinh}\; \left(x\right)^2$$
$${\rm acosh}\; \left(x\right)^2$$
$${\rm atanh}\; \left(x\right)^2$$
(%o1) done
我猜 \;
的 asinh
输出等有点不对劲。如果您需要,我们也可以解决这个问题。
tex
输出代码是启发式算法的集合,大部分时间都有效。如您所见,如何获得不同的输出并不总是很明显。
这里是 Robert Dodier 回答的一个小补充。我将 Maxima 与 STACK 系统结合使用以进行 computer-aided 评估(来自文件 stacktex.lisp
的 home page, Github). Because STACK modifies the behaviour of Maxima's TeX system, a different approach is needed in that context. One possibility is to delete this clause(其中有一条附加评论建议您删除它)。完成后,它如 Robert Dodier 的回答一样,对于删除正确的绑定能力注释仍然有用,否则你将得到 (\sin(x))^2
而不是 \sin(x)^2
.