[Tikzdevice-bugs] Single file with tikzDevice

Gabor Grothendieck ggrothendieck at gmail.com
Sun Dec 6 17:46:09 CET 2009


If you able to provide this feature (i.e. incorporate the tikz tex directly
into the current file rather than writing out a temporary file and reading
it back in) then that would be useful since one of the key potential
advantages of tikz and pgf are the ability to have a single file rather than
multiple files.  Perhaps an append=TRUE argument like this:

cat("\\documentclass{article}
\\usepackage{tikz}
\begin{document}
\\begin{figure}[ht]
\\centering
", file = "myfile.tex")
tikz("myfile.tex", width=5, height=5, append = TRUE)
x <- rnorm(100)
plot(x)
dev.off()
cat("\\caption{caption}
\\label{fig:inline}
\\end{figure}
\\end{document}
", file = "myfile.tex", append = TRUE)

On Sun, Dec 6, 2009 at 11:34 AM, Cameron Bracken
<cameron.bracken at gmail.com>wrote:

> Interesting Idea.  This should work with plain Sweave.  It is not very
> efficient and would be very slow for large files since it must write
> out then read in then write out.
>
> \documentclass{article}
> \usepackage{tikz}
> \usepackage[nogin]{Sweave}
> \begin{document}
> \begin{figure}[ht]
> \centering
> <<inline,echo=F,results=tex>>=
>
>  require(tikzDevice)
>  tf <- tempfile()
>  tikz(tf,width=5,height=5)
>    x <- rnorm(100)
>    plot(x)
>  #Suppress "null device 1" from being printed
>  dummy <- dev.off()
>  cat(readLines(tf),sep='\n')
>
> @
> \caption{caption}
> \label{fig:inline}
> \end{figure}
> \end{document}
>
>
> -Cameron
>
>
>
> On Sun, Dec 6, 2009 at 9:02 AM, Gabor Grothendieck
> <ggrothendieck at gmail.com> wrote:
> > I would like to create a single file that has my latex and tikzDevice
> output
> > as opposed to outputting the tikZ output into a separate file and using
> > \input .  The latex would be generated using cat statements in R.
> >
> > Can that be done?  If so, can you provide a small example.
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.r-forge.r-project.org/pipermail/tikzdevice-bugs/attachments/20091206/1c605ab8/attachment.htm 


More information about the Tikzdevice-bugs mailing list