An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121202/2579ac2a/attachment.pl>
Problem with figures
7 messages · Duncan Murdoch, Shige Song, Yihui Xie
On 12-12-02 5:42 PM, Shige Song wrote:
I am having problem making ggplot2, tikzDevice, and knitr working together. I used a very simple example:
I don't use knitr so I can't really help, but you didn't tell us how you passed this file to knitr, so maybe nobody can. However, if you were using Sweave, you would need to mention that the code chunk produces a figure (using "fig=TRUE" in the <<>>= header). Duncan Murdoch
---------------------------example.Rnw-----------------------------
\documentclass[preview]{standalone}
\begin{document}
\begin{figure}
<<fig1,eval=TRUE,echo=FALSE,dev='tikz'>>=
library(ggplot2)
qplot(displ, hwy, data = mpg, colour = factor(cyl))
@
\end{figure}
\end{document}
---------------------------------------------------------------------------------
I got "... ! ==> Fatal error occurred, no output PDF file produced!
label: fig1 (with options)
List of 3
$ eval: logi TRUE
$ echo: logi FALSE
$ dev : chr "tikz"
Error in process_file(text, output) :
Quitting from lines 6-8: (test_Rnw.Rnw) Error in
getMetricsFromLatex(TeXMetrics) :
TeX was unable to calculate metrics for the following string
or character:
hwy
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.
Calls: knit -> process_file
Execution halted"
Best,
Shige
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121202/248ba9e0/attachment.pl>
fig=TRUE is irrelevant here, and knitr does not need fig=TRUE at all
(plots are automatically recorded).
The real problem is the [preview] option; remove it and you are all set.
Next time if you have problems with tikzDevice, you can take a look at
the LaTeX log to know what exactly is wrong, e.g. in this case you
will see
! LaTeX Error: Option clash for package preview.
The log file is at figure/fig1.log by default in your case.
Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Sun, Dec 2, 2012 at 5:36 PM, Shige Song <shigesong at gmail.com> wrote:
Easiest way: copy and paste the code into Rstudio and hit "compile pdf".
From the command line, I believe you can do "knit2pdf example.Rnw".
Shige On Sun, Dec 2, 2012 at 6:12 PM, Duncan Murdoch <murdoch.duncan at gmail.com>wrote:
On 12-12-02 5:42 PM, Shige Song wrote:
I am having problem making ggplot2, tikzDevice, and knitr working together. I used a very simple example:
I don't use knitr so I can't really help, but you didn't tell us how you passed this file to knitr, so maybe nobody can. However, if you were using Sweave, you would need to mention that the code chunk produces a figure (using "fig=TRUE" in the <<>>= header). Duncan Murdoch ---------------------------**example.Rnw-------------------**----------
\documentclass[preview]{**standalone}
\begin{document}
\begin{figure}
<<fig1,eval=TRUE,echo=FALSE,**dev='tikz'>>=
library(ggplot2)
qplot(displ, hwy, data = mpg, colour = factor(cyl))
@
\end{figure}
\end{document}
------------------------------**------------------------------**
---------------------
I got "... ! ==> Fatal error occurred, no output PDF file produced!
label: fig1 (with options)
List of 3
$ eval: logi TRUE
$ echo: logi FALSE
$ dev : chr "tikz"
Error in process_file(text, output) :
Quitting from lines 6-8: (test_Rnw.Rnw) Error in
getMetricsFromLatex(**TeXMetrics) :
TeX was unable to calculate metrics for the following string
or character:
hwy
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.
Calls: knit -> process_file
Execution halted"
Best,
Shige
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121203/8d0068f9/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121203/ed262106/attachment.pl>
I'm using the latest version of TeXLive under Ubuntu (http://packages.ubuntu.com/quantal/tex/texlive) so I did not realize the version of standalone can be a problem. My version is also 1.1a, but I do not have any problems if I remove the preview option from your example. Sounds like there is a subtle difference somewhere between your Debian TeXLive and my Ubuntu TeXLive... Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA
On Mon, Dec 3, 2012 at 9:29 AM, Shige Song <shigesong at gmail.com> wrote:
All right. I did some more digging. It turns out that the real problem is
that the version of the "standalone" LaTeX package installed on my Debian
system is 1.1a. The easiest fix is to replace the three files
"standalone.cfg", "standalone.cls", and "standalone.sty" with the most
recent version from CTAN, which is 1.1b. Now I use
"\documentclass[preview]{standalone}" in my Rnw file to get the desired
results.