简体   繁体   中英

tikzDevice not working for basic example

Consider the following example:

library(tikzDevice)
tikz("test.tex")
plot(1:10)
dev.off()

An error will be produced once the plot is created, with a lot of code but near the end the error appears:

("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'

What's going on?

A bit late...

You should have a .tex file with the tikz code of your plot in C:\\Users\\cgmil\\AppData\\Local\\Temp\\Rtmp6FouwP/ . Just replace the last two lines

\makeatletter
\@@end

by

\end{document}
\end{tikzpicture}

Then compile the document. New packages will be installed and it should works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM