Under temperature changes or loading, alloys can form beautiful patterns of microstructure that largely determine their macroscopic behaviour. These patterns result from phase transformations involving a change of shape of the underlying crystal lattice, together with the requirement that such changes in different parts of the crystal fit together geometrically. Similar considerations apply to plastic slip. The lecture will explain both successes in explaining such microstructure mathematically, and how resolving deep open questions of the calculus of variations could lead to a better understanding.