                 file.callback = (file2) ->
                   d file2.uniqueIdentifier
               Files.resumable.addFile file
+        for figure in attach
+          figure.message =
+            title: "Figure " +
+              (formatLabel label for label in figure.labels).join " / "
+            body: figure.caption
+            format: 'latex'
+            published: now
+          rootFiles = (file for file in figure.files when file.graphic.subcaption == false)
+          if rootFiles.length == 1
+            figure.message.file = rootFiles[0].file2id
+            figure.files = _.without figures.files, rootFiles[0]
+          frevision = _.clone figure.message
+          figure.message.creator = me
+          figure.message.created = now
+          frevision.updators = [me]
+          frevision.updated = now
+          await Meteor.call 'messageImport', group, message._id, figure.message, [frevision], defer error, figure.message._id
         await
           for figure in attach
             for file in figure.files

          for graphic in figure.graphics
            for label in graphic.labels
              figures[label] = figure

  ## Extract sections.
  for filename, content of zip.files

              [labels, subbody] = findLabels subbody
              subcaption = /\\caption\s*{((?:[^{}]|{[^{}]*})*)}/.exec(subbody)?[1]
              findIncludeGraphics subbody, subcaption, labels
          findIncludeGraphics body, false  ## subcaption = false for root images
          ## Search for correct extensions
          for graphic in graphics
            for extension in ['', '.svg', '.png', '.jpg', '.pdf']
