gpt4 book ai didi

r - Knitr 在 R 代码中转义 latex 特殊字符(例如,〜,$)

转载 作者:行者123 更新时间:2023-12-04 20:41:23 26 4
gpt4 key购买 nike

当我在这个 knitr 文档的输出上运行它时,LaTeX 崩溃了,因为 LaTeX 特殊字符没有正确转义。任何提示如何解决这个问题?

\documentclass{beamer} 
\begin{document}
\begin{frame}{Unescaped dollar signs and tildes}

In this example, neither the tilde nor the dollar sign
will appear in the pdf document, and the dollar sign
will cause a \LaTeX error.

<<xtable, results="asis">>=
n <- 100

x <- rnorm(n)

y <- 2*x + rnorm(n)

out <- lm(y ~ x)

library(xtable)

xtable(summary(out)$coef, digits=c(0, 2, 2, 1, 2))
@

\end{frame}
\end{document}

最佳答案

您需要添加 [fragile]如果您的框架包含带有特殊 latex 字符的 knitr 块,则选择:

\begin{frame}[fragile]

来源: knitr webpage .

关于r - Knitr 在 R 代码中转义 latex 特殊字符(例如,〜,$),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25800985/

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