           url: match[2][1...-1]
 
   processCites = (tex) ->
+    return tex unless tex
     tex.replace /\\cite\s*(?:\[([^\[\]]*)\]\s*)?{([^{}]*)}/g, (match, p1, p2) ->
       '[' + (
         for cite in p2.split ','

        attach = _.unique attach  ## upload \ref'd figures only once each
        for figure in attach
          figure.message =
            title: "Figure ``#{figure.labels[figure.labels.length-1]}''"
            body: figure.caption
            published: now
            format: 'latex'

              file.creator = me
              file.created = now
              file.group = group
              file.graphic = graphic
              figure.files.push file
              do (d = defer file.file2id) ->
                file.callback = (file2) ->
