gpt4 book ai didi

R bookdown - 表头中的数学不起作用

转载 作者:行者123 更新时间:2023-12-02 03:06:16 25 4
gpt4 key购买 nike

克隆 bookdown-demo 后我试图在标题中得到一个带有一些数学的表格。在 html 输出中,一切正常。在 PDF 输出中它被破坏了:

block :

```{r}
knitr::kable(
head(cars),
col.names = c("$y_{speed}$", "$y_{dist}$")
)
```

Bookdown - PDF:(在这里你可以看到错误的输出)

enter image description here

Rmarkdown - PDF:(结果符合预期)

enter image description here

Bookdown - HTML:(结果符合预期)

enter image description here

这是 Latex-Code bookdown 产生的:

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{knitr::}\KeywordTok{kable}\NormalTok{(}
\KeywordTok{head}\NormalTok{(cars),}
\DataTypeTok{col.names =} \KeywordTok{c}\NormalTok{(}\StringTok{"$y_\{speed\}$"}\NormalTok{, }\StringTok{"$y_\{dist\}$"}\NormalTok{)}
\NormalTok{)}
\end{Highlighting}
\end{Shaded}

\begin{tabular}{r|r}
\hline
\$y\_\{speed\}\$ & \$y\_\{dist\}\$\\
\hline
4 & 2\\
\hline
4 & 10\\
\hline
7 & 4\\
\hline
7 & 22\\
\hline
8 & 16\\
\hline
9 & 10\\
\hline
\end{tabular}

最佳答案

只需为 kable 使用参数 escape = F 因为在 bookdown 中似乎有特殊字符的双重转义。

关于R bookdown - 表头中的数学不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42598821/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com