       tex = tex
       .replace /%.*$\n?/mg, ''
       .replace /\\begin\s*{(wrap)?figure}[^\0]*?\\end\s*{(wrap)?figure}\s*/g, ''
-      .replace /\\cite\s*(?:\[([^\[\]]*)\]\s*)?{([^{}]*)}/g, (match, p1, p2) ->
-        '[' + (
-          for cite in p2.split ','
-            cite = cite.trim()
-            bib = bibs[cite]
-            if bib?
-              "\\href{#{bib.url}}{#{bib.abbrev}}"
-            else
-              console.warn "Missing bib url for '#{cite}'" unless bib?
-              cite
-        ).join(', ') + (if p1? then ", #{p1}" else '') + ']'
+      tex = processCites tex
       depths = []
       start = null
       labels = {}

          abbrev: abbrev
          url: match[2][1...-1]

  ## Extract figures.
  figures = {}
  for filename, content of zip.files

              console.warn "Missing file for \\includegraphics{#{graphics}}"
            graphics.push filename
          caption = /\\caption\s*{((?:[^{}]|{[^{}]*})*)}/.exec p2
          caption = processCites caption[1]
          labels = []
          lr = /\\label\s*{((?:[^{}]|{[^{}]*})*)}/g
          while (match = lr.exec p2)?
