1. A method of laying out a page which is to contain a plurality of discrete document elements, comprising: receiving a hierarchical page description describing layout of the discrete document elements on the page, wherein the hierarchical page description contains two or more hierarchical levels, each of the discrete document elements is placed at one of the hierarchical levels; optimising layout of the page described by the hierarchical page description by one or more rearrangement operations, where each rearrangement operation rearranges elements at a single hierarchical level, to minimise the value of a cost function; and laying out the discrete document elements on the page according to the optimised hierarchical page description layout.