如何解决R 包 tikzDevice 不生成用于插入 LaTeX 的 .tex 文件
我曾经使用 R 中的 tikzDevice 生成一个 .tex 文件,以便将其插入到 LaTeX 文档中。直到两天前,我的代码运行良好,生成的 .tex 文件没有任何错误。 这是我的代码的 MWE:
library(readxl)
library(tidyverse)
library(tufte)
library(dplyr)
library(ggplot2)
library(viridis)
library(tikzDevice)
library(stringr)
library(scales)
test <- data.frame(Company,Var1,Var2,Year)
tikz(file = "C:/Users/**/Desktop/test.tex",width = 14,height = 10,pointsize=1,sanitize=TRUE
)
Test <- ggplot(test,aes(x = factor(test$Year,level=c('2020','2021')),y = test$Var1,size = test$Var2,fill = str_wrap(test$Company,1))) +
theme_bw() +
geom_point(shape=21,alpha = 0.5)
Test <- Test + scale_x_discrete(label=c("2020","2021"))
Test
dev.off()
然而,这两天以来,我收到以下错误消息并且 .tex 文件为空:
Measuring dimensions of: \char77
Running command: "C:\PROGRA~1\MiKTeX\miktex\bin\x64\pdflatex.exe" -interaction=batchmode -halt-on-error -output-directory "C:\Users\wdschrei\AppData\Local\Temp\Rtmp0U1bX8\tikzDevice5f4e57ad9" "tikzStringWidthCalc.tex"
Fehler in getMetricsFromLatex(TeXMetrics,verbose = verbose) :
TeX was unable to calculate metrics for:
\char77
Run the following commands for diagnosis:
tikztest()
tikzTest("\\char77")
Common reasons for failure include:
* The string contains a character which is special to LaTeX unless
escaped properly,such as % or $.
* The string makes use of LaTeX commands provided by a package and
the tikzDevice was not told to load the package.
The TeX and log files used for the calculation can help diagnose the
problem. If these files are missing,rerun the plot and make sure to
keep the R session open.
TeX file: tikzStringWidthCalc.tex
Log file: tikzStringWidthCalc.log
Zusätzlich: Warnmeldungen:
1: Use of `test$Year` is discouraged. Use `Year` instead.
2: Use of `test$Var1` is discouraged. Use `Var1` instead.
3: Use of `test$Var2` is discouraged. Use `Var2` instead.
4: Use of `test$Company` is discouraged. Use `Company` instead.
>
> dev.off()
RStudioGD
2
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。