Handling Latex backslashes in xtable

前端 未结 2 1419
暖寄归人
暖寄归人 2020-12-14 16:25

I have a table that includes the following column:

 mytable <- data.frame(beta_0 = c(1,2,3)

What I want to do is output a table with a c

2条回答
  •  隐瞒了意图╮
    2020-12-14 16:38

    Two issues here; first, you need a double backslash as otherwise it treats it as a control sequence. Second, by default, xtable sanitizes text so that it won't break LaTeX. Use one of the sanitize. parameters to control this; to do no sanitizing, pass it the identity function.

    colnames(mytable) <- "$\\beta_0$"
    print(xtable(mytable), include.rownames = F, sanitize.colnames.function = identity)
    

提交回复
热议问题