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 and, for each hierarchical level, the page description contains a description of discrete documents from the plurality of discrete document elements in the hierarchical level and at least one constraint for arranging the discrete documents in the hierarchical level, and for a particular hierarchical level of the two or more hierarchical levels, the at least one constraint for that particular hierarchical level is only applicable for that particular hierarchical level; for each hierarchical level, optimizing layout of the page described by the hierarchical page description, one hierarchal level at a time, by rearranging the plurality of discrete elements in a single hierarchical level at a same time using the at least one constraint for the hierarchical level, to minimize the value of a cost function; and laying out the discrete document elements on the page for each hierarchal level, one hierarchal level at a time, according to the optimized hierarchical page description layout for each hierarchal level.