1. A machine readable medium storing a program which when executed by at least one processing unit analyzes a document comprising a plurality of primitive elements, the program comprising sets of instructions for: identifying aligned gaps in a plurality of text lines in a column of the document; determining which of the aligned gaps are indicative of spacing between a list item label and a list item in order to identify text lines that include the aligned gaps as list items; identifying hierarchical levels for the list items based on alignment, spacing, and content of the list items; and defining a hierarchically-organized set of lists for the column in which list items with the same hierarchical level are in the same list.