Plot

Align

Align table cell content horizontally and vertically.

It's often easier to compare numbers and values when they are all aligned in a meaningful way. Novem tables support both horizontal alignment (left, center, right) and vertical alignment (top, middle, bottom). The alignment is applied to a subsection of the table defined by the standard slicing instructions. To instruct the alignment we use these glyphs:

 <    -- left align (horizontal)
 -    -- center align (horizontal)
 >    -- right align (horizontal)
 ^    -- top align (vertical)
 =    -- middle align (vertical)
 v    -- bottom align (vertical)

You can also combine horizontal and vertical alignment by using two characters, where the first character is the horizontal alignment and the second is the vertical alignment (e.g., <^ for left+top).

It can be helpful to think of the symbols "pointing" in the direction of the alignment.

Left alignment is the most common alignment and is the default if no instructions are given. That being said, some templates could have a different default direction, so the below example shows how to add a left align to the entire table.

All we need to do to left align the table is to create a global selector : : and give it the < (left) instruction.

ctrl/config/table/cell/align
   :     :     <                 -- left align everything

The next example shows how to center all columns in a table except the left one. Often you'll have index values or other information in the left column that you might feel look better left align.

Here we start by replicating the left align everything instruction, and then providing a more specific center align - that centers the rest of the table.

ctrl/config/table/cell/align
   :     :     <   -- left align everything
   :    1:     -   -- center everything except the first column

Finally we have what is probably the most common table alignment for numeric data. Below we have an example that left aligns the right most column, centers the remainder of the top row and right aligns all the numbers below.

Here we take advantage of the fact that our rules are processed in order, this allows us to first left align everything, then center everything except the first column and then further right aligning all the numbers.

ctrl/config/table/cell/align
   :     :     <   -- left align everything
   :    1:     -   -- center everything except the first column
  1:    1:     >   -- align everything else to the right

This little alignment mix is more to show the flexibility of the slicers than any common alignment need. Hopefully this can serve as an inspiration to get your table looking just right.

The instructions below primarily does two things:

  • left center and right align columns 2, 3 and 4
  • create three different "snake" patterns for columns 5,6 and 7

Hopefully this helps illustrate that once can create complex formatting with rather few instructions.

ctrl/config/table/cell/align
  :       :      <    -- left align everything
  :      1:      >    -- right align all rows and all columns starting
                      -- at column 2
  0      1:      -    -- center top row starting at column 2

  :      2       -    -- center third column
  :      3       <    -- right align forth column

 -- create the left "snake" in column five
 4:-1    4       -    -- center fifth column from fifth row and down
 7:9     4       <    -- override row 8-10 and left align

 -- create the right "snake" in column seven
  :      6       <    -- left align column 7
 4:-1    6       -    -- center seventh column from fifth row and down
 7:9     6       >    -- override row 8-10 and right align

-- create the middle "snake" in column six
  :      5       -    -- start by centering column six
 2:-1:4  5       <    -- left align every forth row starting at row 3
 4:-1:4  5       >    -- left align every forth row starting at row 5

In addition to horizontal alignment, you can control vertical alignment within cells. This is particularly useful when cells have different heights due to varying content. The vertical alignment glyphs are:

  • ^ - top align (content sits at the top of the cell)
  • = - middle align (content is vertically centered)
  • v - bottom align (content sits at the bottom of the cell)

When using a single vertical alignment character, horizontal alignment defaults to center:

ctrl/config/table/cell/align
   :     :     ^   -- top align everything (horizontal defaults to center)
   :     :     v   -- bottom align everything (horizontal defaults to center)

For full control over both horizontal and vertical alignment, combine both characters in a two-character instruction. The first character is the horizontal alignment and the second is the vertical:

 <^   -- left + top
 <=   -- left + middle
 <v   -- left + bottom
 -^   -- center + top
 -=   -- center + middle
 -v   -- center + bottom
 >^   -- right + top
 >=   -- right + middle
 >v   -- right + bottom

This allows precise positioning of content within cells:

ctrl/config/table/cell/align
   :     :     <=   -- left + middle align everything
   0     :     -^   -- center + top align header row
  1:    -1     >v   -- right + bottom align data cells except last column