Alignment and Distribution of Objects

This section describes the Align and Distribute dialog (Object icon Align and Distribute... (Shift+Ctrl+A)) which allows the positioning of objects with respect to other objects or to the selection, drawing, or page. Two types of positioning are available: alignment where the centers or edges of objects are aligned to one another, and distributing where objects are distributed in some direction based on their centers or edges.

Align and Distribute dialog.
Align and Distribute dialog.

Align

The alignment of objects is with respect to an anchor. The anchor can be an object or be defined by the selection, drawing, or page; the choice of what is used is set in the pull-down menu Relative to. The object may be specified to be the first or last object selected. If multiple objects are selected at the same time, this is equivalent to the top or bottom object in z-order. Alternatively, the object can be specified to be the biggest or smallest item, where size is determined by the size of the bounding box, the width for vertical alignment and the height for horizontal alignment. The bounding box sides are used as the reference points for alignment except for text, where the baseline is used.

When the Treat selection as group: box is checked, all selected objects are treated as if they were in a Group. This saves on having to group and ungroup the selected objects when you wish to align them together to the Page or to the drawing. Alignment relative to other criteria is unpredictable.

The various alignment options are:

  • Horizontal:

    • icon Align right sides to left side of anchor.

    • icon Align right sides to right side of anchor.

    • icon Align horizontal centers to center of anchor.

    • icon Align left sides to left side of anchor.

    • icon Align left sides to right side of anchor.

    • icon Align baselines of text to anchor, horizontally. As of v0.48, text anchor position depends on alignment and orientation of text (e.g. the anchor box will be on the right for right-aligned text).

  • Vertical:

    • icon Align top sides to bottom side of anchor.

    • icon Align top sides to top side of anchor.

    • icon Align vertical centers to center of anchor.

    • icon Align bottom sides to bottom side of anchor.

    • icon Align bottom sides to top side of anchor.

    • icon Align baselines of text to anchor, vertically.

Distribute: Uniform

The distribute part of the Align and Distribute dialog allows objects to be evenly spaced in the horizontal or vertical direction based on some criteria. Two options are included in this part of the dialog, which perhaps should be included separately: randomizing the center of objects and unclumping. They will be considered in the next section.

The distribution of objects is between the two objects at the extremes (i.e., the leftmost and rightmost objects for horizontal distribution). The definition of which is the leftmost and rightmost object is made using the objects' bounding boxes, and it may depend on the type of distribution selected. For example, if a distribution is based on the rightmost edge of the objects, then the objects rightmost edge will be used to determine which objects are at the extremes.

The various distribution options are:

  • Horizontal:

    • icon Distribute left sides evenly.

    • icon Distribute centers evenly.

    • icon Distribute right sides evenly.

    • icon Distribute with uniform gaps between objects.

    • icon Distribute baseline anchors evenly.

  • Vertical

    • icon Distribute left sides evenly.

    • icon Distribute centers evenly.

    • icon Distribute top sides evenly.

    • icon Distribute with uniform gaps between objects.

    • icon Distribute baseline anchors evenly.

Distribute: Non-Uniform

The distribute part of the Align and Distribute dialog has two options that modify the distribution of objects in a non-uniform way. Both affect the horizontal and vertical distributions at the same time.

The two options are:

  • icon Randomize the center of objects.

  • icon Unclump objects (i.e., move objects to more evenly space the edge-to-edge distances). Repeated application approaches the use of the Distribute with uniform gaps commands described previously.

Distribute: Remove Overlaps

Another section of the Align and Distribute dialog allows one to move objects just enough that they don't overlap. Two entry boxes, one for the horizontal direction and the other for the vertical direction, allow the addition of a minimum space between adjacent objects.

Rows and Columns

The Rows and Columns dialog (Object icon Rows and Columns... ) can be used to arrange an arbitrary number of objects into a two-dimensional grid.

Rows and Columns dialog.
Rows and Columns dialog.

To use the dialog, first select all the objects you wish to arrange into a grid. The dialog will default to a one-dimensional array. You can use the Row and Column entry boxes to change the number of rows and columns. If you use the up or down arrow to change the number of rows, the number of columns will change to give you the minimum number required to include all the objects in the selection. A similar change to the number of rows will happen if you change the number of columns. The maximum number of rows or columns is 100.

The algorithm for determining the order the objects are placed in the array attempts to preserve any existing rows. For this algorithm, the bounding box of each object is used. Technically, the objects are first sorted by their vertical positions. Then objects that overlap vertically are sorted by their horizontal positions. Finally, the objects are placed from left to right and from top to bottom in the array. The algorithm works pretty well but cannot handle all situations since determining what objects are in a row is objective. (If in the vertical direction A overlaps B and B overlaps C but A does not overlap C, are A and C in the same row?)

Grid align 1.
Twelve object before (left) and after (right) aligning with a 3 by 4 grid.

For placing objects, the grid is divided into cells. First, the cell size and placement is determined and then the objects are positioned inside the cells, one object to one cell.

Cells are given the height of the tallest object if the Equal height box is checked; otherwise, they are given the height of the tallest object in their row. A similar policy is followed for width.

Grid align 2.
Alignment with the Equal height box checked (left) and unchecked (right). Note how the height of the 8 has been used for all rows on the left and just its own row on the right.

If the Fit into selection option is selected, the rows and columns of cells are evenly spaced with the edge rows and columns flush against the bounding box of the selection. If the Set spacing option is selected, the rows and columns are separated by the amount entered in the Row spacing and Column spacing entry boxes. The spacing can be negative.

Once the cell positions have been determined, the objects are placed inside the cell according to the selected Align options (top, middle, bottom; left, center, right).

Grid align 3.
Grid alignment with alignment to top (left), center (middle), and bottom (right) of cell.

Note that the bounding box of all the objects after alignment may not be the same as the bounding box of the selection prior to alignment even though the Fit to selection option has been chosen. This is because the selection bounding box has been used to place the cells. The objects within the cells may not touch the cell walls. (There also appears sometimes to be a gratuitous shift: Bug?)