   .replace /\\subsubsection\s*\*?\s*{((?:[^{}]|{[^{}]*})*)}/g, '<h4>$1</h4>'
   .replace /\\paragraph\s*\*?\s*{((?:[^{}]|{[^{}]*})*)}\s*/g, '<p><b>$1</b> '
   .replace /\\footnote\s*{((?:[^{}]|{[^{}]*})*)}/g, '[$1]'
-  .replace /\\includegraphics\s*{([^{}]*)}/g, '<img src="$1">'
+  .replace /\\includegraphics\s*(\[[^\[\]]*\]\s*)?{((?:[^{}]|{[^{}]*})*)}/g,
+    (match, optional, graphic) ->
+      style = ''
+      optional.replace /width\s*=\s*([0-9.]+)\s*([a-zA-Z]*)/g,
+        (match2, value, unit) ->
+          style += "width: #{value}#{unit};"
+          ''
+      .replace /height\s*=\s*([0-9.]+)\s*([a-zA-Z]*)/g,
+        (match2, value, unit) ->
+          style += "height: #{value}#{unit};"
+          ''
+      style = ' style="' + style + '"' if style
+      """<img src="#{graphic}"#{style}>"""
   .replace /\\begin\s*{(problem|theorem|conjecture|lemma|corollary)}/g, (m, p1) -> "<blockquote><b>#{s.capitalize p1}:</b> "
   .replace /\\end\s*{(problem|theorem|conjecture|lemma|corollary)}/g, '</blockquote>'
   .replace /\\begin\s*{(proof|pf)}/g, '<b>Proof:</b> '

  .replace /`/g, '&lsquo;'
  .replace /'/g, '&rsquo;'
  .replace /\\&/g, '&amp;'
  .replace /\\([{}])/g, '$1'
  .replace /~/g, '&nbsp;'
  .replace /\\\s/g, ' '
  .replace /---/g, '&mdash;'

    math[i] = block
    "MATH#{i}ENDMATH"
  [text, math]

putMathBack = (tex, math) ->
  ## Restore math
  tex.replace /MATH(\d+)ENDMATH/g, (match, p1) -> math[p1]

postprocessKaTeX = (text, math) ->
  replacer = (block) ->
