WG4209-WorkingWithTables
WG4209-WorkingWithTables
Chapter 9
Working with Tables
Copyright
This document is Copyright © 2011–2014 by the LibreOffice Documentation Team. Contributors
are listed below. You may distribute it and/or modify it under the terms of either the GNU General
Public License (http://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative Commons
Attribution License (http://creativecommons.org/licenses/by/4.0/), version 4.0 or later.
All trademarks within this guide belong to their legitimate owners.
Contributors
John A Smith Jean Hollis Weber
Ron Faile Jr. Barbara Duprey
Feedback
Please direct any comments or suggestions about this document to the Documentation Team’s
mailing list: [email protected]
Note: Everything you send to a mailing list, including your email address and any other personal
information that is written in the message, is publicly archived and cannot be deleted.
Acknowledgments
This chapter is adapted and updated from Chapter 9 of the OpenOffice.org 3.3 Writer Guide. The
contributors to that chapter are:
Peter Hillier-Brook John Kane Stefan A. Keel
Iain Roberts Gary Schnabl Janet Swisher
Barbara M. Tobias Jean Hollis Weber Bob Wickham
Michele Zarri Magnus Adielsson
Creating a table
Before you insert a table into a document, it helps to have an idea of the visual result you want to
obtain as well as an estimate of the number of rows and columns required. Every parameter can
be changed at a later stage; however, thinking ahead can save a large amount of time as changes
to fully formatted tables often require a significant effort.
• On the Standard toolbar, click the left side of the split Table button
To directly insert a table with the default properties, click on the arrow button next to
the Table icon on the Standard toolbar. A graphic appears where you can choose the
Tip size of the table (up to fifteen rows and up to ten columns). To create the table, click
on the cell that you want to be on the last row of the last column. Holding down the
mouse button over the Table icon will also display the graphic.
In the Insert Table dialog, you can specify the properties for the new table.
General settings: In the Name box, you can enter a different name from the LibreOffice-generated
default for the table. This might come in handy when using the Navigator to jump quickly to a table.
In the Columns and Rows boxes, specify the number of columns and rows for the new table. You
can change the size of the table later, if necessary.
Creating a table 5
Figure 1: Inserting a new table using the Insert Table dialog
Under Options, set up the initial table characteristics. Selecting the options in this section of the
dialog produces the following results:
• Heading — Selecting this enables a heading to be used in the table and enables further
options for the heading. Defines the number of rows in the table to be used as headings.
The default Table Heading paragraph style is applied to the heading rows. You can edit the
Table Heading paragraph style in the Styles and Formatting window to change these
default settings (centered, bold, and italic text). When splitting a table into two tables, the
Heading rows can be copied into the second table.
Repeat Heading Rows on new pages — Selection enables the heading rows of the table
to be repeated at the top of subsequent pages if the table spans more than one page.
Heading Rows — Specifies the number of rows to be used for the heading. Default is 1.
• Don’t split table over pages — Prevents the table from spanning more than one page.
This can be useful if the table starts near the end of a page, and would look better if it were
completely located on the following page. If the table becomes longer than would fit on one
page, you will need to either deselect this option or manually split the table.
• Border — Surrounds each cell of the table with a border. This border can be modified or
deleted later.
The AutoFormat button opens a dialog from which you can select one of the many predefined
table layouts. See “Automatic formatting of tables” on page 23 for more information. Click OK after
selecting your table layout.
After making your choices, click Insert. Writer creates a table as wide as the text area (from the left
page margin to the right page margin), with all columns the same width and all rows the same
height. You can adjust the columns and rows later to suit your needs.
Creating a table 6
Figure 2: Nested table example
This function can be disabled or enabled in Tools > AutoCorrect Options. On the
Note Options tab, deselect or select Create table.
Creating a table 7
The Separate text at part of the dialog has four options for the separator for the columns of text.
Select Other to choose the default comma (useful if you are importing a CSV file) or type any
character in the box. The other options in this dialog are the same as those in the dialog used to
insert a table shown in Figure 1.
Click OK when all your choices have been made.
Example
In this example we will convert the following text into a table.
Row 1 Column 1; Row 1 Column 2; Row 1 Column 3
Row 2 Column 1; Row 2 Column 2; Row 2 Column 3
Choose Table > Convert > Text to Table
In this case, the separator between elements is a semicolon. By selecting the text and applying the
conversion, we obtain the following result.
Row 1 Column 1 Row 1 Column 2 Row 1 Column 3
Row 2 Column 1 Row 2 Column 2 Row 2 Column 3
Note that, unlike the creation of a table by other mechanisms, the conversion from text to table
preserves the paragraph style and character style applied to the original text.
You can also use the Convert menu to perform the opposite operation; that is, to transform a table
into plain text. This may be useful when you want to export the table contents into a different
program.
To transform a table into text, place the cursor anywhere in the table, choose Table > Convert >
Table to Text in the Menu bar, pick the preferred row separator, and click OK to finish.
Default parameters
If you create a table using the Insert Table dialog or the Table button on the Standard toolbar, the
following defaults are set:
• The cells use the Table Contents paragraph style, which, in the default template, is identical
to the Default Style paragraph style.
• The default table occupies all the space from margin to margin (text area).
• The default table has thin black borders around each cell (grid).
Additionally, if you activate the Heading option, the cells in the heading row (or rows) use the
Table Heading paragraph style. In the default template, the text is centered and set with a bold
font.
Clicking on the Insert Row icon on the Table toolbar inserts one row below the
selected one. Clicking on the Insert Column icon on the Table toolbar inserts a
Note column after (to the right of) the selected one.
Regardless of how they are inserted, new rows or columns have the same formatting
as the row or column where the cursor was when the insert command was issued.
You can also quickly insert a row or a column using the keyboard:
1) Place the cursor in the row or column next to the row or column you want to insert.
2) Press Alt+Insert to activate keyboard handling.
3) Use the arrow keys as desired to add a row or column:
Left to insert a new column to the left of the cell where the cursor is located.
Right to insert a new column to the right of the cell where the cursor is.
Down to insert a new row below the cell where the cursor is.
Up to insert a new row above the cell where the cursor is.
The above keyboard technique can also be used to delete rows or columns by replacing the
Alt+Insert keystroke combination in Step 2 with Alt+Delete.
When the selected cells have different styles of border the User-defined area shows
Note the border as a gray line. You can click on the gray line to choose a new border style
(first click), leave the border as it is (second click) or delete the border (third click).
• Line specifies what the border looks like: the style, width, and color. There are a number of
different styles and colors to choose from. Style, Width, and Color selections apply to those
borders highlighted by a pair of black arrows in the User-defined map on the left-hand side
of the dialog.
To reset everything if you are having problems with borders, right-click in the table
and choose Table or choose Table > Table Properties from the Menu bar. On the
Tip Borders tab, select the Set No Borders icon under Line arrangement: Default (the
box on the left).
Figure 8 shows an example of a table set with a background image, and the first row background
colored. As you can see, the row background covers the table background.
Note Turning boundaries off does not hide any borders that the table may have.
You can also turn table boundaries on and off through Tools > Options >
Tip LibreOffice > Appearance. On that page, you can display or hide boundaries
around text, pages headers and footers, figures, and other parts of a document.
• Select the vertical alignment of the text in the table or the selected cells; the choices are to
align with the top of the cell, the center of the cell, or the bottom of the cell. This alignment
is in addition to the Left-Right alignment options available on the Table page of the Table
Format dialog.
A table heading row cannot span two pages, but any other row can. A one-row table
(often used for page layout purposes), if set up with the default of including a
Note heading, will not break across pages. The cure is to make sure the table is defined
without a heading row.
Vertical alignment
By default, text entered into a table is aligned to the top-left of the cell. You can change the default
for the entire table, as described above, or for individually selected cells.
To vertically align the text in specific cells:
• Place the cursor in the cell you wish to change, or click and drag to select multiple cells.
• Right-click in the selected area and choose Cell > Center, Top, or Bottom from the context
menu to vertically align the text as desired.
Number formats
The number format can be set for a whole table or group of cells. For example, cells can be set to
display in a particular currency, to four decimal places, or in a particular date format.
The Number recognition option can be enabled under Tools > Options > LibreOffice Writer >
Table within the Input in Tables section.
You will notice that LibreOffice displays the formatting code for the category and
format selected in Format Code section at the bottom of the dialog. For example, if
Tip you select a date format such as 31 Dec 1999 the corresponding code is D MMM
YYYY. Advanced users can easily customize this formatting code as well as create
new user-defined codes.
Alignment specifies that numbers are always bottom right aligned in the cell. If this field is not
selected numbers are always top left aligned in the cell.
Direct formatting is not influenced by the Alignment field. If you center align the cell
Note content directly, it remains centered irrespective of whether text or numbers are
involved.
To enter a Tab character as part of the text of the cell, press the Ctrl and Tab keys at
Tip the same time.
To move to the beginning of the table, press Ctrl+Home. If the active cell is empty, the move is to
the beginning of the table. If the cell has content, the first press goes to the beginning of the cell
and the next press goes to the beginning of the table (pressing again takes you to the beginning of
the document).
To move to the end of the table, press Ctrl+End. If the active cell is empty, the move is to the end
of the table. If the cell has content, the first press goes to the end of the cell and the next press
goes to the end of the table (pressing again takes you to the end of the document).
You have to select all cells that might be affected by the sorting. For example, if you
Note select only the cells of one column, the sort affects that column only, while the others
remain unchanged. In such a case, you risk mixing the data of the rows.
Basic spreadsheet functions in tables are much the same as in LibreOffice Calc. The
main difference is that cell references are formatted differently. Cell A2 (first column,
Tip second row) is referred to in Calc as A2 (or $A$2 for an absolute reference). In Writer
tables, it is referred to as <A2>.
For example, suppose you had two numbers in cells <B1> and <C2> and wanted to display the
sum of the two in cell <A1>, as shown in Figure 11.
Do the following:
1) Click in cell <A1> and press the = key, or choose Table > Formula from the Menu bar, or
press F2. The Formula bar appears automatically, near the top of the screen. In the
leftmost side of the bar, you can see the coordinates of the selected cell.
2) Click in cell <B1>. The identifiers of this cell are automatically displayed in the Formula bar
and inserted into cell <A1>.
To display a cell's formula and make it available for editing, choose Table > Formula
Tip from the Menu bar, or press F2.
To display the list of the mathematical functions that you can use in a table:
1) Display the Formula toolbar by pressing F2 or by selecting a blank cell and
Tip pressing the = key.
2) Click the Formula f(x) icon.
Caution Unlike in Calc, when inserting or deleting rows or columns of the table, formulas are
not updated automatically. If you plan to use complex formulas you should consider
embedding a Calc spreadsheet in your Writer document.
This protection is not intended for secure protection. It is just a switch to protect the
Note cells against accidental changes.
Adding a caption
You can easily add a caption to any table. Writer will keep track of all your captioned tables,
automatically number them, and update any links to them.
To add a caption to a table:
1) Place the cursor in the table.
Once the category, numbering style, and separator are established in the Caption
dialog, you can edit them in the document if you choose. However, doing so may
Note damage the automatic numbering and reference links. If you need to establish the
numbering and reference link for the caption, you can choose to leave your caption
blank in the Caption dialog and add it later.
Writer supplies five category labels for captions: <None>, Drawing, Table, Illustration, and Text.
You can also create your own category labels, formatting, and separators. For example, you might
want your tables to be labeled as Fantasia, formatted with roman numerals, and using a period
(‘.’) as a separator, as follows:
Fantasia I. Interesting data
Fantasia II. More interesting data
Fantasia III. Yet more interesting data
To accomplish this:
1) Open the Caption dialog following the instructions above.
2) In the Category field, select the text and type the word Fantasia.
3) In the Numbering drop-down list, select the Roman (I II III) option.
4) In the Separator field, select the text and type a period (.) followed by a space.
Writer will use exactly what you type into the Category and Separator fields, so be
Note sure to include any additional spaces or punctuation you want to see in your caption.
Additional options for numbering captions by chapter are available under the Options button in the
Captions dialog. Some of these settings which refer to the outline level will only have an effect if
you are using outline level paragraph styles on the chapter headings within your document. See
Chapter 7. Working With Styles, for information.
By adding chapter numbers to your captions, LibreOffice will restart the caption numbering for each
chapter it encounters. For example, if the last figure caption you create in chapter 1 is Figure 1.15,
and the next figure caption you create is in chapter 2, the numbering will start over at Figure 2.1.
Options available to chapter numbering for captions include the following:
• Use Level to specify the outline levels that triggers a restart of the numbering as well as
how many levels of outline numbering are shown before the table number. An example may
be useful. Suppose your document uses Heading 1 style for chapters and Heading 2 style
for sub-headings, and that this is how you set up your outline numbering. If you want all the
tables in a chapter (that is, between two Heading 1 paragraphs) to be numbered
sequentially independently of the sub-heading they are under, select 1 as Level. If instead
you want to restart the numbering at each sub-heading select level 2.
• Use the Separator field to establish the separator between the chapter number and figure
number.
• Use Character style to set a character style for the caption. This is useful if the separator
of your choice is not a symbol included in the default font type of your document or if you
want the caption to have a special color, size and so on.
Cross-referencing a table
You can insert a cross-reference to a captioned table. Clicking on the cross-reference takes the
reader directly to the table.
1) Position the cursor where you want the cross reference.
2) Choose Insert > Cross-reference from the Menu bar.
3) Set the Type to Table (or whatever you chose as the category). A list of captioned tables
will be shown in the Selection panel; select the one you want to reference.
4) In the Format pane, choose how the cross reference will appear.
Page creates a reference to the page number that the caption appears on.
Chapter creates a reference to the chapter number in which the caption appears. This will
only produce an empty space unless you have set up your chapter headings with outline
level paragraph styles.
Reference inserts the entire caption’s category, number and caption text as a reference.
Above/Below inserts “above” or “below” depending on whether the table appears above or
below the cross-reference.
As Page Style creates a reference to the page number that the caption appears on, using
the page style format.
Category and Number creates a cross-reference with only the caption’s category and
number; for example, Table 1 for the first table.
Caption Text creates the reference using the caption text, leaving off the category and
number.
Numbering inserts only the number of the caption.
5) Click Insert to add the cross-reference and click Close to exit the dialog.
You cannot rename or delete the Default format. Figure 12 shows that with Default
Note selected, the Rename and Delete buttons are not available.
This technique does not include table and column widths in the table format. To insert
Tip a table with predefined full formatting, save it as AutoText. See “Using AutoText” in
Chapter 3, Working with Text, for instructions.
If cells in one table include formulas using data from the other table, those cells will
Note contain an error message: **Expression is faulty**.
To see clearly where the paragraphs are and to delete them easily, choose View >
Tip Nonprinting Characters (Ctrl+F10) or click the ¶ button in the Standard toolbar.
Deleting a table
To delete a table:
1) Click anywhere in the table.
2) Choose Table > Delete > Table from the Menu bar.
The second method also merges the paragraph after the table with the paragraph
Note before the table, which may not be what you want.
Copying a table
To copy a table from one part of the document and paste it into another part:
1) Click anywhere in the table.
2) From the Menu bar choose Table > Select > Table.
3) Press Ctrl+C or click the Copy icon on the Standard toolbar.
4) Move the cursor to the target position and click on it to fix the insertion point.
5) Press Ctrl+V or click the Paste icon in the Standard toolbar.
Moving a table
To move a table from one part of a document to another part:
1) Click anywhere in the table.
2) From the Menu bar, choose Table > Select > Table.
3) Press Ctrl+X or click the Cut icon in the Standard toolbar. (This step removes the contents
of the cells but leaves the empty cells, which must be removed in step 6.)
4) Move the cursor to the target position and click on it to fix the insertion point.
5) Press Ctrl+V or click the Paste icon in the Standard toolbar. (This pastes the cells and their
contents and formatting.)
6) Return to the original table, click somewhere in it and then choose Table > Delete > Table
from the Menu bar.
Captions are considered as paragraphs separate from the table itself. If there is a
Note caption below a table, for example, just position the cursor at the end of the caption
and press Enter.
Name Description
Line Style Opens the Border Style window where you can modify the border line style.
This can be torn off and floated separately.
Line Color (of A split button. You can apply the color with a single click on the icon, or by
the border) selecting the triangle button, open the Border Color window where you can
modify the border color. This can be torn off and floated separately.
Borders, add Opens the Borders window where you can select which sides of the table or of
lines; SHIFT to the selected cells will have a border. This can be torn off and floated separately.
remove
Background A split button. You can apply the color with a single click on the icon, or by
Color selecting the triangle button, open the Background color window where you can
select the background color of the table or of the selected cells. This can be
torn off and floated separately.