考虑以下示例:
library(tikzDevice)
tikz("test.tex")
plot(1:10)
dev.off()
创建绘图后会产生错误,代码很多,但接近结束时出现错误:
("C:\ProgramError in getMetricsFromLatex(TeXMetrics, verbose = verbose) :
TeX was unable to calculate metrics for the following string
or character:
m
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 contents of the LaTeX log of the aborted run have been printed above,
it may contain additional details as to why the metric calculation failed.
In addition: Warning messages:
1: In readLines(texLog) :
incomplete final line found on 'C:\Users\cgmil\AppData\Local\Temp\Rtmp6FouwP/tikzStringWidthCalc.log'
2: In readLines(texLog) :
incomplete final line found on 'C:\Users\cgmil\AppData\Local\Temp\Rtmp6FouwP/tikzStringWidthCalc.log'
发生什么事了?
有点晚了...
您应该有一个 .tex 文件,其中包含
C:\Users\cgmil\AppData\Local\Temp\Rtmp6FouwP/
中绘图的 tikz 代码。只需替换最后两行即可
\makeatletter
\@@end
由
\end{document}
\end{tikzpicture}
然后编译文档。将安装新软件包并且它应该可以工作。
我迟到了 7 年,但也许其他人将来也会遇到这个问题。我是这样修复的:
https://ctan.org/pkg/preview?lang=en下载软件包
preview
tex preview.ins
preview.sty
并将其复制到文件夹C:\texlive\2024\texmf-dist\tex\latex\preview
(您可能需要创建此文件夹texhash