Pergunta

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?

Foi útil?

Solução

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 a cond 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:

maxima --very-quiet -r "linel: 1000$ tex1(solve(8*x^2+7*x+5));" | grep -v false > output.txt

Anyway, I'll send a patch to the Maxima list ASAP so that future versions of the program won't have this shortcoming.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top