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:<br>
<br>cat("\\documentclass{article}<br>\\usepackage{tikz}<br>\begin{document}<br>\\begin{figure}[ht]<br>\\centering<br>", file = "myfile.tex")<br>tikz("myfile.tex", width=5, height=5, append = TRUE)<br>
x <- rnorm(100)<br>plot(x)<br>dev.off()<br>cat("\\caption{caption}<br>\\label{fig:inline}<br>\\end{figure}<br>\\end{document}<br>", file = "myfile.tex", append = TRUE)<br><br>On Sun, Dec 6, 2009 at 11:34 AM, Cameron Bracken <span dir="ltr"><<a href="mailto:cameron.bracken@gmail.com">cameron.bracken@gmail.com</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Interesting Idea. This should work with plain Sweave. It is not very<br>
efficient and would be very slow for large files since it must write<br>
out then read in then write out.<br>
<br>
\documentclass{article}<br>
\usepackage{tikz}<br>
\usepackage[nogin]{Sweave}<br>
\begin{document}<br>
\begin{figure}[ht]<br>
\centering<br>
<<inline,echo=F,results=tex>>=<br>
<br>
require(tikzDevice)<br>
tf <- tempfile()<br>
tikz(tf,width=5,height=5)<br>
x <- rnorm(100)<br>
plot(x)<br>
#Suppress "null device 1" from being printed<br>
dummy <- dev.off()<br>
cat(readLines(tf),sep='\n')<br>
<br>
@<br>
\caption{caption}<br>
\label{fig:inline}<br>
\end{figure}<br>
\end{document}<br>
<font color="#888888"><br>
<br>
-Cameron<br>
</font><div><div></div><div class="h5"><br>
<br>
<br>
On Sun, Dec 6, 2009 at 9:02 AM, Gabor Grothendieck<br>
<<a href="mailto:ggrothendieck@gmail.com">ggrothendieck@gmail.com</a>> wrote:<br>
> I would like to create a single file that has my latex and tikzDevice output<br>
> as opposed to outputting the tikZ output into a separate file and using<br>
> \input . The latex would be generated using cat statements in R.<br>
><br>
> Can that be done? If so, can you provide a small example.<br>
><br>
><br>
</div></div></blockquote></div><br>