Maxima – 84 – Files di input e output – funzioni e variabili per l’output di TeX

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.257.

Nota urgente per me: devo verificare se TeX e LaTeX sono compatibili o quali sono le differenze. Confido nella compatibilità ma chissà… 🤔

Note that the built-in TeX output functionality of wxMaxima makes no use of the functions described here but uses its own implementation instead.

tex (expr)
tex (expr, destination)
tex (expr, false)
tex (label)
tex (label, destination)
tex (label, false)
Prints a representation of an expression suitable for the TeX document preparation system. The result is a fragment of a document, which can be copied into a larger document but not processed by itself.

tex(expr) prints a TeX representation of expr on the console.

tex(label) prints a TeX representation of the expression named by label and assigns it an equation label (to be displayed to the left of the expression). The TeX equation label is the same as the Maxima label.

destination may be an output stream or file name. When destination is a file name, tex appends its output to the file. The functions openw and opena create output streams.

tex(expr, false) and tex(label, false) return their TeX output as a string.

tex evaluates its first argument after testing it to see if it is a label. Quote-quote '' forces evaluation of the argument, thereby defeating the test and preventing the label. See also texput.

(%i1) integrate (1/(1+x^3), x);
                                          2 x - 1
                       2             atan(-------)
                  log(x  - x + 1)         sqrt(3)    log(x + 1)
(%o1)          (- ---------------) + ------------- + ----------
                         6              sqrt(3)          3
(%i2) tex (%o1);
$$-{{\log \left(x^2-x+1\right)}\over{6}}+{{\arctan \left({{2\,x-1
 }\over{\sqrt{3}}}\right)}\over{\sqrt{3}}}+{{\log \left(x+1\right)
 }\over{3}}\leqno{\tt (\%o1)}$$
(%o2)                               (\%o1)
(%i3) tex (integrate (sin(x), x));
$$-\cos x$$
(%o3)                                false
(%i4) tex (%o1, "foo.tex");
(%o4)                               (\%o1)

Sì, compatibile

tex(expr, false) returns its TeX output as a string.

(%i5) S : tex (x * y * z, false);
(%o5) $$x\,y\,z$$
(%i6) S;
(%o6) $$x\,y\,z$$

tex1 (e)
Returns a string which represents the TeX output for the expressions e. The TeX output is not enclosed in delimiters for an equation or any other environment.

(%i7) tex1 (sin(x) + cos(x));
(%o7)                            \sin x+\cos x

texput (a, s)
texput (a, f)
texput (a, s, operator_type)
texput (a, [s_1, s_2], matchfix)
texput (a, [s_1, s_2, s_3], matchfix)
Assign the TeX output for the atom a, which can be a symbol or the name of an operator.

texput(a, s) causes the tex function to interpolate the string s into the TeX output in place of a.

texput(a, f) causes the tex function to call the function f to generate TeX output. f must accept one argument, which is an expression which has operator a, and must return a string (the TeX output). f may call tex1 to generate TeX output for the arguments of the input expression.

texput(a, s, operator_type), where operator_type is prefix, infix, postfix, nary, or nofix, causes the tex function to interpolate s into the TeX output in place of a, and to place the interpolated text in the appropriate position.

texput(a, [s_1, s_2], matchfix) causes the tex function to interpolate s_1 and s_2 into the TeX output on either side of the arguments of a. The arguments (if more than one) are separated by commas.

texput(a, [s_1, s_2, s_3], matchfix) causes the tex function to interpolate s_1 and s_2 into the TeX output on either side of the arguments of a, with s_3 separating the arguments.

Assign TeX output for a variable.

(%i8) texput (me,"\\mu_e");
(%o8)                                \mu_e
(%i9) tex (me);
$$\mu_e$$
(%o9)                                false

Assign TeX output for an ordinary function (not an operator).

(%i10) texput (lcm, "\\mathrm{lcm}");
(%o10)                           \mathrm{lcm}
(%i11) tex (lcm (a, b));
$$\mathrm{lcm}\left(a , b\right)$$
(%o11)                               false

Call a function to generate TeX output.

(%i12) texfoo (e) := block ([a, b], [a, b] : args (e),
          concat("\\left[\\stackrel{",tex1(b),"}{",tex1(a),"}\\right]"))$

(%i13) texput (foo, texfoo);
(%o13)                              texfoo
(%i14) tex (foo (2^x, %pi));
$$\left[\stackrel{\pi}{2^{x}}\right]$$
(%o14)                               false

Assign TeX output for a prefix operator.

(%i15) prefix ("grad");
(%o15)                               grad
(%i16) texput ("grad", " \\nabla ", prefix);
(%o16)                              \nabla
(%i17) tex (grad f);
$$ \nabla f$$
(%o17)                               false

Assign TeX output for an infix operator.

(%i18) infix ("~");
(%o18)                                 ~
(%i19) texput ("~", " \\times ", infix);
(%o19)                              \times
(%i20) tex (a ~ b);
$$a \times b$$
(%o20)                               false

Assign TeX output for a postfix operator.

(%i21) postfix ("##");
(%o21)                                ##
(%i22) texput ("##", "!!", postfix);
(%o22)                                !!
(%i23) tex (x ##);
$$x!!$$
(%o23)                               false

Assign TeX output for a nary operator.

(%i24) nary ("@@");
(%o24)                                @@
(%i25) texput ("@@", " \\circ ", nary);
(%o25)                               \circ
(%i26) tex (a @@ b @@ c @@ d);
$$a \circ b \circ c \circ d$$
(%o26)                               false

Assign TeX output for a nofix operator.

(%i27) nofix ("foo");
(%o27)                                foo
(%i28) texput ("foo", "\\mathsc{foo}", nofix);
(%o28)                           \mathsc{foo}
(%i29) tex (foo);
$$\mathsc{foo}$$
(%o29)                               false

Assign TeX output for a matchfix operator.

(%i30) matchfix ("<<", ">>");
(%o30)                                <<
(%i31) texput ("<<", [" \\langle ", " \\rangle "], matchfix);
(%o31)                      [ \langle ,  \rangle ]
(%i32) tex (<>);
$$ \langle a \rangle $$
(%o32)                               false
(%i33) tex (<<a, b>>);
$$ \langle a , b \rangle $$
(%o33)                               false
(%i34) texput ("<<", [" \\langle ", " \\rangle ", " \\, | \\,"], matchfix);
(%o34)                 [ \langle ,  \rangle ,  \, | \,]
(%i35) tex (<>);
$$ \langle a \rangle $$
(%o35)                               false
(%i36) tex (<<a, b>>);
$$ \langle a \, | \,b \rangle $$
(%o36)                               false

get_tex_environment (op)
set_tex_environment (op, before, after)
Customize the TeX environment output by tex. As maintained by these functions, the TeX environment comprises two strings: one is printed before any other TeX output, and the other is printed after.

Only the TeX environment of the top-level operator in an expression is output; TeX environments associated with other operators are ignored.

get_tex_environment returns the TeX environment which is applied to the operator op; returns the default if no other environment has been assigned.

set_tex_environment assigns the TeX environment for the operator op.

(%i37) get_tex_environment (":=");
(%o37) [
\begin{verbatim}
, ;
\end{verbatim}
]
(%i38) tex (f (x) := 1 - x);

\begin{verbatim}
f(x):=1-x;
\end{verbatim}

(%o38)                               false
(%i39) set_tex_environment (":=", "$$", "$$");
(%o39)                             [$$, $$]
(%i40) tex (f (x) := 1 - x);
$$f(x):=1-x$$
(%o40)                               false

get_tex_environment_default ()
get_tex_environment_default (before, after)
Customize the TeX environment output by tex. As maintained by these functions, the TeX environment comprises two strings: one is printed before any other TeX output, and the other is printed after.

get_tex_environment_default returns the TeX environment which is applied to expressions for which the top-level operator has no specific TeX environment (as assigned by set_tex_environment).

set_tex_environment_default assigns the default TeX environment.

(%i41) get_tex_environment_default ();
(%o41)                             [$$, $$]
(%i42) tex (f(x) + g(x));
$$g\left(x\right)-x+1$$
(%o42)                               false
(%i43) set_tex_environment_default ("\\begin{equation}
", "
\\end{equation}");
(%o43) [\begin{equation}
,
\end{equation}]
(%i44) tex (f(x) + g(x));
\begin{equation}
g\left(x\right)-x+1
\end{equation}
(%o44)                               false

Posta un commento o usa questo indirizzo per il trackback.

Trackback

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d blogger hanno fatto clic su Mi Piace per questo: