Search Locate Previous Next Contents

Simple Column Titles

The preceding topics introduced several of the table-handling features of NewLeaf, and showed how to apply these to a single table, both individually and in combination to produce the desired output. The tutorial continues with some topics which demonstrate how to add column titles and captions to a table, and how to position a table horizontally on a page. The examples that follow are a continuation of the work you have already done.


Column titles are treated separately from a table although they inherit some of its properties. In its basic form, a set of simple column titles is a vector of text vectors containing one text string for each column in the table:

leaf.Init ª leaf.Use''
leaf.table.Titles districts
leaf.table.List salesQ1
View doc„leaf.Close

Any elements in the vector of column titles that lie beyond the number of columns in the table are ignored. If there are fewer column titles than columns in the table, NewLeaf reshapes the vector of vectors as required:

leaf.Init ª leaf.Use''
leaf.table.Titles 'Odd' 'Even'
leaf.table.List salesQ1
View doc„leaf.Close

Column titles can occupy more than one row. Where a column title exceeds the width of the corresponding table column, NewLeaf automatically word-wraps the text string. Useful column titles for the sales report would have each district name beneath its associated region. You can construct the appropriate text string for each column by concatenating each district name to the end of its corresponding region name, then allow NewLeaf to word-wrap individual text strings. If a column title requires fewer lines than any others, it is centred vertically within the row of column titles (see the rightmost column):

leaf.Init ª leaf.Use''
leaf.table.Titles regions,¨(›,' '),¨districts
leaf.table.List salesQ1
View doc„leaf.Close

Alternatively, it is possible to control this word-wrap to some extent by specifying an individual column title as a vector of text vectors. NewLeaf starts each separate text string on a new row, although individual text strings are still subject to word-wrap if their length exceeds the width of the column:

leaf.Init ª leaf.Use''
leaf.table.Titles ›[1]regions,[0.5]districts
leaf.table.List salesQ1
View doc„leaf.Close

NewLeaf adjusts the overall height of the row of column titles to accommodate the column title with the largest number of text strings.

Any column title with fewer text strings is centred within this vertical distance.

Compare the vertical position of “Total” above the rightmost column of the previous example (where it is beneath an empty vector) with its position when it is the only text string in the column title:

leaf.Init ª leaf.Use''
leaf.table.Titles (¯1‡›[1]regions,[0.5]districts),¯1†districts
leaf.table.List salesQ1
View doc„leaf.Close

In summary, column titles have the following default characteristics:

  1. The column title cells are the same width as the corresponding columns of the table.
  2. The horizontal rules above and below the column titles are the same thickness as the table border, that is, the first of the three gridline settings.
  3. The vertical rules between the column titles are the same thickness as the vertical gridline setting, that is, the second of the three gridline settings.
  4. The individual lines within a column title are uniformly spaced within the vertical height of the column title row.
  5. Each line in a column title is centre-aligned within the column.
  6. All column titles appear in 13-point bold Helvetica (Arial).
  7. There are no horizontal rules between the lines in a multiple-line column title.

The first three of these properties are inherited from the table. The next two topics in this tutorial demonstrate how to set the alignment and font for the column titles. The final topic in this tutorial explains how to specify column titles that extend across more than one column; this is the only time that horizontal rules appear within the column titles.

You can now add the region and district names as column titles to the sales report begun in previous tutorial. Note how this example puts an empty vector, that is, no title, above the first column:

leaf.Init ª leaf.Use''
leaf.table.Font (›'TI,10'),((¯1+¯1†½salesQ1)½›'HE,10'),›'HEB,10'
leaf.table.Qfmt (›''),((¯1+¯1†½salesQ1)½›'CF8.1'),›'CF9.1'
leaf.table.Align (›'left'),(¯1†½salesQ1)½›'decimal1'
leaf.table.CellWidths 72×0.9,((¯1+¯1†½salesQ1)½0.75),0.8
leaf.table.Gridlines 1,(›0.5,(1-¯1†½salesQ1)†0.5),0
leaf.table.Spacing 1 1
leaf.table.Titles (›''),(¯1‡›[1]regions,[0.5]districts),¯1†districts
leaf.table.List ¯1‡[1]products,salesQ1
leaf.table.Rule 0.5
leaf.table.Spacing 3 3
leaf.table.List ¯1†[1]products,salesQ1
View doc„leaf.Close


Continue to: Horizontal Alignment of Column Titles
© Copyright Causeway Graphical Systems Ltd 2001