| Search Locate Previous Next | Contents |
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:
nlInit ª nlUse'' nltTitles districts nltList salesQ1 View docnlClose
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:
nlInit ª nlUse'' nltTitles 'Odd' 'Even' nltList salesQ1 View docnlClose
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):
nlInit ª nlUse'' nltTitles regions,¨(,' '),¨districts nltList salesQ1 View docnlClose
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:
nlInit ª nlUse'' nltTitles [1]regions,[0.5]districts nltList salesQ1 View docnlClose
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:
nlInit ª nlUse'' nltTitles (¯1[1]regions,[0.5]districts),¯1districts nltList salesQ1 View docnlClose
In summary, column titles have the following default characteristics:
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:
nlInit ª nlUse'' nltFont ('TI,10'),((¯1+¯1½salesQ1)½'HE,10'),'HEB,10' nltQfmt (''),((¯1+¯1½salesQ1)½'CF8.1'),'CF9.1' nltAlign ('left'),(¯1½salesQ1)½'decimal1' nltCellWidths 72×0.9,((¯1+¯1½salesQ1)½0.75),0.8 nltGridlines 1,(0.5,(1-¯1½salesQ1)0.5),0 nltSpacing 1 1 nltTitles (''),(¯1[1]regions,[0.5]districts),¯1districts nltList ¯1[1]products,salesQ1 nltRule 0.5 nltSpacing 3 3 nltList ¯1[1]products,salesQ1 View docnlClose