next up previous contents index
Next: 7.2 The Generic Table Up: 7 Table Editing Previous: 7 Table Editing

Subsections

7.1 Editing Tables

When you start up a table editor, or issue the New command in a table editor, a new table is created having N x M empty cells (by default, N = 7 and M = 7). New rows and columns of empty cells can be created with the Add Row and Add Column commands. Selected rows and columns can be deleted with the Delete Rows and Delete Columns commands.

If you start up a table editor from the tcm start-up tool, before the main window of the editor is displayed, a text field list dialog is presented. This dialog has four fields: number of rows, number of columns, minimal row height and minimal column width. In these fields the default values are already filled in. You can fill in different values if you want.

By default, the table is positioned on the drawing area having its top-left corner a little right below the top-left corner of the drawing area. You can reposition the entire table by means of the four arrow buttons in the bottom-left corner of the main window. Like the diagram editors, the page boundaries are displayed. If you print the table or save it as plain PostScript, the table is positioned on the printed page exactly as it is positioned on the drawing area (what you see is what you print).

Each row and each column has a sequence number label. These labels are used to select an entire row or column or to move an entire row or column to a new position. These labels cannot be edited or printed. In the View menu there is an option to hide the labels. See figure 7.1 for a snap-shot of the table editor.


  
Figure 7.1: Snap-shot of a table being edited.
\begin{figure}
\begin{center}

\includegraphics [width=5.5in]{p/table_snapshot.ps}\end{center}\end{figure}

7.1.1 Definitions

We first give some definitions of the terms that are used in the rest of this chapter.

The document that you edit is called a table.  A table contains a number of cells  which are invisible rectangles. The table has a number of rows  and a number of columns . Each cell is part of one row and of one column. All rows in the table have the same number of cells and all columns of a table have the same number of cells. All cells in a row have the same height and all cells in a column have the same width. All cells in a row have the same center y-coordinate and all cells in a column have the same center x-coordinate. All rows and columns are packed, i.e. rows and columns cannot overlap and the distance between two rows or two columns is zero when there are no other rows between them.

Each row has a row label  which is an uneditable label containing the row sequence number (rows are ordered according to their y-coordinates), positioned near the left edge of the first cell of the row. Each column has a column label  which is an uneditable label containing the column sequence number (columns are ordered according to their x-coordinates), positioned above the first cell of the column.

Each border line between two cells is called a line piece . A line piece has a certain line style: solid, dashed, fat, invisible and so on. So, line pieces are the items of a table that can be made visible and make the table appear like a grid. Line pieces are either horizontal or vertical. Horizontal line pieces are part of the same column as the neighboring cells and vertical line pieces are part of the same row as the neighboring cells.

A cell itself is invisible, only its four border lines are possibly visible. A cell can contain some piece of cell text . Cell text is an editable multi-line text string. The cell text is positioned in the cell according to the column alignment, row alignment, text margin width and text margin height (which are all explained in the next sections). A cell can be selected. A selected cell has a rectangle drawn inside its four border lines.

7.1.2 Selection Commands

A selected cell is highlighted by an extra black rectangle inside the cell boundaries (see figure 7.1). The distance between the selection rectangle and the line pieces is a pixel or two. Here is a list of all the table editor selection commands:

7.1.3 Editing Text

  

Text editing works the same for all document editors. See section 2.5.1 for the different edit commands and the two different edit modes, in-line editing and out-line editing.

When a cell text has been edited and the autoresizing  toggle is on, the cell sizes automatically adapt to the new text size. I.e. if the text is too high to fit into the cell, the cell, and consequently the entire row is made higher, and if the text is too wide to fit into the cell, the cell, and consequently the entire column, is made wider. If the cell text becomes less wide or high, and the autoresize toggle is on, then the row will be made less high, respectively, the column will be made less wide, down to the size that the other texts in that row or column still fit and that the row height or column width do not get below the minimal row height    or column width of the table. The minimal row height and minimal column width is the cell height and cell width when the table is initialized. Cells can not be made smaller than the minimal row height and column width. The minimal row height and column width can be modified in Table menu.

7.1.4 Copying and Moving Text

To move a single cell text  from one cell to another, drag and drop it with button-1 from an unselected source cell to a destination cell (just like dragging an edge label in a diagram editor). The old text of the destination cell will be overwritten. If the text is dropped somewhere outside a cell or you click button-2 while dragging, the command will be aborted.

Copying a single cell text  from one cell to another works in the same manner as moving a text. The difference is that the source cell should be selected.

When the autoresizing toggle is on, cell sizes automatically adapt to the new situation when text is copied or moved.

7.1.5 Cutting and Pasting Text

The above method for moving or copying cell texts works only for one cell at the time. To perform this on a whole group of cell texts there are the Cut, Copy and Paste commands. To cut cell texts to the cell text buffer, use the  Cut Texts <Ctrl+X> command in the Edit menu. It clears the texts of the selected cells and copies them into the buffer. Cut can also be a helpful command when you want to clear a part of the table. You can copy cell texts to the buffer via the Copy Texts <Ctrl+C> command in the Edit menu. It copies the text into the buffer, but, unlike Cut, it does not clear the cells.   

The cell texts in the buffer can be pasted into the table. The Paste Texts <Ctrl+Y> command in the Edit menu makes a paste box, that is attached to the mouse pointer.  The size of the paste box is about the size of the cell texts in the buffer. You can move the paste box with the mouse and click button-1 somewhere into the table to release it. The cell in which the mouse cursor (and the top-left of the paste box) was at the time you clicked button-1 becomes the top-left cell of the cell area in which the texts are pasted. Which cell is pasted by which cell text is determined by the relative row and column position (not of the actual size of the texts) when the original texts were cut or copied into the paste buffer. When you paste, the texts from the buffer are copied from the buffer into the table. The old cell texts are overwritten. If the box is released with the mouse pointer somewhere out of the table, the paste command is aborted. If the paste box is released (partly) outside the table, only the part that covers the table is modified.

7.1.6 Adding Rows and Columns

To add rows, use the Add Rows    command in the Edit menu. A prompt dialog is popped up asking for the number of rows to be added (default is 1). In the dialog there is a toggle to choose between adding the new rows above the selection or appending them to the bottom of the table. ``Above the selection'' means one row above the highest selected cell in the current selection, or when the selection is empty, to the bottom of the table.

Adding columns, via the Add Columns    command, is like adding rows. There is a choice between adding the new columns to the left of the current selection or appending to the right of the table.

After adding rows or columns the table is redrawn including the new rows and columns in such a way that the top-left corner of the table remains at the same position.

7.1.7 Deleting Rows and Columns

To delete rows, use the Delete Rows command in the Edit menu.   This command deletes every row in which one or more cells are selected.

To delete columns, use the Delete Columns command in the Edit menu.   This command deletes every column in which one or more cells are selected.

To delete all cells, use the Delete All command. This results into an empty table [*]. Before everything is deleted, a question dialog asks if you are sure about what you are doing.

To remove all unused rows and columns, use the Purge   command. This command deletes all rows and columns in which all cells have empty cell texts.

When you delete rows and/or columns, the table is redrawn in such a way that the top-left corner stays at the same position.

7.1.8 Moving Rows and Columns

Moving a row is possible via dragging a row label from the    source row to the desired destination row. If the dragged label is released in one of the cells of the destination row, the source row, where the label came from, is moved to the position of the destination row and the destination row and the rows between the source and destination row are all shifted one row up (when the source row was above the destination row) or one row down (when the source row was beneath the destination row) [*].

Moving a column works in a similar way.   If you drop a column label into a cell of another column, the source column moves to that position and the destination column and the columns between those two are all shifted one column left or right.

Note that when you move a row or column, the row and column labels are not moved with. They stay in the same consecutive order, of course.

After either command, the resulting table has the same position and has the same size.

7.1.9 Sorting Rows and Columns

With the Sort Rows command in the Edit menu you can sort rows alphabetically.    When the selection is empty, the table is sorted according to the contents of the first column. If there are selected cells, sorting is according to the column of the left-most selected cell.

With the Sort Columns command in the Edit menu you can sort columns   alphabetically. When the selection is empty, the table is sorted according to the contents of the first row. If there are selected cells, sorting is according to the row of the top-most selected cell.

After either command, the resulting table has the same position and the same size.

7.1.10 Resizing Rows and Columns

    

Resizing rows and columns can be done by hand but only when the autoresizing toggle is off. To resize a row or column, drag a line piece between two rows or columns: if you enter a line piece between two rows or between two columns, the mouse pointer turns into a pair of vertical respectively horizontal arrows. To resize a row you can drag the line piece with button-1 up or down. If you drop the line at a new position, the row above the dragged line, is resized. You cannot resize a row to less than the minimal row height of the table (the minimal row height can be modified in the Table menu). The part of the table below the row that is resized, will be repositioned (but not resized).

To resize a column you can drag a line piece with button-1 left or right. If you drop the line at a new position, the column to the left of the line that is dragged, is resized. You cannot resize a column to less than the minimal column width of the table (which you can be modified in the Table menu). The part of the table to the right of the column that is resized, will be repositioned (but not resized).

7.1.11 Undo and Redo

The table editors have a multiple-level undo for their commands. A command which is undone, can be redone again.   All table edit commands listed in the Edit and Text menu can be undone. Furthermore, the table edit commands issued by the mouse can also be undone. In table 7.2 all undo-able table editor commands are listed together with how they can be called.


  
Figure 7.2: All atomic table edit commands.
\begin{figure}
\begin{center}

\includegraphics {p/tablecommands.eps}\end{center}\end{figure}

7.1.12 Table Text Commands

The Text menu  contains certain commands that work on cell texts.

7.1.13 Table Layout Commands

The Table menu  contains commands that determine the layout of the table.


next up previous contents index
Next: 7.2 The Generic Table Up: 7 Table Editing Previous: 7 Table Editing
Frank Dehne,Faculty of Mathematics and Computer Science, Vrije Universiteit Amsterdam
11/17/1997