docs/manual/guide/10-tables.org
553 lines · 30670 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 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. To align without moving, use Org ▸ Align Table:
62
63| Preset | Key |
64|--------+------------------------------|
65| Emacs | =C-c C-c= in a table |
66| Mac | Org ▸ Align Table |
67| Doom | =C-c C-c=, or =SPC m b a= |
68
69To align every table when a file opens, set =org-startup-align-all-tables= to =true=
70in the config file (default =false=), or put =#+STARTUP: align= in the file;
71=#+STARTUP: noalign= turns it off for that file. See
72[[file:13-configuration.org][Configuration]].
73
74* Editing rows and columns
75
76| Action | Org command | Emacs | Mac | Doom |
77|-----------------------------------+----------------------------+----------------+-------------+-------------------------------|
78| Move row up | =org-table-move-row-up= | =M-<up>= | =⌃⌘↑= | =M-<up>=, =M-k= |
79| Move row down | =org-table-move-row-down= | =M-<down>= | =⌃⌘↓= | =M-<down>=, =M-j= |
80| Move column left | =org-table-move-column-left= | =M-<left>= | =⌃⌘←= | =M-<left>=, =M-h= |
81| Move column right | =org-table-move-column-right= | =M-<right>= | =⌃⌘→= | =M-<right>=, =M-l= |
82| Insert column | =org-table-insert-column= | =M-S-<right>= | =⌃⌥⌘→= | =M-S-<right>=, =SPC m b i c= |
83| Delete column | =org-table-delete-column= | =M-S-<left>= | =⌃⌥⌘←= | =M-S-<left>=, =SPC m b d c= |
84| Insert row above | =org-table-insert-row= | =M-S-<down>= | =⌃⌥⌘↓= | =M-S-<down>=, =SPC m b i r= |
85| Delete row | =org-table-kill-row= | =M-S-<up>= | =⌃⌥⌘↑= | =M-S-<up>=, =SPC m b d r= |
86| Insert rule below | =org-table-insert-hline= | =C-c -= | =⌃⌘-= | =C-c -=, =SPC m b -=, =SPC m b i h= |
87| Sort rows | =org-table-sort-lines= | =C-c ^= | Org ▸ Sort Table Lines | =C-c ^= |
88| Transpose | =org-table-transpose-table-at-point= | Org ▸ Transpose Table | Org ▸ Transpose Table | Org ▸ Transpose Table |
89| Edit field in its own editor | =org-table-edit-field= | =C-c `= | Org ▸ Edit Table Field | =C-c `= |
90
91The new column goes to the left of the caret's column, empty. Deleting a row deletes
92the line; it doesn't go to the clipboard. When rows and columns move, are inserted or
93are deleted, the =#+TBLFM= line is updated to match: references are renumbered, and
94formulas for a deleted row or column are removed.
95
96The Mac preset uses the same keys for headings and list items; in a table they act on
97the table.
98
99** Sorting
100
101=C-c ^= in a table asks =Sort Table: [a]lphabetic, [n]umeric, [t]ime. A/N/T means
102reversed:= and sorts the rows between the rules around the caret by the caret's
103column. If the caret isn't in a field, it asks for the column first. Sorting is stable.
104
105- *a* compares text without case.
106- *n* compares the number at the start of each field.
107- *t* compares a timestamp in the field, else a duration such as =1:30= or =2h 15min=,
108 else a clock time =H:MM=. Fields with none of these sort as 0.
109
110** Transposing
111
112Org ▸ Transpose Table swaps rows and columns. Rules are dropped.
113
114** The field editor
115
116=C-c `= opens the field at the caret in an editor of its own, which is easier for long
117text. =C-c '= or =⌘Return= puts it back; =Escape= or =C-c C-k= leaves it unchanged.
118Line breaks become single spaces and lines that start with =#= are dropped, as
119=org-table-finish-edit-field= does.
120
121* Narrow columns
122
123A field that holds a width cookie =<N>=, optionally with an alignment letter
124(=<l10>=, =<c8>=, =<r12>=), marks the column for narrowing. Narrowed fields show their
125first /N/ display columns followed by =…=. The text itself is unchanged.
126
127| Command | Org command | Keys |
128|------------------------------------------+-----------------------------------+------------------------------------------|
129| Org ▸ Shrink or Expand Table Column | =org-table-toggle-column-width= | Emacs and Doom =C-c TAB= |
130| Org ▸ Shrink Table Columns with Widths | =org-table-shrink= | No default key |
131| Org ▸ Expand Table Columns | =org-table-expand= | No default key |
132
133=C-c TAB= in a field toggles that column. Outside a column, for example on the leading
134=|=, it asks for =Column ranges (e.g. 2-4 6-):=, where =6-= means column 6 to the end.
135A column without a width cookie shrinks to a bare =…= when toggled. Typing in a narrowed
136field widens its column again, as editing Org's overlays does. =#+STARTUP: shrink=
137narrows every column with a width cookie when the file opens.
138
139* Importing and exporting
140
141| Command | Org command |
142|----------------------------------------+--------------------|
143| Import Table from File… (command palette) | =org-table-import= |
144| Export Table to File… (command palette) | =org-table-export= |
145
146Open the command palette with =⇧⌘P= (=M-x= in the Emacs preset, =SPC := in Doom).
147
148Import asks for a CSV, TSV or plain text file, inserts its contents at the caret on a
149line of its own, and converts them to a table with the separator guessed as for a
150region (see /Creating a table/).
151
152Export writes the table at the caret. A file name ending in =.csv= gets CSV: fields
153separated by commas, with fields that contain a comma or a double quote quoted and
154inner quotes doubled. Any other name gets TSV. Rules are left out.
155
156Import and export are Mac only.
157
158* Formulas
159
160Orgstar evaluates Org's spreadsheet formulas, =org-table-recalculate= and
161=org-table-eval-formula=, natively: Calc expressions in a reimplementation of the part
162of Emacs Calc that tables use, and Lisp formulas in a small Emacs Lisp evaluator. What
163falls outside them is handed to Emacs on the Mac (see /When Emacs is needed/).
164
165Formulas live in a =#+TBLFM:= line right after the table, separated by =::=:
166
167#+BEGIN_SRC org
168| Item | Qty | Price | Total |
169|-------+-----+-------+-------|
170| Apple | 3 | 0.50 | 1.50 |
171| Pear | 12 | 0.75 | 9.00 |
172|-------+-----+-------+-------|
173| Sum | | | 10.50 |
174,#+TBLFM: $4=$2*$3;%.2f::@>$4=vsum(@I..@II);%.2f
175#+END_SRC
176
177Blank lines between the table and =#+TBLFM:= are allowed. If there are several
178=#+TBLFM:= lines, recalculating the table uses the first; =C-c C-c= on another applies
179that line instead (=org-table-calc-current-TBLFM=).
180
181** Kinds of formula
182
183| Left side | Kind | Applies to |
184|-------------------------+----------------------+------------------------------------------------------------------|
185| =$3= | Column formula | Every data row of column 3, except rows marked =!=, =^=, =_=, =$= or =/= in the first column. |
186| =$<=, =$>= | Column formula | The first or last column. |
187| =@2$3=, =@>$3= | Field formula | One field. Field formulas override column formulas. |
188| =@2$2..@4$3= | Range formula | Every field in the rectangle. |
189| =@4= | Row formula | Every field of data row 4. |
190| =$name= | Named field formula | The field named by a =^= or =_= row (see /Names, parameters and constants/). |
191
192A left side relative to the current row, such as =@-1$2=, is an error
193(=Unknown field=), and so is one relative to a rule, such as =@I$2=, as in Org. Two
194formulas for the same field are an error.
195
196** References
197
198Rows count data lines from 1; rules don't count. Columns count from 1.
199
200| Reference | Meaning |
201|----------------------+----------------------------------------------------------------------|
202| =$2= | Column 2 in the current row. |
203| =$-1=, =$+1= | The column before or after the current one. |
204| =$<=, =$>=, =$>>= | The first column, the last, the one before last. |
205| =@3= | Row 3 in the current column. |
206| =@-1=, =@+1= | The row above or below. |
207| =@<=, =@>= | The first or last data row. |
208| =@I=, =@II=, =@III= | The first, second, third rule; as a row, the line after it. |
209| =@-I= | The rule above the current row. |
210| =@I+2= | Two data rows after the first rule. |
211| =@2$3= | Row 2, column 3. |
212| =$0= | The current column. |
213| =@#=, =$#= | The current row's or column's number, as a value. |
214| =@2$1..@4$3= | A range: the fields of the rectangle, as a vector. |
215| =$1..$3= | Columns 1 to 3 of the current row. |
216| =@I..@II= | The current column from the first rule to the second. |
217
218In a Calc formula a single field becomes a number in parentheses, and a range becomes
219a vector such as =[1,2,3]=. Without the =E= flag, empty fields count as 0 on their own
220and are left out of ranges.
221
222Fields in a Calc formula must hold numbers, timestamps or =nan=, unless the =N= flag
223reads every field as a number. A reference to a field with other text needs Emacs,
224because Calc would treat the text as a symbol.
225
226** Names, parameters and constants
227
228The first column can mark special rows, as in Org's spreadsheet:
229
230| Mark | Row |
231|-------+---------------------------------------------------------------------------------------|
232| =!= | Column names: =$qty= in a formula means the column whose =!= row field is =qty=. |
233| =^= | Names for the fields in the row above, usable as =$name=. |
234| =_= | Names for the fields in the row below. |
235| =$= | Parameters: fields like ~rate=0.2~, usable as =$rate=. |
236| =#= | Marked for recalculation. |
237| =*= | Marked for recalculation. |
238| =/= | Not recalculated. |
239
240When any row's first field is one of =!=, =^=, =_=, =$=, =#= or =*=, column formulas
241in a whole-table recalculation apply only to the rows marked =#= or =*=, as
242=org-table-calculate-mark-regexp= decides in Org. So a table with a =!= names row and
243no =#= rows gets no column formulas applied; mark the rows to calculate. Field
244formulas apply either way. Rows marked =!=, =^=, =_=, =$= or =/= are never changed by
245column formulas.
246
247#+BEGIN_SRC org
248| ! | qty | price | total |
249|---+-----+-------+-------|
250| # | 2 | 3 | 6 |
251| # | 4 | 0.5 | 2 |
252,#+TBLFM: $4=$qty*$price
253#+END_SRC
254
255A =$name= that isn't a column name, parameter or named field is looked up as
256=org-table-get-constant= does:
257
258- in =#+CONSTANTS:= lines of the file or its setup file, written ~name=value~ and
259 separated by spaces (~#+CONSTANTS: c=299792458 g=9.81~);
260- =$PROP_xyz= reads the =xyz= property of the entry holding the table, with
261 inheritance.
262
263A name that isn't found becomes =#UNDEFINED_NAME=. A parameter named =%= in a =$= row,
264for example ~%=%.2f~, is put in front of the flags of every formula that has a =;=,
265so ~$3=$2/3;~ is formatted with =%.2f=.
266
267** Remote references
268
269=remote(NAME, REF)= reads a field or range from another table:
270
271#+BEGIN_SRC org
272,#+NAME: rates
273| item | rate |
274|------+------|
275| a | 2 |
276| b | 3 |
277
278| x | y | z |
279|---+---+---|
280| 4 | 8 | 5 |
281,#+TBLFM: $2=$1*remote(rates,@2$2)::$3=vsum(remote(rates,@2$2..@>$2))
282#+END_SRC
283
284=NAME= is found in this order:
285
2861. a table after =#+NAME: NAME= or =#+TBLNAME: NAME= in the same file;
2872. the first table in the entry whose =ID= property is =NAME=, in the same file;
2883. the first table in the entry with that =ID= in any indexed file in your sidebar
289 folders, read from the file on disk.
290
291=REF= may use spreadsheet-style references such as =B3= (column B, row 3), which
292become =@3$2=.
293
294** Calc expressions
295
296Calc formulas use Calc's number rules: integers are exact, and decimal numbers are
297rounded to 12 significant digits after every operation. Results are shown with up to
2988 significant digits unless a format flag says otherwise (=org-calc-default-modes=).
299
300Operators, from lowest to highest precedence (the lowest, ~||~, is logical or, giving
3011 or 0):
302
303| Operator | Meaning |
304|------------------------------------+-----------------------------------------------------------|
305| =&&= | Logical and. |
306| =!= | Logical not. |
307| ~==~, ~!=~, =<=, =>=, ~<=~, ~>=~ | Comparisons, giving 1 or 0. They can't be chained. |
308| =+=, =-= | Addition and subtraction. |
309| =/=, =%=, =\= | Division, modulo (sign of the divisor), integer division rounding down. |
310| =*= | Multiplication. |
311| unary =-= | Negation. |
312| =^= | Power. |
313
314Parentheses group, =[a, b, c]= writes a vector, =<2026-10-05 Mon>= writes a date, and
315=nan= is "not a number".
316
317Functions:
318
319| Function | Result |
320|--------------------------------------------+---------------------------------------------------------------|
321| =vsum=, =vprod= | Sum or product of a vector. |
322| =vcount= | Number of elements. |
323| =vmean=, =vmedian= | Mean, median. |
324| =vmax=, =vmin= | Largest, smallest element. |
325| =vvar=, =vsdev= | Sample variance, sample standard deviation. |
326| =vpvar=, =vpsdev= | Population variance, population standard deviation. |
327| =max(a, b, …)=, =min(a, b, …)= | Largest, smallest argument. |
328| =if(c, a, b)= | =a= if =c= is nonzero, else =b=. |
329| =abs= | Absolute value. |
330| =floor=, =ceil=, =trunc= | Round down, up, toward zero, to an integer. |
331| =round(x)=, =round(x, n)= | Round to an integer, or to /n/ decimal places. |
332| =mod(a, b)=, =idiv(a, b)= | As =%= and =\=. |
333| =fact= | Factorial of a non-negative integer. |
334| =sqrt=, =exp=, =ln=, =log10= | Square root, exponential, natural and base-10 logarithm. |
335| =sin=, =cos=, =tan= | Trigonometry, in degrees unless the =R= flag is set. |
336| =arcsin=, =arccos=, =arctan= | Inverse trigonometry, in degrees unless =R=. |
337
338Other Calc functions, variables such as =pi= or =e=, symbolic results, complex results
339and division by zero need Emacs.
340
341** Mode flags and formats
342
343After the formula, a =;= starts its flags, as in ~$3=$1/$2;%.2f~ or ~$4=$1*2;f2~:
344
345| Flag | Meaning |
346|-----------+-------------------------------------------------------------------------------------------|
347| =nN= | Float format with /N/ significant digits. |
348| =fN= | Fixed format with /N/ decimal places. |
349| =sN= | Scientific format with /N/ digits. |
350| =eN= | Engineering format with /N/ digits. |
351| =pN= | Calc precision. Only =p12=, the default, is evaluated natively; others need Emacs. |
352| =D=, =R= | Angles in degrees (the default) or radians. |
353| =F= | Prefer fractions: =1/3= stays =1:3=. |
354| =N= | Treat every field as a number; text counts as 0. |
355| =E= | Keep empty fields: in ranges they stay in, and count as =nan= in Calc. |
356| =L= | Literal: in Lisp formulas, insert fields as they are written. |
357| =T= | Durations: read =H:MM= and =H:MM:SS= fields as times, show the result as =HH:MM:SS=. |
358| =U= | As =T=, showing =HH:MM=. |
359| =t= | As =T=, showing decimal hours with two places, such as =1.50=. |
360
361The flags =S= (symbolic) and =u= need Emacs. Any other text after the flags is a
362=format= string applied to the result, such as =%.2f= or =%d=; =format= supports
363=%s=, =%S=, =%d=, =%o=, =%x=, =%X=, =%c=, =%e=, =%f= and =%g=.
364
365** Durations
366
367With =T=, =U= or =t=, fields like =1:30= or =10:00:30= are read as hours, minutes and
368seconds:
369
370#+BEGIN_SRC org
371| start | end | sum | diff | hours |
372|----------+---------+----------+-------+-------|
373| 1:30 | 0:45 | 02:15:00 | 00:45 | 3.00 |
374| 10:00:30 | 2:15:10 | 12:15:40 | 07:45 | 20.02 |
375,#+TBLFM: $3=$1+$2;T::$4=$1-$2;U::$5=$1*2;t
376#+END_SRC
377
378** Dates
379
380Timestamps in fields, active or inactive, take part in Calc arithmetic as dates. The
381difference of two dates is a number of days, with a fraction when the timestamps have
382times. A date plus a number is a date, written back as an inactive timestamp:
383
384#+BEGIN_SRC org
385| start | end | days | later |
386|------------------+------------------+------+------------------|
387| <2026-10-05 Mon> | <2026-10-12 Mon> | 7 | [2026-10-12 Mon] |
388,#+TBLFM: $3=$2-$1::$4=$1+7
389#+END_SRC
390
391** Lisp formulas
392
393A formula that starts with ='(= is Emacs Lisp. Each reference becomes a Lisp string,
394or a number with =N=, or the field's text inserted as is with =L=. A range becomes the
395values separated by spaces, so wrap it in a quoted list:
396
397#+BEGIN_SRC org
398| name | greeting |
399|-------+----------|
400| Ada | Ada! |
401| Grace | Grace! |
402,#+TBLFM: $2='(concat $1 "!")
403
404| n |
405|---|
406| 1 |
407| 2 |
408|---|
409| 3 |
410,#+TBLFM: @>$1='(apply '+ '(@I..@II));N
411#+END_SRC
412
413The evaluator supports:
414
415- special forms: =quote=, =function=, =lambda=, =progn=, =prog1=, =if=, =when=,
416 =unless=, =cond=, =and=, =or=, =let=, =let*=, =setq=, =push=, =pop=, =while=,
417 =dolist=, =dotimes=, =with-output-to-string=, =ignore-errors=, =condition-case=;
418- arithmetic: =+=, =-=, =*=, =/=, =%=, =mod=, =1+=, =1-=, =abs=, =max=, =min=, =float=,
419 =floor=, =ceiling=, =round=, =truncate=, ~=~, =<=, =>=, ~<=~, ~>=~, ~/=~, =zerop=;
420- predicates: =not=, =null=, =eq=, =eql=, =equal=, =numberp=, =integerp=, =floatp=,
421 =stringp=, =listp=, =consp=, =symbolp=;
422- lists: =car=, =cdr=, =cadr=, =cddr=, =cons=, =list=, =nth=, =nthcdr=, =elt=, =aref=,
423 =append=, =length=, =reverse=, =number-sequence=, =memq=, =member=, =memql=, =assoc=,
424 =assq=, =delq=, =delete=, =mapcar=, =mapc=, =mapconcat=, =funcall=, =apply=,
425 =identity=, =ignore=;
426- strings: =concat=, =format=, =format-message=, ~string=~, =string-equal=, =string<=,
427 =string-lessp=, =upcase=, =downcase=, =capitalize=, =substring=, =string-to-number=,
428 =number-to-string=, =int-to-string=, =string-prefix-p=, =string-suffix-p=,
429 =string-empty-p=, =string-trim=, =split-string=, =prin1-to-string=;
430- output and errors: =princ=, =prin1=, =print=, =terpri=, =message=, =error=,
431 =user-error=;
432- Org's lookup functions =org-lookup-first=, =org-lookup-last= and =org-lookup-all=.
433
434Any other function needs Emacs. An error inside a Lisp formula writes =#ERROR= in the
435field, as does a Calc error.
436
437* Entering formulas
438
439There are three ways to set a formula.
440
441*In the field.* Type ~=expr~ in a field and press =TAB= or =RET=: Orgstar stores
442~$N=expr~ as the column's formula and evaluates it, as
443=org-table-maybe-eval-formula= does. Type ~:=expr~ instead to store a field formula
444~@R$C=expr~.
445
446*With a prompt.* =org-table-eval-formula= asks for the formula (~Column formula $N=~
447or ~Field formula @R$C=~) with the stored one filled in, stores it and evaluates it in
448the current field. An empty answer keeps the stored formula and evaluates it again,
449unlike Emacs, where an empty answer removes it. To remove a formula, delete it in the
450formula editor below or from the =#+TBLFM:= line.
451
452| Command | Emacs | Mac | Doom |
453|-------------------------------+----------+-----------------------------+----------|
454| Org ▸ Set Column Formula | ~C-c =~ | Org ▸ Set Column Formula | ~C-c =~ |
455| Org ▸ Set Field Formula | none | Org ▸ Set Field Formula | none |
456
457Org's ~C-u C-c =~ for field formulas has no equivalent key, because Orgstar has no
458prefix argument; use the menu item or type ~:=~ in the field.
459
460*In the formula editor.* =C-c '= in a table or on its =#+TBLFM:= line
461(=org-table-edit-formulas=) opens the formulas in an editor of their own, one per line,
462grouped under =# Column Formulas=, =# Field and Range Formulas= and
463=# Named Field Formulas=. A formula can continue on indented lines. =C-c '= or
464=⌘Return= installs the formulas; =Escape= or =C-c C-k= leaves them unchanged.
465Installing doesn't recalculate; do that next with =C-c C-c= on the =#+TBLFM:= line, or
466Org ▸ Recalculate Table in the Mac preset.
467
468The formulas are stored sorted the way =org-table-formula-less-p= sorts them.
469
470* Recalculating
471
472| Command | Org command | Emacs | Mac | Doom |
473|----------------------------------+-----------------------------------+-------------------------------+-----------------------------+-------------------------------------|
474| Recalculate Table | =org-table-recalculate= with =C-u= | =C-c C-c= on =#+TBLFM:= | Org ▸ Recalculate Table | =SPC m b r=, =C-c C-c= on =#+TBLFM:= |
475| Recalculate Table Row | =org-table-recalculate= | =C-c *= | Org ▸ Recalculate Table Row | =C-c *= |
476
477In Doom's normal state, =RET= in a table recalculates it when it has a =#+TBLFM:=
478line and aligns it otherwise; on a =#+TBLFM:= line it recalculates.
479
480When the table has a rule below its first data row, recalculating the whole table
481leaves the rows above that rule, the header, alone. With marked rows, the marks decide
482instead (see /Names, parameters and constants/). Each
483command evaluates the column formulas row by row, then the field formulas, then aligns
484the table. Formulas are evaluated once; Org's iterate-until-stable recalculation
485(=C-u C-u C-c *=) isn't available.
486
487Tables are not recalculated automatically. Rows marked =#= are not recalculated when
488you press =TAB= or =RET= in them, as =org-table-maybe-recalculate-line= would do in
489Emacs; recalculate with one of the commands above.
490
491* When Emacs is needed
492
493When a formula uses something the native evaluator doesn't have, the command reports
494what it was and the Mac recalculates the table in Emacs instead. This happens for:
495
496- references to fields holding text in a Calc formula, and symbolic results;
497- Calc functions and variables not listed above, precision other than =p12=, and the
498 =S= and =u= flags;
499- division by zero, complex results, vector results, and numbers too large for
500 64-bit integers;
501- Lisp functions not listed above.
502
503The echo area shows =Recalculating in Emacs (reason)…=, then =Recalculated in Emacs=.
504Orgstar runs =emacs -Q --batch= on a copy of the file, so your Emacs init file,
505packages and customizations are not loaded, then replaces the table with Emacs's
506result. It looks for Emacs at the path in the =ORGSTAR_EMACS= environment variable,
507then =/opt/homebrew/bin/emacs=, =/usr/local/bin/emacs=,
508=/Applications/Emacs.app/Contents/MacOS/Emacs=, =/run/current-system/sw/bin/emacs= and
509=/usr/bin/emacs=. If none is found, the echo area says Emacs isn't installed and the
510table is unchanged. The run stops after 60 seconds. If you edit the table while Emacs
511is working, its result is discarded.
512
513If the table's formulas contain Lisp, Orgstar asks first:
514=This table's formulas run Lisp. Run them? (yes, no, always)=. =always= trusts this
515table's text in this file, so the question isn't asked again until the text changes.
516
517Entering a formula that needs Emacs with ~C-c =~, Set Field Formula or ~=~ in a field
518is not handed to Emacs. The echo area shows =The formula was stored; recalculating it
519needs Emacs= and the reason, but the table and its =#+TBLFM:= line stay unchanged.
520Add such a formula in the formula editor or by editing the =#+TBLFM:= line, then
521recalculate the table, which runs it in Emacs.
522
523For how Orgstar and Emacs share files, see
524[[file:15-alongside-emacs.org][Using Orgstar alongside Emacs]].
525
526* table.el tables
527
528Tables drawn with =+= corners and =-= and =|= borders, as the =table.el= package makes
529them, are recognized and kept as written:
530
531#+BEGIN_SRC org
532+-------+-------+
533| Name | Value |
534+-------+-------+
535| a | 1 |
536+-------+-------+
537#+END_SRC
538
539Orgstar doesn't edit them as tables: =TAB=, alignment and formulas don't apply. HTML
540export renders them as tables, with cells that span rows and columns, and Markdown
541export writes them as a code block. See [[file:12-export.org][Export]].
542
543* Plotting
544
545=#+PLOT:= lines are recognized and completed as keywords, but Orgstar doesn't draw
546plots (=org-plot/gnuplot= is not available).
547
548* On iOS
549
550The iOS app evaluates formulas natively with the same engine. Tables that need Emacs
551are not recalculated there; the app reports =This table needs Emacs, which runs on the
552Mac= with the reason. Table import and export are Mac only. See
553[[file:14-ios.org][iOS]].