I have a LaTeX manuscript that inputs from a single Sweave file. The file creates plots and places them in the document using <fig=TRUE>
.
Is there a way that I can tell all of the figures to go to the end of the document, where the rest of the figures are? All of the other figures are placed at the end with the LaTeX option [ht!]
The only solution I have come up with is to use <fig=FALSE>
, save the file as a graphics file, and then call the figure from within LaTeX at the end of the document. Is there a way to do this within the R-code part of the Sweave document itself (presumably this would be easier to do).
Another alternative is to use the LaTeX 'endfloat' package. Add the following to your preamble, and it will put all of the figures at the end.
\usepackage[noheads,nomarkers]{endfloat}
You could also do <chunk_name, fig = TRUE, include = F>
in the chunk where you create the plot and call it at the end using
<new_chunk, fig = TRUE>
<<chunk_name>>
@
The image created with fig=TRUE
will always have the name:
FILENAME-CHUNKNAME.pdf
Where FILENAME is the name of your .Rnw
file without extension, So with this you can easilly make the includegraphics
call yourself:
% Somewhere in source:
<<CHUNKNAME,fig=TRUE,include=FALSE>>=
plot(1)
@
% Later in source:
\begin{figure}
\centering
\includegraphics{FILENAME-CHUNKNAME}
\caption{Whatever}
\label{fig:whatever}
\end{figure}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With