答案1
欢迎来到 TeX.SE。一个小型 MWE 演示了如何添加列标题。您的错误是在调用函数时kable
,您需要在其中添加format='latex',escape=FALSE
。
% Compile in RStudio to knit to pdf
\documentclass[a4paper,12pt]{article}
\usepackage{booktabs}
\begin{document}
<<Rcode,results='asis'>>=
library(kableExtra)
L1 <- data.frame("sxy"=2229,"sxx"=10954,"var"=6.8)
colnames(L1) <- c("$sxy$","$sxx$","$\\widehat{var}(\\widehat{b_0})$")
print(kable(L1,format='latex',escape=FALSE,booktabs=T))
@
\end{document}