  We study the phase behavior of hard spheres confined between two parallel
hard plates using extensive computer simulations. We determine the full
equilibrium phase diagram for arbitrary densities and plate separations from
one to five hard-sphere diameters using free energy calculations. We find a
first-order fluid-solid transition, which corresponds to either capillary
freezing or melting depending on the plate separation. The coexisting solid
phase consists of crystalline layers with either triangular or square symmetry.
Increasing the plate separation, we find a sequence of crystal structures from
n triangular to (n+1) square to (n+1) triangular, where n is the number of
crystal layers, in agreement with experiments on colloids. At high densities,
the transition between square to triangular phases are intervened by
intermediate structures, e.g., prism, buckled, and rhombic phases.
