@@ -291,8 +291,13 @@ writeDocx opts doc@(Pandoc meta _) = do
291291 let numpath = "word/numbering.xml"
292292 numbering <- parseXml refArchive distArchive numpath
293293 newNumElts <- mkNumbering (stLists st)
294+ let allElts = onlyElems (elContent numbering) ++ newNumElts
294295 let numEntry = toEntry numpath epochtime $ renderXml numbering{ elContent =
295− elContent numbering ++ map Elem newNumElts }
296+ -- we want all the abstractNums first, then the nums,
297+ -- otherwise things break:
298+ [Elem e | e <- allElts
299+ , qName (elName e) == "abstractNum" ] ++
300+ [Elem e | e <- allElts, qName (elName e) == "num" ] }
296301 let docPropsPath = "docProps/core.xml"
297302 let docProps = mknode "cp:coreProperties"
298303 [("xmlns:cp","http://schemas.openxmlformats.org/package/2006/metadata/core-properties")