1 #+OPTIONS: H:3 num:nil toc:t \n:nil ::t |:t ^:t -:t f:t *:t tex:t d:(HIDE) tags:not-in-toc
2 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
3 #+SEQ_TODO: TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
4 #+TAGS: Write(w) Update(u) Fix(f) Check(c)
5 #+TITLE: Org tutorial for tables
7 #+EMAIL: bzg AT altern DOT org
10 #+CATEGORY: org-tutorial
12 [[file:../index.org][{Back to Worg's index}]]
14 This tutorial briefly describes the use of tables with Org. You can
15 freely improve this tutorial by editing [[file:../index.org][Worg]].
21 The easiest way to create a table is to directly type the "|" character
22 at the beginning of a line, or after any amount of white space. This
23 will put you in the first field of an atomic table.
25 : | This is the content of the first cell
27 Once you've finished editing this cell, you can jump to the next one by
28 pressing =TAB=. Since the row you just started only contains one cell,
29 the next cell is really the first cell of the next row.
31 : | This is the content of the first cell |
32 : | < Here I am after pressing TAB |
34 ** By creating the structure and filling it
36 You can also create a table from scratch with =C-c |=. You will be
37 asked for the structure of the table, the default being 5x2 (see
38 =org-table-default-size=), five columns and two rows:
41 : |---+---+---+---+---|
44 Then you can jump from one field to another with the =TAB= key (jump to
45 the /next/ cell) or =S-<TAB>= (jump to the /previous/ cell). =RET= will
46 jump to the to the next cell in the same colum, and create a new column
47 if there is no such cell (or if the next row is beyond a separator
50 ** By converting a region into a table
52 Org provides useful ways of converting a region into a table. For this,
53 select a region and press =C-c |=. For example, press =C-c |= on this:
55 : some, comma, separated, values
57 will automagically produce this:
59 : | some | comma | separated | values |
61 Usually, this command should be smart enough to guess what is the field
62 separator for the region. If each line of the active region contains a
63 =TAB= or a comma, it will assume this is the separator.
65 - If you want to force the comma as a field separator, press =C-u C-c |=.
67 - If you want to force TAB as a field separator, press =C-u C-u C-c |=.
69 - If you want to force a specific number of spaces -- say 3 -- use =C-u 3 C-c |=.
71 * Editing the structure of a table
73 Editing table with Org is pure magic.
75 ** Moving rows/columns
77 Let's say for example that you have this basic table:
83 With the cursor in the A field, pressing =M-<right>= will move the A
90 With the cursor in the first row, pressing =M-<down>= will move the
97 ** Inserting rows/columns
99 Prefixed with the Shift key, these command will /insert/ a new column or
100 a new row, instead of moving it. For example, with the cursor initially
101 in the =B= cell, =S-M-<right>= will insert a new column between =A= and
108 ... leaving the cursor in the newly created column.
110 And =S-M-<down>= when cursor is in the first row will insert a new row
111 at the beginning of the table:
118 * Narrowing the visible part of a column
120 Sometimes cells can get really wide. If you want to restrict the width
121 visible width of a cell, you need to add a new row to your table.
124 : | A very wide cell | Another very very wide cell |
126 Pressing =C-c C-c= on this table will update the display so that the
127 first and second columns are respectively narrowed to 10 and 15
131 : | A very=> | Another very => |
133 When columns are narrowed, it might be useful to temporarily see the
134 content of a cell with =C-u <TAB>= (or =C-u C-c `=) or to edit the
135 content in a separate window with =C-c `=.
137 * Preparing tables for export
144 will be exported like this:
149 ** Adding a table header
157 will be exported like this:
163 The horizontal line separating the two rows tells the exporter to
164 consider the first line is the table header.
168 You can group columns like this:
170 : | | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
171 : |---+----+-----+-----+-----+---------+------------|
172 : | / | <> | < | | > | < | > |
173 : | # | 1 | 1 | 1 | 1 | 1 | 1 |
174 : | # | 2 | 4 | 8 | 16 | 1.4142 | 1.1892 |
175 : | # | 3 | 9 | 27 | 81 | 1.7321 | 1.3161 |
176 : |---+----+-----+-----+-----+---------+------------|
180 | | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt(N) |
181 |---+----+-----+-----+-----+---------+---------|
182 | / | <> | < | | > | < | > |
183 | # | 1 | 1 | 1 | 1 | 1 | 1 |
184 | # | 2 | 4 | 8 | 16 | 1.4142 | 1.1892 |
185 | # | 3 | 9 | 27 | 81 | 1.7321 | 1.3161 |
186 |---+----+-----+-----+-----+---------+---------|