| Search Locate Previous Next | Contents |
NewLeaf aligns the contents of each cell in a column along the left edge by default.
To align the sales data along the right edge of each column, type:
leaf.Init ª leaf.Use'' leaf.table.Align 'right' leaf.table.List salesQ1 View docleaf.Close
Repeat the previous example using 'centre' or 'center' instead of 'right' alignment.
Then, to right- and left-align alternate columns, type:
leaf.Init ª leaf.Use'' leaf.table.Align 'Right' 'Left' leaf.table.List salesQ1 View docleaf.Close
There are three things to note here. First, the alignment is not case sensitive, so 'right' has the same effect as 'Right' or 'RIGHT'. Second, the vector of alignment settings is always reshaped to match the number of columns in the table. Thirdly, you can reduce any of the words to two-letter abbreviations, such as 'ce' 'ri' 'ri'.
NewLeaf is also able to align the decimal points in numeric data, and to reserve sufficient space to the right of the decimal for a specified number of digits to appear.
As the sales data have been calculated to one decimal place, try typing:
leaf.Init ª leaf.Use'' leaf.table.Align 'decimal1' leaf.table.List salesQ1 View docleaf.Close
The figures in each column are now aligned according to the position of the decimal place, but they are a mixture of integers and floating-point numbers. Try combining an appropriate format specification with the decimal alignment to produce a more consistent appearance:
leaf.Init ª leaf.Use'' leaf.table.Align 'decimal1' leaf.table.Qfmt ((¯1+¯1½salesQ1)½'CF8.1'),'CF9.1' leaf.table.List salesQ1 View docleaf.Close
Continuing with the sales report, left-align the row titles and decimal-align the data:
leaf.Init ª leaf.Use'' leaf.table.Qfmt (''),((¯1+¯1½salesQ1)½'CF8.1'),'CF9.1' leaf.table.Align ('left'),(¯1½salesQ1)½'decimal1' leaf.table.List products,salesQ1 View docleaf.Close
Note that the order in which you set the alignments and the format specifications in this example was the reverse of the order in the previous example. The NewLeaf table properties are mutually independent, so an APL application can set them in whichever order is appropriate to the processing.