如何防止 Maxima tex1 回绕其输出?
我从批处理脚本中调用了 Maxima tex1
,如下所示:
maxima --very-quiet -r "tex1(solve(8*x^2+7*x+5));" | grep -v false > output.txt
并且我得到了 output.txt
,如下所示:
\left[ x=-{{\sqrt{111}\,i+7}\over{16}} , x={{\sqrt{111}\,i-7}\over{16}} \righ\
t]
它作为 (La)TeX 输入文件无效。
如何防止 Maxima tex1 包装其输出?
I invoked Maxima tex1
from within a batch script as follows:
maxima --very-quiet -r "tex1(solve(8*x^2+7*x+5));" | grep -v false > output.txt
and I got the output.txt
as follows:
\left[ x=-{{\sqrt{111}\,i+7}\over{16}} , x={{\sqrt{111}\,i-7}\over{16}} \righ\
t]
that is not valid as a (La)TeX input file.
How to prevent Maxima tex1
from wrapping its output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉回复晚了。
而不是
tex1(solve(8*x^2+7*x+5));
写:
?princ(tex1(solve(8*x^2+7*x+5)))$
问题是 tex1 返回的字符串正在由显示格式化程序打印(与打印字符串的函数相同,如果您在交互式会话中使用 Maxima)。显示格式化程序在行字符处断开字符串(默认 = 79)并插入反斜杠。相反,出于您的目的,您希望完全避开显示格式化程序,因此您使用 ?princ (仅打印字符串的 Lisp 函数)打印字符串,并使用“$”而不是“;”终止输入。告诉 Maxima 不要调用显示格式化程序。
请注意,MYPRINC 中的硬编码常量 70 在这里不起作用。给出的示例中未调用 MYPRINC。
Sorry for the late reply.
Instead of
tex1(solve(8*x^2+7*x+5));
write:
?princ(tex1(solve(8*x^2+7*x+5)))$
The problem is that the string returned by tex1 is being printed by the display formatter (the same function which would print the string if you were using Maxima in an interactive session). The display formatter breaks strings at linel characters (default = 79) and inserts a backslash. Instead for your purposes you want to evade the display formatter entirely, so you print the string with ?princ (a Lisp function to just print the string) and terminate the input with "$" instead of ";" to tell Maxima not to call the display formatter.
Note that the hard-coded constant 70 in MYPRINC doesn't come into play here. MYPRINC is not called in the example given.
不幸的是,这是硬编码到 Maxima 中的。解决此问题的一种方法是编辑位于文件 maxima/src/mactex.lisp 中的函数 myprinc。有一个
cond
形式,其中写有 70。它应该读取 linel 而不是 70。如果您在进行此更改后重新编译 maxima,则以下内容将起作用:无论如何,我将发送补丁尽快添加到 Maxima 列表中,以便该程序的未来版本不会出现此缺点。
This is, unfortunately, hard coded into Maxima. A way to solve this problem is to edit the function myprinc located in the file
maxima/src/mactex.lisp
. There is acond
form that has a 70. written there, it should read linel instead of 70. If you recompile maxima after making this change then the following will work:Anyway, I'll send a patch to the Maxima list ASAP so that future versions of the program won't have this shortcoming.