1

I use knitr to compile a document composed of two .Rnw. Please considered the following examples from this answer

main.Rnw

% !Rnw weave = knitr
% !TeX program = pdfLaTeX

\documentclass[final,12pt]{article}

\usepackage[a4paper]{geometry}
% \usepackage{pgfplotstable}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

<<include=FALSE>>=
  opts_chunk$set(concordance=TRUE, fig.width='8', fig.height='4', fig.pos='htb', out.width='\\textwidth')
@

\begin{document}
<<child-demo, child='include.Rnw', eval=TRUE>>=
@
\end{document}

and include.Rnw

% !TeX root = main.Rnw
% !Rnw weave = knitr
% !TeX program = pdfLaTeX

Let's plot the spectrum of $Na$:

<<'na', dev='tikz', fig.cap='Spectrum of $Na$', echo=FALSE>>=
  plot(c(1:10))
@

I have noticed that uncommenting the line \usepackage{pgfplotstable} the pdf produced by the tikzDevice is of size 0.

This is the verbose output of the R console while knitting when loading the pgfplotstable, as you can see there's no error message, still the .pdf file (but not the .tikz) produce is of size 0.

> > options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE)
> .ess_weave(knit, "/my/path/main.Rnw")
Loading required package: knitr


processing file: /my/path/main.Rnw
  |.............                                                    |  20%
  ordinary text without R code

  |..........................                                       |  40%
label: unnamed-chunk-1 (with options) 
List of 1
 $ include: logi FALSE

  |.......................................                          |  60%
  ordinary text without R code

  |....................................................             |  80%
label: child-demo (with options) 
List of 2
 $ child: chr "include.Rnw"
 $ eval : logi TRUE



processing file: /my/path/include.Rnw
  |......................                                           |  33%
  ordinary text without R code

  |...........................................                      |  67%
label: na (with options) 
List of 3
 $ dev    : chr "tikz"
 $ fig.cap: chr "Spectrum of $Na$"
 $ echo   : logi FALSE

Warning: 'mode(width)' and 'mode(height)' differ between new and previous
     ==> NOT changing 'width' & 'height'
Creating new TikZ metrics dictionary in:
    include-tikzDictionary
  |.................................................................| 100%
  ordinary text without R code


  |.................................................................| 100%
  ordinary text without R code


output file: main.tex

[1] "main.tex"

And here the last part (too long to post all) of na.log from generating the picture (in the rest of the document I couldn't find any error):

Package pgfplots Warning: running in backwards compatibility mode (unsuitable t
ick labels; missing features). Consider writing \pgfplotsset{compat=1.9} into y
our preamble.
 on input line 33.


Overfull \hbox (99.38345pt too wide) in paragraph at lines 124--125
[][] 
 []

(./na.aux) ) 
Here is how much of TeX's memory you used:
 20223 strings out of 493311
 479203 string characters out of 6137849
 631627 words of memory out of 5000000
 23277 multiletter control sequences out of 15000+600000
 4702 words of font info for 16 fonts, out of 8000000 for 9000
 957 hyphenation exceptions out of 8191
 65i,7n,84p,700b,609s stack positions out of 5000i,500n,10000p,200000b,80000s

No pages of output.
PDF statistics:
 3 PDF objects out of 1000 (max. 8388607)
 3 compressed objects within 1 object stream
 0 named destinations out of 1000 (max. 500000)
 13 words of extra memory for PDF output out of 10000 (max. 10000000)

Is it possible to use pgfplotstable along with the tikzDevice?

9
  • Looks like this is due to including pgfplotstable after the preview package in na.tikz in figure folder. But, currently, I have no idea how to fix this.
    – m0nhawk
    Nov 8, 2013 at 7:16
  • pgfplotstable a such should be harmless... but it includes pgfplots, which, in turn, includes tikz. Does it make a difference if you include one of tikz or pgfplots instead of pgfplotstable? And: what is the error message? Typically, a result of size 0 means "error" and errors are always indicated by error messages. Nov 9, 2013 at 16:05
  • @ChristianFeuersänger I couldn't find any error message in the R log (I added it to the question). I tried including tikz and pgfplots instead of pgfplotstable: with tikz the pdf of the figure is correctly produced but with pgfplots the figure pdf has still size 0.
    – Francesco
    Nov 9, 2013 at 21:40
  • I did not mean the R log, I meant the log produced by pdflatex. It is probably available as main.log or something like that Nov 10, 2013 at 11:45
  • I do not know the answer yet, but first you need to fix a couple of mistakes in the examples you referenced: tex.stackexchange.com/posts/142355/revisions There should be a figure/na.log file, which you can open and see what is wrong there.
    – Yihui Xie
    Nov 10, 2013 at 22:48

0

You must log in to answer this question.

Browse other questions tagged .