 |
Spreadsheets |
 |
TeXmacs provides rudimentary spreadsheet-like facilities with the
advantage that the computations can be carried out using any of the
plug-ins that can be used as a scripting language. In order to use the
spreadsheet facilities, you should therefore start with the selection
of a scripting language in the menu Document\(\rightarrow\)Scripts.
As soon as you have selecting a scripting language, such as Maxima, then you may enter a new spreadsheet using
Insert\(\rightarrow\)Table\(\rightarrow\)Textual spreadsheet or Insert\(\rightarrow\)Table\(\rightarrow\)Numeric
spreadsheet. You may edit the spreadsheet as an
ordinary table, except that the ↩ key will attempt to
reevaluate the cells of the table.
In addition, when preceding the contents of a cell by =, then cell
will be considered as an input-output switch. More precisely, the
input is a formula which will be evaluated using the current scripting
language. After the evaluation, only the result of the evaluation is
shown in the cell. After pressing ↩ a second time in the cell,
it will be possible switch back and edit the input. In the formulas,
one may refer to the others using names such as c5 for
the third row and the fifth column.
Example 1. On the
left-hand side of the figure below, we have displayed a simple table
with formulas for evaluating the sums of the first two items of each
row. On the right-hand side, we have shown the result after
evaluation.
| 1 |
10 |
=a1+b1 |
| 100 |
1000 |
=a2+b2 |
| 1 |
10 |
\(11\) |
| 100 |
1000 |
\(1100\) |
|
|
Figure 1. Evaluation of a simple
spreadsheet.
|
Example 2. The cells may
contain mathematical formulas and the spreadsheet may take advantage
of any of the capacities of the scripting language. For instance, the
figure below demonstrates another possible use of Maxima.
| \(\sin (x^2)\) |
| =diff(a1,x) |
| =diff(a2,x) |
| =diff(a3,x) |
| \(\sin (x^2)\) |
| \(2 x \cos (x^2)\) |
| \(2 \cos (x^2) - 4 x^2 \sin (x^2)\) |
| \(- 12 x \sin (x^2) - 8 x^3 \cos (x^2)\) |
|
|
Figure 2. Computation of successive
derivatives using Maxima.
|
TeXmacs supports a few special notations for applying operations on
all cells in a subtable. For instance, as in Excel,
one may use the notation c3:d5 for indicating all cells
c3, c4, c5, d3,
d4, d5 in the block from c3 to
d5. An alternative notation \(, \ldots,\) for
: can be entered by typing ,,. In a similar
way, one may enter the special notation \(+ \cdots +\) by typing ++.
For instance, c3\(+ \cdots +\)d5 stands for the sum of
all cells between c3 and d5.
Example 3. The figure
below shows an example on how to use taking sums of cells. Notice that
empty cells count for zero.
| 15.10 |
15.10 |
30.20 |
| 100 |
125 |
75 |
| 28.50 |
|
14.25 |
| 12 |
16 |
20 |
| =a1\(+ \cdots +\)a4 |
=b1\(+ \cdots +\)b4 |
=c1\(+ \cdots +\)c4 |
| 15.10 |
15.10 |
30.20 |
| 100 |
125 |
75 |
| 28.50 |
|
14.25 |
| 12 |
16 |
20 |
| \(155.6\) |
\(156.1\) |
\(139.45\) |
|
|
Figure 3. Evaluation of a simple
spreadsheet.
|
Notice that copying and pasting of subtables works in the same way as
for ordinary tables, with the additional features that the names of
the cells and references to cells in the formulas are renumbered
automatically. Similarly, automatic renumbering is used when inserting
new columns or rows, or when removing existing columns or rows.
We also notice that field references can be used inside spreadsheet
cells in order to refer to some computational markup outside the
table. Inversely, each spreadsheet also carries an invisible
Ref field which can be edited by deactivating the
spreadsheet or from the focus bar (when selecting the entire
spreadsheet). The Ref field of the spreadsheet is used as
a prefix for referring to the contents of cells outside the table or
from within other spreadsheets. For instance, if Ref
equals sheet, then sheet-c4 will refer to
the field c4 inside the spreadsheet.
© 2012 Joris van der Hoeven
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the section entitled
"GNU Free Documentation License".