I have a parent and child Rnw document. The children's document is located in the children subfolder, i.e.
+-- parent.Rnw +-- children +-- child.Rnw +-- figure +-- test.pdf
Now I want to create the number (margin) test.pdf from inside the child document using the pdf function and put it in the figure folder inside the children folder (i.e. the local figure folder for child.Rnw ).
parent.Rnw
\documentclass{article} \begin{document} I am the parent <<child, child='children/child.Rnw'>>= @ \end{document}
child.Rnw
<<parent, echo=FALSE, cache=FALSE>>= knitr::set_parent("../parent.Rnw") @ I am the child doc. <<>>= pdf("figure/test.pdf") plot(1:10) dev.off() @ \marginpar{ \includegraphics[width=\marginparwidth]{figure/test.pdf} }
When compiling child.Rnw everything works fine. The path to figure/test.pdf correct for the child document, but not when compiling the parent document. Then it should be children/figure/test.pdf .
Question: How can I find the correct path to compile the child AND parent document?
source share