File: maxima_76.html

package info (click to toggle)
maxima 5.47.0-9
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 193,104 kB
  • sloc: lisp: 434,678; fortran: 14,665; tcl: 10,990; sh: 4,577; makefile: 2,763; ansic: 447; java: 328; python: 262; perl: 201; xml: 60; awk: 28; sed: 15; javascript: 2
file content (420 lines) | stat: -rw-r--r-- 19,108 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Maxima 5.47.0 Manual: Functions and Variables for TeX Output</title>

<meta name="description" content="Maxima 5.47.0 Manual: Functions and Variables for TeX Output">
<meta name="keywords" content="Maxima 5.47.0 Manual: Functions and Variables for TeX Output">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="maxima_toc.html#Top" rel="start" title="Top">
<link href="maxima_423.html#Function-and-Variable-Index" rel="index" title="Function and Variable Index">
<link href="maxima_toc.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="maxima_72.html#File-Input-and-Output" rel="up" title="File Input and Output">
<link href="maxima_77.html#Functions-and-Variables-for-Fortran-Output" rel="next" title="Functions and Variables for Fortran Output">
<link href="maxima_75.html#Functions-and-Variables-for-File-Input-and-Output" rel="previous" title="Functions and Variables for File Input and Output">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
body {color: black; background: white;  margin-left: 8%; margin-right: 13%;
      font-family: "FreeSans", sans-serif}
h1 {font-size: 150%; font-family: "FreeSans", sans-serif}
h2 {font-size: 125%; font-family: "FreeSans", sans-serif}
h3 {font-size: 100%; font-family: "FreeSans", sans-serif}
a[href] {color: rgb(0,0,255); text-decoration: none;}
a[href]:hover {background: rgb(220,220,220);}
div.textbox {border: solid; border-width: thin; padding-top: 1em;
    padding-bottom: 1em; padding-left: 2em; padding-right: 2em}
div.titlebox {border: none; padding-top: 1em; padding-bottom: 1em;
    padding-left: 2em; padding-right: 2em; background: rgb(200,255,255);
    font-family: sans-serif}
div.synopsisbox {
    border: none; padding-top: 1em; padding-bottom: 1em; padding-left: 2em;
    padding-right: 2em; background: rgb(255,220,255);}
pre.example {border: 1px solid rgb(180,180,180); padding-top: 1em;
    padding-bottom: 1em; padding-left: 1em; padding-right: 1em;
    background-color: rgb(238,238,255)}
div.spacerbox {border: none; padding-top: 2em; padding-bottom: 2em}
div.image {margin: 0; padding: 1em; text-align: center}
div.categorybox {border: 1px solid gray; padding-top: 1em; padding-bottom: 1em;
    padding-left: 1em; padding-right: 1em; background: rgb(247,242,220)}
img {max-width:80%; max-height: 80%; display: block; margin-left: auto; margin-right: auto}

-->
</style>

<link rel="icon" href="figures/favicon.ico">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6>"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Functions-and-Variables-for-TeX-Output"></a>
<div class="header">
<p>
Next: <a href="maxima_77.html#Functions-and-Variables-for-Fortran-Output" accesskey="n" rel="next">Functions and Variables for Fortran Output</a>, Previous: <a href="maxima_75.html#Functions-and-Variables-for-File-Input-and-Output" accesskey="p" rel="previous">Functions and Variables for File Input and Output</a>, Up: <a href="maxima_72.html#File-Input-and-Output" accesskey="u" rel="up">File Input and Output</a> &nbsp; [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_423.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Functions-and-Variables-for-TeX-Output-1"></a>
<h3 class="section">13.4 Functions and Variables for TeX Output</h3>


<p>Note that the built-in TeX output functionality of wxMaxima makes no use of
the functions described here but uses its own implementation instead.
</p>
<a name="tex"></a><a name="Item_003a-Input_002fdeffn_002ftex"></a><dl>
<dt><a name="index-tex"></a>Function: <strong>tex</strong> <em><br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>tex</tt> (<var>expr</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>tex</tt> (<var>expr</var>, <var>destination</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>tex</tt> (<var>expr</var>, false) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>tex</tt> (<var>label</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>tex</tt> (<var>label</var>, <var>destination</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>tex</tt> (<var>label</var>, false)</em></dt>
<dd>
<p>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.
</p>
<p><code>tex (<var>expr</var>)</code> prints a TeX representation of <var>expr</var> on the
console.
</p>
<p><code>tex (<var>label</var>)</code> prints a TeX representation of the expression named by
<var>label</var> 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.
</p>
<p><var>destination</var> may be an output stream or file name.  When <var>destination</var>
is a file name, <code>tex</code> appends its output to the file.  The functions
<code>openw</code> and <code>opena</code> create output streams.
</p>
<p><code>tex (<var>expr</var>, false)</code> and <code>tex (<var>label</var>, false)</code>
return their TeX output as a string.
</p>
<p><code>tex</code> evaluates its first argument after testing it to see if it is a
label.  Quote-quote <code>''</code> forces evaluation of the argument, thereby
defeating the test and preventing the label.
</p>
<p>See also <code><a href="#tex1">tex1</a></code> and <code><a href="#texput">texput</a></code>.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">(%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, &quot;foo.tex&quot;);
(%o4)                          (\%o1)
</pre></div>

<p><code>tex (<var>expr</var>, false)</code> returns its TeX output as a string.
</p>
<div class="example">
<pre class="example">(%i1) S : tex (x * y * z, false);
(%o1) $$x\,y\,z$$
(%i2) S;
(%o2) $$x\,y\,z$$
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-TeX-output">TeX output</a>
&middot;<a href="maxima_424.html#Category_003a-File-output">File output</a>
&middot;</div></dd></dl>

<a name="tex1"></a><a name="Item_003a-Input_002fdeffn_002ftex1"></a><dl>
<dt><a name="index-tex1"></a>Function: <strong>tex1</strong> <em>(<var>e</var>)</em></dt>
<dd>
<p>Returns a string which represents the TeX output for the expressions <var>e</var>.
The TeX output is not enclosed in delimiters for an equation or any other
environment.
</p>
<p>See also <code><a href="#tex">tex</a></code> and <code><a href="#texput">texput</a></code>.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">(%i1) tex1 (sin(x) + cos(x));
(%o1)                     \sin x+\cos x
</pre></div>
</dd></dl>

<a name="texput"></a><a name="Item_003a-Input_002fdeffn_002ftexput"></a><dl>
<dt><a name="index-texput"></a>Function: <strong>texput</strong> <em><br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>texput</tt> (<var>a</var>, <var>s</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>texput</tt> (<var>a</var>, <var>f</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>texput</tt> (<var>a</var>, <var>s</var>, <var>operator_type</var>) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>texput</tt> (<var>a</var>, [<var>s_1</var>, <var>s_2</var>], matchfix) <br>&nbsp;&nbsp;&nbsp;&nbsp;<tt>texput</tt> (<var>a</var>, [<var>s_1</var>, <var>s_2</var>, <var>s_3</var>], matchfix)</em></dt>
<dd>
<p>Assign the TeX output for the atom <var>a</var>, which can be a symbol or the name
of an operator.
</p>
<p><code>texput (<var>a</var>, <var>s</var>)</code> causes the <code>tex</code> function to interpolate
the string <var>s</var> into the TeX output in place of <var>a</var>.
</p>
<p><code>texput (<var>a</var>, <var>f</var>)</code> causes the <code>tex</code> function to call the
function <var>f</var> to generate TeX output.  <var>f</var> must accept one argument,
which is an expression which has operator <var>a</var>,
and must return either a string (the TeX output) or <code>false</code>,
indicating that the TeX function in effect when <code>texput</code> is called
should handle the expression.
<var>f</var> may call <code>tex1</code> to generate TeX output for the
arguments of the input expression.
</p>
<p><code>texput (<var>a</var>, <var>s</var>, <var>operator_type</var>)</code>, where <var>operator_type</var>
is <code>prefix</code>, <code>infix</code>, <code>postfix</code>, <code>nary</code>, or <code>nofix</code>,
causes the <code>tex</code> function to interpolate <var>s</var> into the TeX output in
place of <var>a</var>, and to place the interpolated text in the appropriate
position.
</p>
<p><code>texput (<var>a</var>, [<var>s_1</var>, <var>s_2</var>], matchfix)</code> causes the <code>tex</code>
function to interpolate <var>s_1</var> and <var>s_2</var> into the TeX output on either
side of the arguments of <var>a</var>.  The arguments (if more than one) are
separated by commas.
</p>
<p><code>texput (<var>a</var>, [<var>s_1</var>, <var>s_2</var>, <var>s_3</var>], matchfix)</code> causes the
<code>tex</code> function to interpolate <var>s_1</var> and <var>s_2</var> into the TeX output
on either side of the arguments of <var>a</var>, with <var>s_3</var> separating the
arguments.
</p>
<p>See also <code><a href="#tex">tex</a></code> and <code><a href="#tex1">tex1</a></code>.
</p>
<p>Examples:
</p>
<p>Assign TeX output for a variable.
</p>
<div class="example">
<pre class="example">(%i1) texput (me,&quot;\\mu_e&quot;);
(%o1)                         \mu_e
(%i2) tex (me);
$$\mu_e$$
(%o2)                         false
</pre></div>

<p>Assign TeX output for an ordinary function (not an operator).
</p>
<div class="example">
<pre class="example">(%i1) texput (lcm, &quot;\\mathrm{lcm}&quot;);
(%o1)                     \mathrm{lcm}
(%i2) tex (lcm (a, b));
$$\mathrm{lcm}\left(a , b\right)$$
(%o2)                         false
</pre></div>

<p>Call a function to generate TeX output.
</p>
<div class="example">
<pre class="example">(%i1) texfoo (e) := block ([a, b], [a, b] : args (e),
  concat(&quot;\\left[\\stackrel{&quot;,tex1(b),&quot;}{&quot;,tex1(a),&quot;}\\right]&quot;))$
(%i2) texput (foo, texfoo);
(%o2)                        texfoo
(%i3) tex (foo (2^x, %pi));
$$\left[\stackrel{\pi}{2^{x}}\right]$$
(%o3)                         false
</pre></div>

<p>Assign TeX output for a prefix operator.
</p>
<div class="example">
<pre class="example">(%i1) prefix (&quot;grad&quot;);
(%o1)                         grad
(%i2) texput (&quot;grad&quot;, &quot; \\nabla &quot;, prefix);
(%o2)                        \nabla 
(%i3) tex (grad f);
$$ \nabla f$$
(%o3)                         false
</pre></div>

<p>Assign TeX output for an infix operator.
</p>
<div class="example">
<pre class="example">(%i1) infix (&quot;~&quot;);
(%o1)                           ~
(%i2) texput (&quot;~&quot;, &quot; \\times &quot;, infix);
(%o2)                        \times 
(%i3) tex (a ~ b);
$$a \times b$$
(%o3)                         false
</pre></div>

<p>Assign TeX output for a postfix operator.
</p>
<div class="example">
<pre class="example">(%i1) postfix (&quot;##&quot;);
(%o1)                          ##
(%i2) texput (&quot;##&quot;, &quot;!!&quot;, postfix);
(%o2)                          !!
(%i3) tex (x ##);
$$x!!$$
(%o3)                         false
</pre></div>

<p>Assign TeX output for a nary operator.
</p>
<div class="example">
<pre class="example">(%i1) nary (&quot;@@&quot;);
(%o1)                          @@
(%i2) texput (&quot;@@&quot;, &quot; \\circ &quot;, nary);
(%o2)                         \circ 
(%i3) tex (a @@ b @@ c @@ d);
$$a \circ b \circ c \circ d$$
(%o3)                         false
</pre></div>

<p>Assign TeX output for a nofix operator.
</p>
<div class="example">
<pre class="example">(%i1) nofix (&quot;foo&quot;);
(%o1)                          foo
(%i2) texput (&quot;foo&quot;, &quot;\\mathsc{foo}&quot;, nofix);
(%o2)                     \mathsc{foo}
(%i3) tex (foo);
$$\mathsc{foo}$$
(%o3)                         false
</pre></div>

<p>Assign TeX output for a matchfix operator.
</p>
<div class="example">
<pre class="example">(%i1) matchfix (&quot;&lt;&lt;&quot;, &quot;&gt;&gt;&quot;);
(%o1)                          &lt;&lt;
(%i2) texput (&quot;&lt;&lt;&quot;, [&quot; \\langle &quot;, &quot; \\rangle &quot;], matchfix);
(%o2)                [ \langle ,  \rangle ]
(%i3) tex (&lt;&lt;a&gt;&gt;);
$$ \langle a \rangle $$
(%o3)                         false
(%i4) tex (&lt;&lt;a, b&gt;&gt;);
$$ \langle a , b \rangle $$
(%o4)                         false
(%i5) texput (&quot;&lt;&lt;&quot;, [&quot; \\langle &quot;, &quot; \\rangle &quot;, &quot; \\, | \\,&quot;],
      matchfix);
(%o5)           [ \langle ,  \rangle ,  \, | \,]
(%i6) tex (&lt;&lt;a&gt;&gt;);
$$ \langle a \rangle $$
(%o6)                         false
(%i7) tex (&lt;&lt;a, b&gt;&gt;);
$$ \langle a \, | \,b \rangle $$
(%o7)                         false
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-TeX-output">TeX output</a>
&middot;</div></dd></dl>

<a name="get_005ftex_005fenvironment"></a><a name="Item_003a-Input_002fdeffn_002fget_005ftex_005fenvironment"></a><dl>
<dt><a name="index-get_005ftex_005fenvironment"></a>Function: <strong>get_tex_environment</strong> <em>(<var>op</var>)</em></dt>
<dd><a name="Item_003a-Input_002fdeffn_002fset_005ftex_005fenvironment"></a></dd><dt><a name="index-set_005ftex_005fenvironment"></a>Function: <strong>set_tex_environment</strong> <em>(<var>op</var>, <var>before</var>, <var>after</var>)</em></dt>
<dd>
<p>Customize the TeX environment output by <code>tex</code>.
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.
</p>
<p>Only the TeX environment of the top-level operator in an expression
is output; TeX environments associated with other operators are ignored.
</p>
<p><code>get_tex_environment</code> returns the TeX environment which is applied
to the operator <var>op</var>; returns the default if no other environment
has been assigned.
</p>
<p><code>set_tex_environment</code> assigns the TeX environment for the operator
<var>op</var>.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">(%i1) get_tex_environment (&quot;:=&quot;);
(%o1) [
\begin{verbatim}
, ;
\end{verbatim}
]
(%i2) tex (f (x) := 1 - x);

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

(%o2)                         false
(%i3) set_tex_environment (&quot;:=&quot;, &quot;$$&quot;, &quot;$$&quot;);
(%o3)                       [$$, $$]
(%i4) tex (f (x) := 1 - x);
$$f(x):=1-x$$
(%o4)                         false
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-TeX-output">TeX output</a>
&middot;</div></dd></dl>

<a name="get_005ftex_005fenviroment_005fdefault"></a><a name="Item_003a-Input_002fdeffn_002fget_005ftex_005fenvironment_005fdefault"></a><dl>
<dt><a name="index-get_005ftex_005fenvironment_005fdefault"></a>Function: <strong>get_tex_environment_default</strong> <em>()</em></dt>
<dd><a name="Item_003a-Input_002fdeffn_002fset_005ftex_005fenvironment_005fdefault"></a></dd><dt><a name="index-set_005ftex_005fenvironment_005fdefault"></a>Function: <strong>set_tex_environment_default</strong> <em>(<var>before</var>, <var>after</var>)</em></dt>
<dd>
<p>Customize the TeX environment output by <code>tex</code>.
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.
</p>
<p><code>get_tex_environment_default</code> returns the TeX environment which is
applied to expressions for which the top-level operator has no
specific TeX environment (as assigned by <code>set_tex_environment</code>).
</p>
<p><code>set_tex_environment_default</code> assigns the default TeX environment.
</p>
<p>Examples:
</p>
<div class="example">
<pre class="example">(%i1) get_tex_environment_default ();
(%o1)                       [$$, $$]
(%i2) tex (f(x) + g(x));
$$g\left(x\right)+f\left(x\right)$$
(%o2)                         false
(%i3) set_tex_environment_default (&quot;\\begin{equation}
&quot;, &quot;
\\end{equation}&quot;);
(%o3) [\begin{equation}
, 
\end{equation}]
(%i4) tex (f(x) + g(x));
\begin{equation}
g\left(x\right)+f\left(x\right)
\end{equation}
(%o4)                         false
</pre></div>

<div class=categorybox>
Categories:<a href="maxima_424.html#Category_003a-TeX-output">TeX output</a>
&middot;</div></dd></dl>

<a name="Item_003a-Input_002fnode_002fFunctions-and-Variables-for-Fortran-Output"></a><hr>
<div class="header">
<p>
Next: <a href="maxima_77.html#Functions-and-Variables-for-Fortran-Output" accesskey="n" rel="next">Functions and Variables for Fortran Output</a>, Previous: <a href="maxima_75.html#Functions-and-Variables-for-File-Input-and-Output" accesskey="p" rel="previous">Functions and Variables for File Input and Output</a>, Up: <a href="maxima_72.html#File-Input-and-Output" accesskey="u" rel="up">File Input and Output</a> &nbsp; [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_423.html#Function-and-Variable-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>