I would like to have a single .tex file, with a main section and an appendix. I would want however to compile it into two distinct pdfs.
There are solutions using \include
, see How to create individual chapter PDFs or Splitting a large document into several files, but this is not using a single .tex
file. The reason I want a single .tex
file is that I am using R Sweave, not showing input code in the main document, but want the input code to be shown in a companion document.
Following LaTeX/Sweave - How to reproduce code blocks in an appendix?, my .tex
file will be:
\documentclass{article}
\begin{document}
Some stuff here to go in first pdf
<<block1,eval=TRUE,echo=FALSE>>=
plot(density(1:10))
@
\appendix
Some stuff here to go in second pdf
<<all-blocks>>=
<<block1>>
@
\end{document}