title: LaTeX math expression in knitr kable (Sweave)
body: <p>Is it possible and how to use a LaTeX math expression in a knitr/Sweave report with <code>kable</code>? In the example below, <code>$x^2$</code> is rendered "as is".</p>
  
  <p>With <code>xtable</code>, for the example below, I would use the option <code>sanitize.colnames.function = function(x) x</code> of <code>print.xtable</code>. Is there such an option for <code>kable</code>?</p>
  
  <pre><code>\documentclass{article}
  \usepackage{booktabs}
  \begin{document}
  
  &lt;&lt;&gt;&gt;=
  library(knitr)
  dat &lt;- mtcars[1:5,1:5]
  options(knitr.table.format = "latex")
  @
  
  &lt;&lt;results='asis'&gt;&gt;=
  names(dat)[1] &lt;- "$x^2$"
  kable(dat, booktabs=TRUE, caption="My table")
  @
  
  \end{document}
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/dgn5F.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dgn5F.png" alt="enter image description here"></a></p>