docs/manual/guide/10-tables.org

design-themes-widgets
orgstar/docs/manual/guide/10-tables.org rendered · source · history · blame · raw

855 lines · 53732 bytes

  1#+TITLE: Tables
  2#+DESCRIPTION: Creating and editing Org tables, column widths, import and export, and spreadsheet formulas.
  3#+LEDE: Org tables are plain text that orgstar keeps aligned, edits by row and column, and recalculates with the same formulas Emacs uses.
  4
  5* Tables in Org
  6
  7A table is a run of lines that start with =|=. Fields are separated by =|=, and a line
  8that starts with =|-= is a horizontal rule:
  9
 10#+BEGIN_SRC org
 11| Name  | Qty | Price |
 12|-------+-----+-------|
 13| Apple |   3 |  0.50 |
 14| Pear  |  12 |  0.75 |
 15#+END_SRC
 16
 17orgstar follows =org-table.el= from Org 9.8.7, with =org-table-automatic-realign= on,
 18=org-table-tab-jumps-over-hlines= on, and formulas adjusted without asking when rows
 19and columns move (=org-table-fix-formulas-confirm= nil). Tables inside dynamic blocks
 20count as tables; tables inside other blocks don't.
 21
 22* Creating a table
 23
 24Type =|=, a few field names separated by =|=, and press =TAB=: orgstar aligns the line
 25as a table and moves to the next field, adding a row after the last one. Type =|-= on
 26the line below a row and press =TAB= to turn it into a full-width rule.
 27
 28=org-table-create-or-convert-from-region= builds one for you: ~C-c |~ in the Emacs
 29and Doom presets, =⌃⌘\= in the Mac preset.
 30
 31With no selection it asks =Table size Columns x Rows [e.g. 5x2]:=. An empty answer
 32makes a 5 × 2 table. When there is more than one row, a rule follows the first row.
 33
 34With text selected, the command converts the selected lines to a table instead
 35(=org-table-convert-region=). The separator is guessed:
 36
 37- tabs, when every line has a tab;
 38- otherwise commas, when every line has a comma, read as CSV: a field in double quotes
 39  can hold commas, and a line break in it becomes a space;
 40- otherwise runs of spaces.
 41
 42* Moving around and alignment
 43
 44| Key     | Org command                | Action                                                                     |
 45|---------+----------------------------+----------------------------------------------------------------------------|
 46| =TAB=   | =org-table-next-field=     | Aligns the table if the row it leaves changed width, and moves to the next field, skipping rules. In the last field it adds a row. |
 47| =S-TAB= | =org-table-previous-field= | Aligns the table and moves to the previous field.                         |
 48| =RET=   | =org-table-next-row=       | Aligns the table and moves down a row in the same column. Before a rule or at the end of the table it inserts a row. |
 49
 50These keys work the same in the Emacs and Mac presets. In Doom they apply in insert
 51state; in normal state =RET= is Doom's "act at point" (see /Recalculating/).
 52
 53Alignment (=org-table-align=) pads every field to its column's width and redraws
 54rules to match. A column is right-aligned when at least half of its non-empty fields
 55are numbers, and left-aligned otherwise. A field that holds only a cookie =<l>=, =<c>=
 56or =<r>= (optionally with a width, such as =<r10>=) fixes the column's alignment.
 57Widths count display columns, so wide characters and hidden link markup are measured
 58as they appear.
 59
 60Alignment happens when you press =TAB=, =S-TAB= or =RET= in a table and after every
 61table command, not while you type. Org's =TAB= aligns only when the buffer changed
 62since the last alignment; orgstar's aligns when the row it leaves no longer lines up
 63with the row above (below, in the first row), so a row you changed and left some other
 64way stays as it is until the next alignment. As in Org, deleting from a field that still
 65ends in two spaces doesn't count as a change: =TAB= pads that field back to its width.
 66To align without moving, use Org ▸ Align Table:
 67
 68| Preset | Key                          |
 69|--------+------------------------------|
 70| Emacs  | =C-c C-c= in a table         |
 71| Mac    | =⌃⌘X= in a table             |
 72| Doom   | =C-c C-c=, or =SPC m b a=    |
 73
 74=C-c C-c= (Mac =⌃⌘X=) in a table is =org-ctrl-c-ctrl-c=, as in Emacs. It first evaluates a formula
 75typed in the current field (see /Entering formulas/). Then, in a row marked =#= (see
 76/Names, parameters and constants/), it recalculates that row, which also aligns the
 77table; in any other row it aligns the table. With the caret at the table's very first
 78character, it recalculates the whole table instead.
 79
 80To align every table when a file opens, set =org-startup-align-all-tables= to =true=
 81in the config file (default =false=), or put =#+STARTUP: align= in the file;
 82=#+STARTUP: noalign= turns it off for that file. See
 83[[file:13-configuration.org][Configuration]].
 84
 85* Editing rows and columns
 86
 87| Action                            | Org command                | Emacs          | Mac         | Doom                          |
 88|-----------------------------------+----------------------------+----------------+-------------+-------------------------------|
 89| Move row up                       | =org-table-move-row-up=    | =M-<up>=       | =⌃⌘↑=       | =M-<up>=, =M-k=               |
 90| Move row down                     | =org-table-move-row-down=  | =M-<down>=     | =⌃⌘↓=       | =M-<down>=, =M-j=             |
 91| Move column left                  | =org-table-move-column-left= | =M-<left>=   | =⌃⌘←=       | =M-<left>=, =M-h=             |
 92| Move column right                 | =org-table-move-column-right= | =M-<right>= | =⌃⌘→=       | =M-<right>=, =M-l=            |
 93| Insert column                     | =org-table-insert-column=  | =M-S-<right>=  | =⌃⌥⌘→=      | =M-S-<right>=, =SPC m b i c=  |
 94| Delete column                     | =org-table-delete-column=  | =M-S-<left>=   | =⌃⌥⌘←=      | =M-S-<left>=, =SPC m b d c=   |
 95| Insert row above                  | =org-table-insert-row=     | =M-S-<down>=   | =⌃⌥⌘↓=      | =M-S-<down>=, =SPC m b i r=   |
 96| Delete row                        | =org-table-kill-row=       | =M-S-<up>=     | =⌃⌥⌘↑=      | =M-S-<up>=, =SPC m b d r=     |
 97| Insert rule below                 | =org-table-insert-hline=   | =C-c -=        | =⌃⌘-=       | =C-c -=, =SPC m b -=, =SPC m b i h= |
 98| Sort rows                         | =org-table-sort-lines=     | =C-c ^=        | =⌃⇧⌘S=      | =C-c ^=            |
 99| Transpose                         | =org-table-transpose-table-at-point= | Org ▸ Transpose Table | Org ▸ Transpose Table | Org ▸ Transpose Table |
100| Edit field in its own editor      | =org-table-edit-field=     | =C-c `=        | Org ▸ Edit Table Field | =C-c `=            |
101
102The new column goes to the left of the caret's column, empty. Deleting a row deletes
103the line; it doesn't go to the clipboard. When rows and columns move, are inserted or
104are deleted, the =#+TBLFM= line is updated to match: references are renumbered, and
105formulas for a deleted row or column are removed.
106
107The Mac preset uses the same keys for headings and list items; in a table they act on
108the table.
109
110** Sorting
111
112=C-c ^= in a table asks =Sort Table: [a]lphabetic, [n]umeric, [t]ime.  A/N/T means
113reversed:= and sorts the rows between the rules around the caret by the caret's
114column. If the caret isn't in a field, it asks for the column first. Sorting is stable.
115
116- *a* compares text without case.
117- *n* compares the number at the start of each field.
118- *t* compares a timestamp in the field, else a duration such as =1:30= or =2h 15min=,
119  else a clock time =H:MM=. Fields with none of these sort as 0.
120
121** Transposing
122
123Org ▸ Transpose Table swaps rows and columns. Rules are dropped.
124
125** The field editor
126
127=C-c `= opens the field at the caret in an editor of its own, which is easier for long
128text. =C-c '= or =⌘Return= puts it back; =Escape= or =C-c C-k= leaves it unchanged.
129Line breaks become single spaces and lines that start with =#= are dropped, as
130=org-table-finish-edit-field= does.
131
132* Narrow columns
133
134A field that holds a width cookie =<N>=, optionally with an alignment letter
135(=<l10>=, =<c8>=, =<r12>=), marks the column for narrowing. Narrowed fields show their
136first /N/ display columns followed by =…=. The text itself is unchanged.
137
138| Command                                  | Org command                       | Keys                                     |
139|------------------------------------------+-----------------------------------+------------------------------------------|
140| Org ▸ Shrink or Expand Table Column      | =org-table-toggle-column-width=   | Emacs and Doom =C-c TAB=                 |
141| Org ▸ Shrink Table Columns with Widths   | =org-table-shrink=                | No default key                           |
142| Org ▸ Expand Table Columns               | =org-table-expand=                | No default key                           |
143
144=C-c TAB= in a field toggles that column. Outside a column, for example on the leading
145=|=, it asks for =Column ranges (e.g. 2-4 6-):=, where =6-= means column 6 to the end.
146A column without a width cookie shrinks to a bare =…= when toggled. Typing in a narrowed
147field widens its column again, as editing Org's overlays does. =#+STARTUP: shrink=
148narrows every column with a width cookie when the file opens.
149
150The iOS editor narrows columns the same way, with =#+STARTUP: shrink= and the three
151commands, which are in Commands when the caret is in a table. The iOS reader shows
152tables at full width.
153
154* Importing and exporting
155
156| Command                                | Org command        |
157|----------------------------------------+--------------------|
158| Import Table from File… (command palette) | =org-table-import= |
159| Export Table to File… (command palette)   | =org-table-export= |
160
161Open the command palette with =⇧⌘P= (=M-x= in the Emacs preset, =SPC := in Doom). On
162iOS, both are under More › Table in the editor, as Import Table from File…, Export Table
163as CSV… and Export Table as TSV…, and in Commands; the file comes from, and goes to, the
164Files app.
165
166Import asks for a CSV, TSV or plain text file, inserts its contents at the caret on a
167line of its own, and converts them to a table with the separator guessed as for a
168region (see /Creating a table/).
169
170Export writes the table at the caret. A file name ending in =.csv= gets CSV: fields
171separated by commas, with fields that contain a comma or a double quote quoted and
172inner quotes doubled. Any other name gets TSV. Rules are left out.
173
174* Formulas
175
176orgstar evaluates Org's spreadsheet formulas, =org-table-recalculate= and
177=org-table-eval-formula=, natively: Calc expressions in a reimplementation of the part
178of Emacs Calc that tables use, and Lisp formulas in a small Emacs Lisp evaluator. What
179falls outside them is handed to Emacs on the Mac (see /When Emacs is needed/).
180
181Formulas live in a =#+TBLFM:= line right after the table, separated by =::=:
182
183#+BEGIN_SRC org
184| Item  | Qty | Price | Total |
185|-------+-----+-------+-------|
186| Apple |   3 |  0.50 |  1.50 |
187| Pear  |  12 |  0.75 |  9.00 |
188|-------+-----+-------+-------|
189| Sum   |     |       | 10.50 |
190,#+TBLFM: $4=$2*$3;%.2f::@>$4=vsum(@I..@II);%.2f
191#+END_SRC
192
193Blank lines between the table and =#+TBLFM:= are allowed. If there are several
194=#+TBLFM:= lines, recalculating the table uses the first; =C-c C-c= on another applies
195that line instead (=org-table-calc-current-TBLFM=).
196
197** Kinds of formula
198
199| Left side               | Kind                 | Applies to                                                       |
200|-------------------------+----------------------+------------------------------------------------------------------|
201| =$3=                    | Column formula       | Every data row of column 3, except rows marked =!=, =^=, =_=, =$= or =/= in the first column. |
202| =$<=, =$>=              | Column formula       | The first or last column.                                        |
203| =@2$3=, =@>$3=          | Field formula        | One field. Field formulas override column formulas.               |
204| =@2$2..@4$3=            | Range formula        | Every field in the rectangle.                                    |
205| =@4=                    | Row formula          | Every field of data row 4.                                       |
206| =$name=                 | Named field formula  | The field named by a =^= or =_= row (see /Names, parameters and constants/). |
207
208A left side relative to the current row, such as =@-1$2=, is an error
209(=Unknown field=), and so is one relative to a rule, such as =@I$2=, as in Org. Two
210formulas for the same field are an error.
211
212** References
213
214Rows count data lines from 1; rules don't count. Columns count from 1.
215
216| Reference            | Meaning                                                              |
217|----------------------+----------------------------------------------------------------------|
218| =$2=                 | Column 2 in the current row.                                         |
219| =$-1=, =$+1=         | The column before or after the current one.                          |
220| =$<=, =$>=, =$>>=    | The first column, the last, the one before last.                     |
221| =@3=                 | Row 3 in the current column.                                         |
222| =@-1=, =@+1=         | The row above or below.                                              |
223| =@<=, =@>=           | The first or last data row.                                          |
224| =@I=, =@II=, =@III=  | The first, second, third rule; as a row, the line after it.          |
225| =@-I=                | The rule above the current row.                                      |
226| =@I+2=               | Two data rows after the first rule.                                  |
227| =@2$3=               | Row 2, column 3.                                                     |
228| =$0=                 | The current column.                                                  |
229| =@0=                 | The current row: =@0$2= is =$2=.                                     |
230| =@#=, =$#=           | The current row's or column's number, as a value.                    |
231| =@2$1..@4$3=         | A range: the fields of the rectangle, as a vector.                   |
232| =$1..$3=             | Columns 1 to 3 of the current row.                                   |
233| =@I..@II=            | The current column from the first rule to the second.                |
234
235In a Calc formula a single field becomes a number in parentheses, and a range becomes
236a vector such as =[1,2,3]=. Without the =E= flag, empty fields count as 0 on their own
237and are left out of ranges.
238
239A field's text goes into the formula as it is, so a field holding text such as =N/A= or
240=TBD= becomes Calc variables and the result is a formula: =$1+5= with =N/A= in =$1=
241gives =N / A + 5=. The =N= flag reads every field as a number instead, with text as 0.
242A field such as =21.11.2026= or =192.168.1.1=, with more than one decimal point, is
243=#ERROR=, as Calc can't read it as a number. A range whose only non-empty field holds
244text with a space, such as =5 kg=, needs Emacs: Calc reads a vector without commas as
245elements separated by spaces.
246
247** Names, parameters and constants
248
249The first column can mark special rows, as in Org's spreadsheet:
250
251| Mark  | Row                                                                                   |
252|-------+---------------------------------------------------------------------------------------|
253| =!=   | Column names: =$qty= in a formula means the column whose =!= row field is =qty=.      |
254| =^=   | Names for the fields in the row above, usable as =$name=.                            |
255| =_=   | Names for the fields in the row below.                                               |
256| =$=   | Parameters: fields like ~rate=0.2~, usable as =$rate=.                               |
257| =#=   | Marked for recalculation.                                                            |
258| =*=   | Marked for recalculation.                                                            |
259| =/=   | Not recalculated.                                                                    |
260
261When any row's first field is one of =!=, =^=, =_=, =$=, =#= or =*=, column formulas
262in a whole-table recalculation apply only to the rows marked =#= or =*=, as
263=org-table-calculate-mark-regexp= decides in Org. So a table with a =!= names row and
264no =#= rows gets no column formulas applied; mark the rows to calculate. Field
265formulas apply either way. Rows marked =!=, =^=, =_=, =$= or =/= are never changed by
266column formulas.
267
268#+BEGIN_SRC org
269| ! | qty | price | total |
270|---+-----+-------+-------|
271| # |   2 |     3 |     6 |
272| # |   4 |   0.5 |     2 |
273,#+TBLFM: $4=$qty*$price
274#+END_SRC
275
276A =$name= that isn't a column name, parameter or named field is looked up as
277=org-table-get-constant= does:
278
279- in =#+CONSTANTS:= lines of the file or its setup file, written ~name=value~ and
280  separated by spaces (~#+CONSTANTS: c=299792458 g=9.81~);
281- =$PROP_xyz= reads the =xyz= property of the entry holding the table, with
282  inheritance.
283
284A name that isn't found becomes =#UNDEFINED_NAME=. A parameter named =%= in a =$= row,
285for example ~%=%.2f~, is put in front of the flags of every formula that has a =;=,
286so ~$3=$2/3;~ is formatted with =%.2f=.
287
288** Remote references
289
290=remote(NAME, REF)= reads a field or range from another table:
291
292#+BEGIN_SRC org
293,#+NAME: rates
294| item | rate |
295|------+------|
296| a    |    2 |
297| b    |    3 |
298
299| x | y | z |
300|---+---+---|
301| 4 | 8 | 5 |
302,#+TBLFM: $2=$1*remote(rates,@2$2)::$3=vsum(remote(rates,@2$2..@>$2))
303#+END_SRC
304
305=NAME= is found in this order:
306
3071. a table after =#+NAME: NAME= or =#+TBLNAME: NAME= in the same file;
3082. the first table in the entry whose =ID= property is =NAME=, in the same file;
3093. the first table in the entry with that =ID= in any indexed file in your sidebar
310   folders, read from the file on disk.
311
312=REF= may use spreadsheet-style references such as =B3= (column B, row 3), which
313become =@3$2=. A =REF= without a row, such as =$1..$2=, reads the row of the other
314table that has the current row's number. =NAME= can itself be a reference: in
315=remote($1,@1$1)=, the current row's first field holds the table's name.
316
317** Calc expressions
318
319Calc formulas use Calc's number rules: integers are exact, and decimal numbers are
320rounded to 12 significant digits after every operation. Results are shown with up to
3218 significant digits unless a format flag says otherwise (=org-calc-default-modes=).
322
323Operators, from lowest to highest precedence (the lowest, ~||~, is logical or: the left
324side if it is nonzero, else the right side):
325
326| Operator                           | Meaning                                                   |
327|------------------------------------+-----------------------------------------------------------|
328| =&&=                               | Logical and: the left side if it is zero, else the right side. |
329| ~==~, ~!=~, =<=, =>=, ~<=~, ~>=~    | Comparisons, giving 1 or 0. They can't be chained.        |
330| =+=, =-=                           | Addition and subtraction.                                 |
331| =/=, =%=, =\=                      | Division, modulo (sign of the divisor), integer division rounding down. |
332| =*=                                | Multiplication. Values side by side also multiply: =2 3=, =2 (x)=. It groups from the right: =a * b c= is =a * (b c)=. |
333| unary =-=                          | Negation.                                                 |
334| =^=                                | Power.                                                    |
335| =!=, =!!= after a value            | Factorial, double factorial.                              |
336| =!= before a value                 | Logical not: =!x^2= is =(!x)^2= and =!x + 1= is =(!x) + 1=. |
337| =%= after a value                  | Percent: =5%= is =0.05=. Followed by a value, =%= is modulo instead. |
338
339Parentheses group, =[a, b, c]= writes a vector, =<2026-10-05 Mon>= writes a date, and
340=nan= is "not a number". =1:3= writes the fraction one third and =1:2:3= one and two
341thirds; =16#FF= writes an integer in base 16 (any base from 2 to 36).
342
343Functions:
344
345| Function                                   | Result                                                        |
346|--------------------------------------------+---------------------------------------------------------------|
347| =vsum=, =vprod=                            | Sum or product of a vector.                                   |
348| =vcount=                                   | Number of elements.                                           |
349| =vmean=, =vmedian=                         | Mean, median.                                                 |
350| =vgmean=, =vhmean=                         | Geometric mean, harmonic mean.                                |
351| =vmax=, =vmin=                             | Largest, smallest element.                                    |
352| =vvar=, =vsdev=                            | Sample variance, sample standard deviation.                   |
353| =vpvar=, =vpsdev=                          | Population variance, population standard deviation.           |
354| =vcov(x, y)=, =vpcov(x, y)=, =vcorr(x, y)= | Sample and population covariance, correlation coefficient.    |
355| =vflat=                                    | The arguments as one vector.                                  |
356| =agmean(a, b)=                             | Arithmetic-geometric mean.                                    |
357| =max(a, b, …)=, =min(a, b, …)=             | Largest, smallest argument.                                   |
358| =if(c, a, b)=                              | =a= if =c= is nonzero, else =b=.                              |
359| =abs=                                      | Absolute value.                                               |
360| =floor=, =ceil=, =trunc=                   | Round down, up, toward zero, to an integer.                   |
361| =round(x)=, =round(x, n)=                  | Round to an integer, or to /n/ decimal places.                |
362| =rounde=, =roundu=                         | As =round=, with halves going to even, or up.                 |
363| =frac(x)=                                  | The fraction nearest to /x/.                                  |
364| =fdiv(a, b)=                               | /a/ divided by /b/ as a fraction.                             |
365| =float(x)=, =pfloat(x)=                    | /x/ as a decimal number.                                      |
366| =sign=                                     | -1, 0 or 1.                                                   |
367| =mod(a, b)=, =idiv(a, b)=                  | As =%= and =\=.                                               |
368| =gcd(a, b)=, =lcm(a, b)=                   | Greatest common divisor, least common multiple.               |
369| =fact=, =dfact=                            | Factorial and double factorial of a non-negative integer.     |
370| =choose(n, m)=, =perm(n, m)=               | Binomial coefficient and permutations, of integers.           |
371| =sqrt=, =exp=, =ln=, =log10=               | Square root, exponential, natural and base-10 logarithm.      |
372| =log(x, b)=                                | Logarithm of /x/ to base /b/.                                 |
373| =pow(x, y)=, =nroot(x, n)=, =exp10(n)=     | /x/ to the power /y/, /n/-th root, 10 to an integer power.    |
374| =hypot(a, b)=                              | The square root of /a/² + /b/².                               |
375| =sin=, =cos=, =tan=                        | Trigonometry, in degrees unless the =R= flag is set.          |
376| =arcsin=, =arccos=, =arctan=, =arctan2(y, x)= | Inverse trigonometry, in degrees unless =R=.               |
377| =sinh=, =cosh=, =tanh=                     | Hyperbolic functions.                                         |
378| =arcsinh=, =arccosh=, =arctanh=            | Inverse hyperbolic functions.                                 |
379| =deg=, =rad=                               | Radians to degrees, degrees to radians.                       |
380| =eq=, =neq=, =lt=, =gt=, =leq=, =geq=      | As ~==~, ~!=~, =<=, =>=, ~<=~ and ~>=~.                       |
381| =land=, =lor=, =lnot=                      | As =&&=, ~||~ and =!=.                                        |
382
383The statistics functions take any number of vectors and numbers, as in
384=vmean($2..$4, $6)=.
385
386Calc leaves what it can't reduce to a number as a formula, and so does orgstar for
387sums, differences, products, quotients and powers:
388
389- A name is a variable: =2*x + x= is =3 x=. Calc's constants =pi=, =e=, =phi= and =gamma=
390  stay names too: =$1^2*pi= gives =9 pi= for 3.
391- Division by zero stays unevaluated: =$1/$2= with 6 and an empty field gives =6/0=,
392  and =x/0 + 1= gives =x / 0 + 1=.
393- =inf=, =-inf= and =uinf= (infinity of unknown sign) follow Calc's rules: =inf - inf= is
394  =nan=, =1/inf= is =0=, =2^inf= is =inf=.
395- =vsum=, =vprod=, =vmean= and =vcount= take vectors holding such formulas.
396- =sqrt=, =abs=, =exp=, =ln=, =min=, =max=, =vmax=, =vmin= and =%= simplify a formula
397  as Calc does, or keep it: =abs(-x)= is =abs(x)=, =sqrt(4 x)= is =2 sqrt(x)=,
398  =vmax($2..$4)= over 4, =absent= and 8 is =max(max(4, absent), 8)=, and =x % 3= stays.
399- Comparisons, =&&=, =||=, =!= and =if= on a formula give a formula unless Calc can
400  decide them: =x == x= is 1, =$2 > 10= with =TBD= in =$2= is =TBD > 10=, and
401  =if($2 > 10, 1, 0)= is =TBD > 10 ? 1 : 0=.
402
403Other functions of a formula, =sqrt=, =exp= and =ln= of one under the =S= flag, and
404complex results such as =sqrt(-inf)= need Emacs.
405
406** Mode flags and formats
407
408After the formula, a =;= starts its flags, as in ~$3=$1/$2;%.2f~ or ~$4=$1*2;f2~:
409
410| Flag      | Meaning                                                                                   |
411|-----------+-------------------------------------------------------------------------------------------|
412| =nN=      | Float format with /N/ significant digits.                                                 |
413| =fN=      | Fixed format with /N/ decimal places.                                                     |
414| =sN=      | Scientific format with /N/ digits.                                                        |
415| =eN=      | Engineering format with /N/ digits.                                                       |
416| =pN=      | Calc precision, 3 to 18 digits (12 by default). See below for limits.                     |
417| =D=, =R=  | Angles in degrees (the default) or radians.                                               |
418| =F=       | Prefer fractions: =1/3= stays =1:3=.                                                      |
419| =N=       | Treat every field as a number; text counts as 0.                                          |
420| =S=       | Symbolic: results that aren't exact stay as formulas, such as =sqrt(2)=.                  |
421| =E=       | Keep empty fields: in ranges they stay in, and count as =nan= in Calc.                    |
422| =L=       | Literal: in Lisp formulas, insert fields as they are written.                             |
423| =T=       | Durations: read =H:MM= and =H:MM:SS= fields as times, show the result as =HH:MM:SS=.      |
424| =U=       | As =T=, showing =HH:MM=.                                                                  |
425| =t=       | As =T=, showing decimal hours with two places, such as =1.50=.                            |
426
427Above =p14=, functions worked out from decimal approximations (=exp=, =ln=, =log=,
428non-integer powers, =sinh= and =cosh=) may need Emacs, and so may =tanh= above =p12=.
429Above =p16= so may the statistics functions, powers of decimal numbers, =sqrt= of a
430non-square and the trigonometric functions.
431
432With =S=, the functions that may give an inexact result (=sqrt=, =exp=, =ln=, =log=,
433=log10=, =pow=, =nroot=, =hypot=, the inverse trigonometric and hyperbolic functions,
434=fact=, =dfact=, the standard deviations, =vgmean=, =vhmean=, the covariances and
435=agmean=), powers other than integer powers, and =sin=, =cos= and =tan= in radians need
436Emacs.
437
438The flag =u= needs Emacs. Any other text after the flags is a
439=format= string applied to the result, such as =%.2f= or =%d=; =format= supports
440=%s=, =%S=, =%d=, =%o=, =%x=, =%X=, =%c=, =%e=, =%f= and =%g=.
441
442** Durations
443
444With =T=, =U= or =t=, fields like =1:30= or =10:00:30= are read as hours, minutes and
445seconds:
446
447#+BEGIN_SRC org
448| start    | end     | sum      | diff  | hours |
449|----------+---------+----------+-------+-------|
450| 1:30     | 0:45    | 02:15:00 | 00:45 |  3.00 |
451| 10:00:30 | 2:15:10 | 12:15:40 | 07:45 | 20.02 |
452,#+TBLFM: $3=$1+$2;T::$4=$1-$2;U::$5=$1*2;t
453#+END_SRC
454
455** Dates
456
457Timestamps in fields, active or inactive, take part in Calc arithmetic as dates. The
458difference of two dates is a number of days, with a fraction when the timestamps have
459times. A date plus a number is a date, written back as an inactive timestamp:
460
461#+BEGIN_SRC org
462| start            | end              | days | later            |
463|------------------+------------------+------+------------------|
464| <2026-10-05 Mon> | <2026-10-12 Mon> |    7 | [2026-10-12 Mon] |
465,#+TBLFM: $3=$2-$1::$4=$1+7
466#+END_SRC
467
468A date is its day number underneath, counted from 1 January of year 1, so the sum of two
469dates is a number and =vmean= of two dates is the day number halfway between them.
470=vsum=, =vmax=, =vmin=, =max=, =min=, =abs= and the comparisons work on dates; =floor=,
471=ceil=, =trunc= and =round= keep a date and drop or round its time. A timestamp with a
472time, even =00:00=, keeps showing one. Calc leaves =abs= of day 0 (=<-1-12-31>=)
473unevaluated, so that needs Emacs.
474
475| Function                                   | Result                                                                             |
476|--------------------------------------------+------------------------------------------------------------------------------------|
477| =year=, =month=, =day=                     | Parts of the date.                                                                 |
478| =hour=, =minute=, =second=                 | Parts of the time, 0 for a date without one.                                       |
479| =weekday=                                  | 0 for Sunday to 6 for Saturday.                                                    |
480| =yearday=                                  | Day of the year, 1 for 1 January.                                                  |
481| =date(y, m, d)=, =date(y, m, d, h, mi, s)= | The date, with a time when an hour is given. =date(m, d)= is this year.            |
482| =date(d)=                                  | The day number of date /d/, or the date of day number /d/.                         |
483| =now()=                                    | The current date and time.                                                         |
484| =incmonth(d, n)=, =incyear(d, n)=          | /n/ months or years later (1 by default), on the last day if the month is shorter. |
485| =newmonth(d, n)=, =newyear(d, n)=          | Day /n/ of the month or year (1 by default; 0 is the last day).                    |
486| =newweek(d, w)=                            | The day on or before /d/ that falls on weekday /w/ (0, Sunday, by default).        |
487| =badd(d, n)=, =bsub(d, n)=                 | /n/ business days later or earlier, skipping Saturdays and Sundays.                |
488| =bsub(d1, d2)=                             | Business days from /d2/ to /d1/.                                                   |
489| =julian(d)=                                | The Julian day number of /d/, or the date of a Julian day number.                  |
490| =unixtime(d)=                              | Seconds since 1970-01-01 00:00 UTC, or the date of a number of seconds.            |
491
492As in Calc, a timestamp year under 100 is read as 19xx or 20xx: 00 to 39 is 20xx, 40 to
49399 is 19xx. =badd= and =bsub= work only for dates in the years 1 to 2737, the range of
494Calc's holiday table; outside it they need Emacs, which leaves them unevaluated.
495
496=julian= of a date with a time and =unixtime= use the local time zone. Emacs applies
497the current year's daylight saving rules to every date, which orgstar doesn't, so in a
498time zone with daylight saving time these need Emacs.
499
500With =N=, =T=, =U= or =t= a timestamp field counts as 0. A result that is a date is
501=#ERROR= with =N=, and with =T=, =U= or =t= it stops the recalculation with the error
502Org gives.
503
504** Lisp formulas
505
506A formula that starts with ='(= is Emacs Lisp. Each reference becomes a Lisp string,
507or a number with =N=, or the field's text inserted as is with =L=. A range becomes the
508values separated by spaces, so wrap it in a quoted list:
509
510#+BEGIN_SRC org
511| name  | greeting |
512|-------+----------|
513| Ada   | Ada!     |
514| Grace | Grace!   |
515,#+TBLFM: $2='(concat $1 "!")
516
517| n |
518|---|
519| 1 |
520| 2 |
521|---|
522| 3 |
523,#+TBLFM: @>$1='(apply '+ '(@I..@II));N
524#+END_SRC
525
526The evaluator supports:
527
528- special forms: =quote=, =function=, =lambda=, =progn=, =prog1=, =if=, =when=,
529  =unless=, =cond=, =and=, =or=, =let=, =let*=, =setq=, =push=, =pop=, =while=,
530  =dolist=, =dotimes=, =with-output-to-string=, =ignore-errors=, =condition-case=,
531  =save-match-data=, =defun=, =defvar=, =defconst=, =let-alist=, =cl-incf= and =cl-decf=
532  on a variable, with dynamic binding, as Org evaluates formulas;
533- =pcase= with literal, symbol, quoted, backquoted and =pred= patterns, where =pred=
534  takes a function name or a lambda;
535- =cl-loop= with =for VAR in LIST=, =for VAR from START to END=, and one kind of
536  =collect= or =sum=, with =do=;
537- arithmetic: =+=, =-=, =*=, =/=, =%=, =mod=, =1+=, =1-=, =abs=, =max=, =min=, =float=,
538  =floor=, =ceiling=, =round=, =truncate=, ~=~, =<=, =>=, ~<=~, ~>=~, ~/=~, =zerop=,
539  =expt=, =sqrt=, =exp=, =log=, =sin=, =cos=, =tan=, =asin=, =acos=, =atan=, =isnan=,
540  =random=, =logand=, =logior=, =logxor=, =ash=, and the variables =float-pi=, =pi= and
541  =float-e=;
542- predicates: =not=, =null=, =eq=, =eql=, =equal=, =numberp=, =integerp=, =floatp=,
543  =stringp=, =listp=, =consp=, =symbolp=;
544- lists: =car=, =cdr=, =cadr=, =cddr=, =cons=, =list=, =nth=, =nthcdr=, =elt=, =aref=,
545  =append=, =length=, =reverse=, =number-sequence=, =memq=, =member=, =memql=, =assoc=,
546  =assq=, =delq=, =delete=, =mapcar=, =mapc=, =mapconcat=, =funcall=, =apply=,
547  =identity=, =ignore=, =last=, =butlast=, =delete-dups=, =nreverse=, =sort= (both
548  calling conventions; these three need Emacs when they would change a list that
549  another variable, list or argument may share), =seq-reduce=, =seq-filter=, =seq-remove=, =seq-map=, =seq-uniq=,
550  =cl-reduce= (with =:initial-value=), =cl-remove-if=, =cl-remove-if-not=, =cl-find= and
551  =cl-position= (with =:test=);
552- strings: =concat=, =format=, =format-message=, ~string=~, =string-equal=, =string<=,
553  =string-lessp=, =upcase=, =downcase=, =capitalize=, =substring=, =string-to-number=,
554  =number-to-string=, =int-to-string=, =string-prefix-p=, =string-suffix-p=,
555  =string-empty-p=, =string-trim=, =split-string=, =prin1-to-string=, =string-join=,
556  =string-to-char=, =char-to-string=, =string-pad=, =string-width=, =string-search=,
557  =string-replace=;
558- regular expressions: =string-match=, =string-match-p=, =match-beginning=, =match-end=,
559  =match-string=, =replace-match= and =replace-regexp-in-string= on strings, and
560  =regexp-quote=;
561- time: =current-time=, =format-time-string=, =float-time=, =time-add=, =time-subtract=,
562  =time-to-days=, =date-to-time=, =days-between=, =org-time-string-to-time=,
563  =org-time-string-to-absolute= and the =calendar-= functions that diary sexps use, in
564  the local time zone and the proleptic Gregorian calendar;
565- output and errors: =princ=, =prin1=, =print=, =terpri=, =message=, =error=,
566  =user-error=;
567- Org's lookup functions =org-lookup-first=, =org-lookup-last= and =org-lookup-all=.
568
569Regular expressions use Emacs's syntax and the syntax table of an Org buffer, and
570=case-fold-search= is on unless the formula binds it to =nil=. These need Emacs:
571numbered groups =\\(?N:=, categories =\\c=, syntax classes and character classes
572such as =\\w=, =\\b= or =[[:alpha:]]= against text with characters past ASCII,
573and case folding of a letter past ASCII, including =capitalize=. =condition-case=
574binds its variable to the error symbol and data, such as =(wrong-type-argument listp 1)=;
575reading that variable for an error whose data orgstar doesn't know, such as
576=args-out-of-range=, needs Emacs, as does a handler that names a specific condition
577when the error isn't one of =wrong-type-argument=, =args-out-of-range=, =arith-error=,
578=void-variable=, =invalid-function=, =wrong-number-of-arguments=, =error= and
579=user-error=. =format-time-string= takes =%Y=, =%y=, =%m=,
580=%d=, =%e=, =%H=, =%k=, =%I=, =%l=, =%M=, =%S=, =%p=, =%a=, =%A=, =%b=, =%h=, =%B=, =%u=,
581=%w=, =%j=, =%F=, =%D=, =%R=, =%T=, =%s=, =%z=, =%n=, =%t= and =%%=, without flags or
582widths; other codes need Emacs, as do float times in =time-add= and =time-subtract=. =date-to-time= and =days-between= read dates as
583=YYYY-MM-DD=, with an optional =HH:MM= or =HH:MM:SS=.
584
585Any other function, or a macro not listed, needs Emacs. As in Emacs 31, =lambda= and
586=function= make function objects rather than lists, so a formula whose value is one, or
587that prints one or takes it apart as a list, needs Emacs; calling one, or passing it to a
588function that calls it, doesn't. An error inside a Lisp formula
589writes =#ERROR= in the field, as does a Calc error. So does a value that is a non-empty
590list, ignoring the format; with =T=, =U= or =t= such a value needs Emacs.
591
592=org-sbe= writes the value of a named src block, run with the variables given:
593
594#+BEGIN_SRC org
595,#+NAME: square
596,#+begin_src emacs-lisp :var n=2
597(* n n)
598,#+end_src
599
600| n | square |
601|---+--------|
602| 3 |      9 |
603,#+TBLFM: $2='(org-sbe square (n $1))
604#+END_SRC
605
606As in Org, a field's text is read as a value, so =abc= names another block or table;
607write =$$1= instead of =$1= to pass the text as a string. A string before the variables
608holds header arguments, and the name may also be a named table or list in the file. As in
609Org, a name under a =COMMENT= heading is skipped, and the name's case must match. =org-sbe= needs Pro's source blocks
610feature.
611
612Emacs Lisp blocks run in orgstar's interpreter, with dynamic binding unless the block
613has =:lexical yes= or =:lexical t=, and =js= blocks run in JavaScriptCore, everywhere and
614without asking, since neither can reach files or other programs. After five seconds orgstar
615stops waiting for a =js= block and the table needs Emacs; a block that never finishes
616keeps running in the background until orgstar quits, and isn't started again while it runs. Blocks in other languages, blocks with =:cache yes=,
617=:file= results or column and row names, other =:lexical= values, values that hold a
618function, Lisp values with symbols in a variable with several values, a name given to
619more than one element, in any case, when the first isn't a src block, references to an =ID= or
620=CUSTOM_ID=, and =js= values that are arrays need Emacs. When Emacs runs a table in a file
621that uses =org-sbe=, it runs the blocks without asking again, so orgstar asks
622=This table's formulas run Lisp and source blocks. Run them? (yes, no)= each time.
623
624* Entering formulas
625
626There are three ways to set a formula.
627
628*In the field.* Type ~=expr~ in a field and press =TAB= or =RET=: orgstar stores
629~$N=expr~ as the column's formula and evaluates it, as
630=org-table-maybe-eval-formula= does. Type ~:=expr~ instead to store a field formula
631~@R$C=expr~.
632
633*With a prompt.* =org-table-eval-formula= asks for the formula (~Column formula $N=~
634or ~Field formula @R$C=~) with the stored one filled in, stores it and evaluates it in
635the current field. Clearing the prompt and pressing =Return= removes the stored
636formula, as in Emacs, and the echo area shows =Formula removed=. You can also delete a
637formula in the formula editor below or from the =#+TBLFM:= line.
638
639| Command                       | Emacs    | Mac                         | Doom     |
640|-------------------------------+----------+-----------------------------+----------|
641| Org ▸ Set Column Formula      | ~C-c =~  | Org ▸ Set Column Formula    | ~C-c =~  |
642| Org ▸ Set Field Formula       | none     | Org ▸ Set Field Formula     | none     |
643
644Org's ~C-u C-c =~ for field formulas has no equivalent key, because orgstar has no
645prefix argument; use the menu item or type ~:=~ in the field.
646
647*In the formula editor.* =C-c '= in a table or on its =#+TBLFM:= line
648(=org-table-edit-formulas=) opens the formulas in an editor of their own, one per line,
649grouped under =# Column Formulas=, =# Field and Range Formulas= and
650=# Named Field Formulas=. A formula can continue on indented lines. =C-c '= or
651=⌘Return= installs the formulas; =Escape= or =C-c C-k= leaves them unchanged.
652Installing doesn't recalculate. The echo area says so and points to Recalculate Table:
653=C-c C-c= on the =#+TBLFM:= line, or =⌃⌘X= there in the Mac preset.
654
655The formulas are stored sorted the way =org-table-formula-less-p= sorts them.
656
657* Recalculating
658
659| Command                          | Org command                       | Emacs                         | Mac                         | Doom                                |
660|----------------------------------+-----------------------------------+-------------------------------+-----------------------------+-------------------------------------|
661| Recalculate Table                | =org-table-recalculate= with =C-u= | =C-c C-c= on =#+TBLFM:=      | =⌃⌘X= on =#+TBLFM:=         | =SPC m b r=, =C-c C-c= on =#+TBLFM:= |
662| Recalculate Table Row            | =org-table-recalculate=           | =C-c *=                       | =⌃⌘*= (=⌃⇧⌘8= on a US keyboard) | =C-c *=                             |
663| Iterate Table Formulas           | =org-table-iterate=               | =C-u C-u C-c *=               | —                           | —                                   |
664
665In Doom's normal state, =RET= in a table recalculates it when it has a =#+TBLFM:=
666line and aligns it otherwise; on a =#+TBLFM:= line it recalculates.
667
668When the table has a rule below its first data row, recalculating the whole table
669leaves the rows above that rule, the header, alone. With marked rows, the marks decide
670instead (see /Names, parameters and constants/). Each
671command evaluates the column formulas row by row, then the field formulas, then aligns
672the table. Each formula is evaluated once. Iterate Table Formulas recalculates the whole
673table again and again until it stops changing, for formulas that depend on each other's
674results, at most ten times. The echo area says =Convergence after 3 iterations=, or
675=Table was already stable=; after ten passes that still change the table it says =No
676convergence after 10 iterations=, and the ten passes stay. =C-u C-c *= also recalculates
677the whole table in the Emacs preset.
678
679A formula that fails, such as one whose reference leads outside the table, stops the
680command there. As in Emacs, the fields written before it stay, the table isn't aligned,
681the caret goes to the start of its field (on a =#+TBLFM= line it stays put), and the echo
682area shows the error.
683=TAB=, =S-TAB= and =RET= in a row marked =#= stop there too, without moving on.
684
685A row marked =#= is recalculated when you press =TAB=, =S-TAB= or =RET= in it, before
686the caret moves (=org-table-maybe-recalculate-line=), and with =C-c C-c= (Mac =⌃⌘X=).
687Other rows are recalculated only by the commands above. Emacs skips a second automatic
688recalculation of the same row by the same command in a row; orgstar recalculates each
689time, which gives the same result unless a formula depends on its own value.
690
691* When Emacs is needed
692
693When a formula uses something the native evaluator doesn't have, the command reports
694what it was and the Mac recalculates the table in Emacs instead. This happens for:
695
696- symbolic results beyond those under /Calc expressions/, such as a function of a field
697  holding text;
698- Calc functions not listed above, intervals such as =[1..5]=, precisions beyond those
699  given under /Mode flags and formats/, parts of the =S= flag, and the =u= flag;
700- complex results, vectors of anything but numbers, numbers too large for 64-bit
701  integers, and decimal numbers past Calc's limit of 10^±4000000;
702- Lisp functions not listed above.
703
704The echo area shows =Recalculating in Emacs (reason)…=, then =Recalculated in Emacs=.
705orgstar runs =emacs -Q --batch= on a copy of the file, so your Emacs init file,
706packages and customizations are not loaded, then replaces the table with Emacs's
707result. It looks for Emacs at the path in the =ORGSTAR_EMACS= environment variable,
708then =/opt/homebrew/bin/emacs=, =/usr/local/bin/emacs=,
709=/Applications/Emacs.app/Contents/MacOS/Emacs=, =/run/current-system/sw/bin/emacs= and
710=/usr/bin/emacs=. If none is found, the table is recalculated as in the Mac App Store
711version, described below.
712Emacs gets your =PATH= with =/opt/homebrew/bin=, =/usr/local/bin=,
713=/Library/TeX/texbin=, =/usr/bin= and =/bin= added, as code blocks and export do, so
714programs a formula starts are found when orgstar was opened from the Dock. The run
715stops after 60 seconds. If you edit the table while Emacs is working, its result is
716discarded.
717
718Edit ▸ Cancel Running Task (=⌘.=) stops the recalculation; the echo area shows
719=Recalculation canceled= and the table is unchanged. Starting another recalculation or
720export in Emacs cancels the one that is running.
721
722The [[file:../install.org][Mac App Store version]] doesn't run Emacs, so it recalculates
723only the tables orgstar computes itself. In any other table it applies the formulas in
724Emacs's order up to the first one it can't compute and stops there, as Emacs does when a
725formula fails: the fields written before it stay, unaligned, and the rest are unchanged.
726The echo area shows =The table was recalculated up to (formula), which can't be
727calculated here: (reason).=, where /formula/ is the left-hand side, such as =$4=. When nothing
728was written, it shows =This table's formulas can't be calculated here: (reason).= and the
729table is unchanged.
730
731If the table's formulas contain Lisp, orgstar asks first:
732=This table's formulas run Lisp. Run them? (yes, no, always)=. =always= trusts this
733table's text in this file, so the question isn't asked again until the text changes.
734
735Entering a formula that needs Emacs with ~C-c =~, Set Field Formula or ~=~ in a field
736is not handed to Emacs. The formula is stored in the =#+TBLFM:= line and the field is
737left as it was; the echo area shows =The formula was stored; recalculating it needs
738Emacs= and the reason. =TAB= and =RET= still move to the next field. Recalculate the
739table to run the formula in Emacs. In the Mac App Store version the echo area shows
740=The formula was stored; it can't be calculated here:= and the reason, and recalculating
741doesn't run it.
742
743For how orgstar and Emacs share files, see
744[[file:15-alongside-emacs.org][Using orgstar alongside Emacs]].
745
746* table.el tables
747
748Tables drawn with =+= corners and =-= and =|= borders, as the =table.el= package makes
749them, are recognized and kept as written:
750
751#+BEGIN_SRC org
752+-------+-------+
753| Name  | Value |
754+-------+-------+
755| a     | 1     |
756+-------+-------+
757#+END_SRC
758
759Edit the text in the cells as usual. =TAB= and =S-TAB= line the borders up, then move to
760the next or previous cell, wrapping around at the ends of the table, as table.el's
761=table-forward-cell= and =table-backward-cell= do; the caret goes to the cell's first
762character. =C-c C-c= (Mac =⌃⌘X=) lines the borders up without moving. Lining up makes
763each column as wide as its widest text, and never narrower than its rules: text typed
764into a cell uses up the spaces at its end first, as table.el does when you type.
765
766Org edits table.el tables in table.el's own buffer, with =C-c '=, and says so for =TAB=
767and =C-c C-c=; orgstar does the editing in place instead. Tables with merged cells, which
768span rows or columns, can be moved through but not lined up ("Can't align a table.el
769table with merged cells"). Formulas, sorting and the other table commands don't apply.
770
771HTML export renders them as tables, with cells that span rows and columns, and Markdown
772export writes them as a code block. See [[file:12-export.org][Export]].
773
774* Plotting
775
776Plot Table (=org-plot/gnuplot=, =C-c " g= in the Emacs and Doom presets, and in the
777command palette; More › Table on iOS) draws the table at the caret, or the first table
778after it, as the =#+PLOT:= lines above it say:
779
780#+BEGIN_SRC org
781#+PLOT: title:"Sales" ind:1 deps:(2 3) type:2d with:linespoints file:"sales.png"
782| month | north | south |
783|-------+-------+-------|
784|     1 |    20 |    12 |
785|     2 |    25 |    18 |
786#+END_SRC
787
788| Option     | Meaning                                                                     |
789|------------+-----------------------------------------------------------------------------|
790| =type=     | =2d= (the default), =3d=, =grid= or =radar=                                 |
791| =ind=      | The column of x values, counting from 1; 0 (the default) plots against row numbers |
792| =deps=     | The columns to plot, as a list such as =(2 3)=; all but =ind= by default    |
793| =with=     | =lines= (the default), =points=, =linespoints=, =impulses=, =boxes=, =histograms=, =steps=, =fsteps= |
794| =title=    | The plot's title                                                            |
795| =file=     | Where the image goes, relative to the Org file's folder; without it the plot shows in a sheet |
796| =labels=   | Names for the columns, as a list; a header row above a rule names them otherwise |
797| =map=      | With =t=, a =3d= plot is seen from above                                    |
798| =ymin=, =ymax=, =xmin=, =xmax= | The axes' ranges; =min= and =max= are =ymin= and =ymax=   |
799| =ticks=    | How many marks the y axis has; for =radar=, how many rings the web has      |
800| =transpose= | With =yes=, rows become columns                                            |
801| =set=, =line=, =script=, =timefmt= | gnuplot commands, a line of gnuplot, a gnuplot script file and the time format, for gnuplot |
802
803Options are read as Org reads them, quirks included: an option's name also matches inside
804a longer word (=timeind:t= sets =ind=), an unquoted value ends at a =.=, =,= or =;=, =set:=
805options before the last =line:= are dropped, and each =set:= and =line:= that's kept comes
806twice, as Org reads the options twice. An ind column of timestamps is plotted as dates, and one of text as labels.
807
808A =radar= plot draws each row as an axis, clockwise from the top, and each column after
809the first as a series named by the header. Each axis is scaled from its row's lowest and
810highest values rounded outward (120 to 340 becomes 100 to 400), or from =ymin= to =ymax=. Org
811works out the number of rings from the values; where Org can't (it signals an error, as for a
812=ymin= above a row's values, or never finishes, as for a row whose values are all the same),
813orgstar reports it and asks for =ticks:=. =ticks:= can't be below 0, and without gnuplot it
814takes at most 1000. A row whose values or their range overflow a double is refused, as Emacs signals an
815error for it.
816
817On the Mac, when gnuplot is installed (orgstar looks on the same =PATH= as code blocks), the
818table goes to gnuplot as Emacs sends it: the same data file and script, so every option and
819gnuplot's own terminals and styles apply. A plot without =file:= is drawn to an image and shown
820in a sheet. Without gnuplot, and on iOS, orgstar draws the plot itself with Swift Charts: =2d=
821as lines, points or bars by =with:=, =grid= as a heat map, =3d= as a surface (a wireframe in a
822file), =radar= as a web. =file:= then takes =.png=, =.jpg= or =.pdf=, 640 by 480 points as
823gnuplot's default, or =.svg= for a =2d= plot. A log axis places values from 1e-307 to
8241e308 and leaves out others; it needs at least one, and its range, if given, must lie
825within them. If inline images are showing, a link to the file
826shows the new plot.
827
828Without gnuplot these =set:= commands are followed, also as a =line:= that starts with =set=:
829
830| Command                                | Effect                                                                  |
831|----------------------------------------+-------------------------------------------------------------------------|
832| =title 'T'=                            | The title, over =title:=                                                |
833| =xlabel 'X'=, =ylabel 'Y'=             | The axes' names                                                         |
834| =xrange [0:10]=, =yrange [*:5]=        | The axes' ranges, low to high; =*= or nothing leaves an end to the data |
835| =logscale=, =logscale x=, =logscale y= | Logarithmic axes                                                        |
836| =grid=                                 | Grid lines at the marks                                                 |
837| =key off=, =key top left=              | Hides or places the legend (top, bottom, left, right; else top right)   |
838| =xtics 2=, =ytics 0.5=                 | A mark every so many units, on an axis that isn't logarithmic           |
839
840=2d= plots follow all of them, except that an x axis of text or dates takes no range, steps or
841log scale. =grid= and =3d map:t= plots follow the title and axis names; other =3d= plots
842and =radar= plots only the title. Other commands, other =line:= options and =script:= are left
843out, and the message after plotting names them, such as =Not followed without gnuplot:
844set:"style fill solid"=.
845
846The [[file:../install.org][Mac App Store version]] doesn't use gnuplot: it always draws
847the plot itself in the same way.
848
849* On iOS
850
851The iOS app evaluates formulas natively with the same engine. Tables that need Emacs
852are not recalculated there; the app reports =This table needs Emacs, which runs on the
853Mac= with the reason. Import and export are under More › Table, with Plot Table.
854Narrow columns work in the editor, as described under /Narrow columns/. See
855[[file:14-ios.org][iOS]].