本文介绍了在Hmisc :: latex中转义LaTeX控件符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在R中有一个数据框,不幸的是其中有包含美元符号的字符串.当包 Hmisc
中的函数latex()
转换时将此数据帧保存到LaTeX表中后,美元符号就不会转义.这使LaTeX无法编译. Hmisc
中是否有一种方法可以在格式化数据框中的值时转义美元符号?
I have a data frame in R which unfortunately has strings in it containing dollar signs. When the function latex()
from the package Hmisc
converts this data frame to a LaTeX table, the dollar signs are not escaped. This renders the LaTeX uncompilable. Is there a way within Hmisc
to escape dollar signs when formatting values from a data frame?
此后,我也无法运行搜索并替换所有美元符号,因为Hmisc
本身会为空单元格添加美元符号.
I can't run search and replace over all dollar signs afterwards either, because the Hmisc
itself adds dollar signs for the empty cells.
最小示例:
> latex("test$test",file="")
# returns:
\begin{table}[!tbp]
% [...]
test$test\tabularnewline
% [...]
\end{table}
# should return:
\begin{table}[!tbp]
% [...]
test\$test\tabularnewline
% [...]
\end{table}
推荐答案
您可以在Hmisc
中查看latexTranslate
函数:
R> latexTranslate("3%")
[1] "3\\%"
这篇关于在Hmisc :: latex中转义LaTeX控件符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!