Alignment

Alignment

is an option which specifies how the contents of a displayed object should be aligned within the available area in the object.

Details

  • The following settings can be given:
  • Automaticdefault alignment based on environment
    Leftleft aligned
    Rightright aligned
    Toptop aligned
    Bottombottom aligned
    Baselinebaseline aligned
    Centercentered
    {h,v}separate horizontal and vertical alignments
    xaligned at position x from (left) to (right)
    {x,y}aligned at horizontal and vertical positions x and y from to
    "c"aligned on the specified character in a grid
  • Alignment->Center is equivalent to Alignment->{Center,Center}.
  • In Alignment->{x,y}, y values run from at the bottom to at the top.
  • Alignment->spec indicates that the spec element of an object should align with the spec element of whatever object contains it.
  • With Alignment->Automatic, the alignment for the contents of an object will be based on the alignment specified for whatever object contains it.
  • General settings for Alignment in Grid and related constructs can be given as:
  • specapply spec to all items
    {specx}apply horizontal alignments specx at successive horizontal positions
    {specx,specy}apply horizontal alignments specx and vertical alignments specy at successive horizontal and vertical positions
    {specx,specy,rules}also allow explicit rules for individual i,j elements
  • The speck can have the following forms:
  • {s1,s2,,sn}use s1 through sn; then use defaults
    {{c}}use c in all cases
    {{c1,c2}}alternate between c1 and c2
    {{c1,c2,}}cycle through all ci
    {s,{c}}use s, then repeatedly use c
    {s1,{c},sn}use s1, then repeatedly use c, but use sn at the end
    {s1,s2,,{c1,c2,},sm,,sn}use the first sequence of si at the beginning, then cyclically use the ci, then use the last sequence of si at the end
    {s1,s2,,{},sm,,sn}use the first sequence of si at the beginning and the last sequence at the end
    {i1->v1,i2->v2,}specify what to use at positions ik
    {spec,rules}use rules to override specifications in spec
  • With settings of the form {s1,s2,,{},sm,,sn}, if there are more si specified than items across the grid, si from the beginning are used for the first items, and ones from the end are used for the last items.
  • Rules of the form {{imin,imax},{jmin,jmax}}->v can be used to specify alignments for regions of a grid.

Examples

open all close all

Basic Examples  (3)

Align elements around the center of the grid:

In[1]:=
Click for copyable input
Out[1]=

Different predefined alignment options for Button:

In[1]:=
Click for copyable input
Out[1]=

Align expressions within the panel:

In[1]:=
Click for copyable input
Out[1]=

Scope  (3)

Generalizations & Extensions  (2)

Properties & Relations  (1)

Introduced in 2007
(6.0)