
\chapter{Tables}

\section{Elementary manipulations on tables}

In order to create a table, you may either use \submenu{Insert}{table}
or one of the following keyboard shorthands:
\begin{description}
  \item[\key{esc}-\key{t}-\key{N}-\key{t}]
    Create a regular table.
  \item[\key{esc}-\key{t}-\key{N}-\key{T}]
    Create a regular table whose cells are centered.
  \item[\key{esc}-\key{t}-\key{N}-\key{b}]
    Create a regular ``block'', whose cells are separated by lines.
  \item[\key{esc}-\key{t}-\key{N}-\key{B}]
    Create a block whose cells are centered.
\end{description}
In math mode, a few other table-like structures are provided:
\begin{description}
  \item[\key{esc}-\key{t}-\key{N}-\key{m}]
    Create a matrix.
  \item[\key{esc}-\key{t}-\key{N}-\key{d}]
    Create a determinant.
  \item[\key{esc}-\key{t}-\key{N}-\key{c}]
    Create a choice list.
\end{description}
The ¤\eqnarray*¤ environment is also a special kind of
table-like structure, which extends over the entire line.
You may start a list of equations using
\subsubmenu{Insert}{mathematics}{equations}.

When starting a new table, its size is minimal (usually $1 \times 1$) and
its cells are empty. New rows and columns are inserted using the
\key{esc}-\key{left}, \key{esc}-\key{right}, \key{esc}-\key{up} and
\key{esc}-\key{down} shorthands. For instance, \key{esc}-\key{right}
creates a new column at the right of the current cursor position.
You may also start a new row below the current cursor position
by hitting \key{return}.

\section{Elementary formatting operations}

\subsection{The formatting mode}

In {\TeXmacs}, arbitrary blocks of cells in the table maybe
formatted in particular ways. For instance, you may give
individual cells a background color, but you may also decide
an entire column to be horizontally centered.
By default, formatting commands operate on individual cells,
but this may be changed via \submenu{Table}{cell operation mode}.
The following operation modes are available:
\begin{description}
  \item[\key{esc}-\key{t}-\key{m}-\key{c}]
    Operate on individual cells.
  \item[\key{esc}-\key{t}-\key{m}-\key{h}]
    Operate on rows.
  \item[\key{esc}-\key{t}-\key{m}-\key{v}]
    Operate on columns.
  \item[\key{esc}-\key{t}-\key{m}-\key{t}]
    Operate on the entire table.
\end{description}
It is also possible to select a block of cells using
the mouse and perform a single operation on that rectangle.

\subsection{Alignment}

The most frequent formatting operation is the horizontal
or vertical alignment of a block of cells.
You may use the \key{alt}-\key{left}, \key{alt}-\key{right},
\key{alt}-\key{up} and \key{alt}-\key{down} keystrokes to
quickly align more to the left, right, top or top.

A specific alignment can also be selected in
the \submenu{Table}{horizontal cell alignment} and
\submenu{Table}{vertical cell alignment} menus.
Alternatively, you may use keyboard shorthands of
the types \key{esc}-\key{t}-\key{h}-\key{$x$}
and \key{esc}-\key{t}-\key{v}-\key{$x$} for
horizontal resp. vertical alignment.

Similarly, you may specify how the table itself
should be aligned with respect to the surrounding text.
This is either done via the
\submenu{Table}{horizontal table alignment} and
\submenu{Table}{vertical table alignment} submenus,
or using keyboard shorthands of the form
\key{esc}-\key{t}-\key{H}-\key{$x$} or
\key{esc}-\key{t}-\key{V}-\key{$x$}.

\subsection{Size}

Using \subsubmenu{Table}{cell width}{set width} resp.
\subsubmenu{Table}{cell height}{set height} you may
specify the width or height of a cell.
In fact, the specified width (or height) may be taken
into account in three different ways:
\begin{description}
  \item[Minimum mode.]
    The actual width of the cell will be the minimum of
    the specified width and the width of the box inside the cell.
  \item[Exact mode.]
    The width of the cell will be precisely the specified one.
  \item[Maximum mode.]
    The actual width of the cell will be the maximum of
    the specified width and the width of the box inside the cell.
\end{description}
The border width and the cell padding (to be explained below) are
taken into account in the size of the box inside the cell.

You may also specify the width and the height of the entire table
in \submenu{Table}{special table properties}. In particular,
you may specify the table to run over the entire width
of a paragraph. When specifying a width (or height)
for the entire table, you need to specify how
the unused space is distributed over the cells using
\subsubmenu{Table}{special cell properties}{distribute unused space}.
By default, the unused space is equally distributed.

\subsection{Border and padding}

You may specify the border widths and padding spaces of a cell
in all possible four directions: on the left, on the right,
at the bottom and at the top (see \submenu{Table}{cell border}).
You have keyboard shorthands of the forms
\key{esc}-\key{t}-\key{b}-\key{$x$} and
\key{esc}-\key{t}-\key{p}-\key{$x$}
in order to specify border widths and cell padding.

The default border width for cells in the block environment is ¤1ln¤,
i.e. the standard line width in the current font
(like the width of a fraction bar).
This width occurs at the right and the bottom of each cell
(except when the cell is on the first row or column).
The default horizontal cell padding is ¤1spc¤:
the width of a white space in the current font.
The default vertical cell padding is ¤1sep¤:
the standard minimal separation between two close boxes.

The entire table may also be given a border and a table padding
in \subsubmenu{Table}{special table properties}{border}.
In this case, the padding occurs outside the border.

\subsection{Background color}

Cells may be given a background color via
\submenu{Table}{cell background color}.

\section{Special features}

In the menus, you also find some other more special features for tables.
Very briefly, these include the following:
\begin{itemize}
  \item Change the ``span'' of a cell and let it run over
        its neighbouring cells on its right and below.
  \item Creation of entire subtables inside cells.
  \item Correction of the depth and height of text,
        in order to let the baselines match.
  \item Horizontal hyphenation of cell contents and
        vertical hyphenation of the entire table.
  \item Gluing several rows and/or columns together,
        so that the glued cells become ``part of the borders''
        of the remaining cells.
  \item Disactivation of the table, in order to see its ``source code''.
  \item Setting the ``extension center'' of a table.
        From now on, the formatting properties of this cell will
        be used for new cells created around this center.
  \item Specification of the minimal and maximum size of a table,
        which will be respected during further editing.
        (this is mainly useful when creating table macros).
\end{itemize}
Currently, all tables come inside an environment like
¤tabular¤, ¤block¤, ¤matrix¤, etc. When creating your own table macros,
you may use \subsubmenu{Table}{special table properties}{extract format}
to extract the format from a given table.
