在 R 和 Latex 中使用大括号给出错误

问题描述 投票:0回答:0

我正在使用以下代码创建一个表:


data <- data.frame(
  z = c("c. $5^{-1}$")
)

create_table(data, "cccc")

当我在 bookdown 中编译它时,它给出以下错误:

! Missing $ inserted.
<inserted text> 
                $
l.890 \end{tabu}

Try to find the following text in bookdown-demo.Rmd:
  \end{tabu} 

You may need to add $ $ around a certain inline R expression `r ` in bookdown-demo.Rmd (see the above hint). See https://github.com/rstudio/rmarkdown/issues/385 for more info.
Error: LaTeX failed to compile bookdown-demo.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See bookdown-demo.log for more info.

当我删除 -1 周围的花括号时,这个错误就消失了。但是,我继续 - 作为指数,而不是 -1。我做错了什么。

r latex bookdown
© www.soinside.com 2019 - 2024. All rights reserved.