我正在尝试在R中绘制表格,但它只是以伪格式打印文本,不确定如何解决。
我的代码:
tex2=TeX('
\\begin{table}[]
\\begin{tabular}{|l|l|}
\\hline
a&b \\\\ \\hline
c & d \\\\ \\hline
\\end{tabular}
\\end{table}
')
plot(tex2, cex=1)
tex2等于
\begin{table}[]
\begin{tabular}{|l|l|}
\hline
a&b \\ \hline
c&d \\ \hline
\end{tabular}
\end{table}
根据https://cran.r-project.org/web/packages/latex2exp/vignettes/using-latex2exp.html的建议
要在RStudio查看器窗格中查看LaTeX代码段,并可以将其导出为图像,需要texPreview
程序包。
library(texPreview)
tex <- '
\\begin{table}[]
\\begin{tabular}{|l|l|}
\\hline
a & b \\\\ \\hline
c & d \\\\ \\hline
\\end{tabular}
\\end{table}
'
tex_preview(tex, imgFormat = "svg")
[当我第一次尝试时,它没有用。我收到此错误:
magick_image_readpath(enc2native(path),密度,深度,条):rsession:未经授权的`/tmp/RtmpKZqeBQ/tex_tempDoc.pdf'@ error / constitute.c / ReadImage / 412
我正在使用Ubuntu。我必须对文件/ etc / ImageMagick-6 / policy.xml进行更改;即我替换了行
<policy domain="coder" rights="none" pattern="PDF" />
with
<policy domain="coder" rights="read | write" pattern="PDF" />