1 #+TITLE: Org tutorial for tables
3 #+EMAIL: bzg AT altern DOT org
4 #+OPTIONS: H:3 num:nil toc:t \n:nil ::t |:t ^:t -:t f:t *:t tex:t d:(HIDE) tags:not-in-toc
5 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
6 #+SEQ_TODO: TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
7 #+TAGS: Write(w) Update(u) Fix(f) Check(c)
10 #+CATEGORY: org-tutorial
12 # This file is released by its authors and contributors under the GNU
13 # Free Documentation license v1.3 or later, code examples are released
14 # under the GNU General Public License v3 or later.
16 [[file:../index.org][{Back to Worg's index}]]
18 This tutorial briefly describes the use of tables with Org. You can
19 freely improve this tutorial by editing [[file:../index.org][Worg]].
25 The easiest way to create a table is to directly type the "|" character
26 at the beginning of a line, or after any amount of white space. This
27 will put you in the first field of an atomic table.
29 : | This is the content of the first cell
31 Once you've finished editing this cell, you can jump to the next one by
32 pressing =TAB=. Since the row you just started only contains one cell,
33 the next cell is really the first cell of the next row.
35 : | This is the content of the first cell |
36 : | < Here I am after pressing TAB |
38 ** By creating the structure and filling it
40 You can also create a table from scratch with =C-c |=. You will be
41 asked for the structure of the table, the default being 5x2 (see
42 =org-table-default-size=), five columns and two rows:
45 : |---+---+---+---+---|
48 Then you can jump from one field to another with the =TAB= key (jump to
49 the /next/ cell) or =S-<TAB>= (jump to the /previous/ cell). =RET= will
50 jump to the to the next cell in the same colum, and create a new column
51 if there is no such cell (or if the next row is beyond a separator
54 ** By converting a region into a table
56 Org provides useful ways of converting a region into a table. For this,
57 select a region and press =C-c |=. For example, press =C-c |= on this:
59 : some, comma, separated, values
61 will automagically produce this:
63 : | some | comma | separated | values |
65 Usually, this command should be smart enough to guess what is the field
66 separator for the region. If each line of the active region contains a
67 =TAB= or a comma, it will assume this is the separator.
69 - If you want to force the comma as a field separator, press =C-u C-c |=.
71 - If you want to force TAB as a field separator, press =C-u C-u C-c |=.
73 - If you want to force a specific number of spaces -- say 3 -- use =C-u 3 C-c |=.
75 * Editing the structure of a table
77 Editing table with Org is pure magic.
79 ** Moving rows/columns
81 Let's say for example that you have this basic table:
87 With the cursor in the A field, pressing =M-<right>= will move the A
94 With the cursor in the first row, pressing =M-<down>= will move the
101 ** Inserting rows/columns
103 Prefixed with the Shift key, these command will /insert/ a new column or
104 a new row, instead of moving it. For example, with the cursor initially
105 in the =B= cell, =S-M-<right>= will insert a new column between =A= and
112 ... leaving the cursor in the newly created column.
114 And =S-M-<down>= when cursor is in the first row will insert a new row
115 at the beginning of the table:
122 * Narrowing the visible part of a column
124 Sometimes cells can get really wide. If you want to restrict the width
125 visible width of a cell, you need to add a new row to your table.
128 : | A very wide cell | Another very very wide cell |
130 Pressing =C-c C-c= on this table will update the display so that the
131 first and second columns are respectively narrowed to 10 and 15
135 : | A very=> | Another very => |
137 When columns are narrowed, it might be useful to temporarily see the
138 content of a cell with =C-u <TAB>= (or =C-u C-c `=) or to edit the
139 content in a separate window with =C-c `=.
141 * Preparing tables for export
148 will be exported like this:
153 ** Adding a table header
161 will be exported like this:
167 The horizontal line separating the two rows tells the exporter to
168 consider the first line is the table header.
172 You can group columns like this:
174 : | | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
175 : |---+----+-----+-----+-----+---------+------------|
176 : | / | <> | < | | > | < | > |
177 : | # | 1 | 1 | 1 | 1 | 1 | 1 |
178 : | # | 2 | 4 | 8 | 16 | 1.4142 | 1.1892 |
179 : | # | 3 | 9 | 27 | 81 | 1.7321 | 1.3161 |
180 : |---+----+-----+-----+-----+---------+------------|
184 | | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt(N) |
185 |---+----+----+----+----+---------+---------|
186 | / | <> | < | | > | < | > |
187 | # | 1 | 1 | 1 | 1 | 1 | 1 |
188 | # | 2 | 4 | 8 | 16 | 1.4142 | 1.1892 |
189 | # | 3 | 9 | 27 | 81 | 1.7321 | 1.3161 |
190 |---+----+----+----+----+---------+---------|