yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.39k stars 879 forks source link

Knit .Rmd child documents in standalone mode #1804

Closed maxpel closed 1 year ago

maxpel commented 4 years ago

From one comment to my SO question (https://stackoverflow.com/questions/59931498/knit-child-documents-in-standalone-mode) I learned that this feature, which is mentioned in the documentation (https://yihui.org/knitr/demo/child/) currently only works for Rnw documents.

Therefore, I would like to file a request for the implementation of this feature with Rmarkdown documents. I would consider this low priority, but I guess it is not hard to do and may come in handy in some situations (like, as in my case, writing my thesis with a lot of chapters that I work on separately).


By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

shrektan commented 4 years ago

@yihui I think I can help with this. Changing knitr::set_parent() to take account of the YAML info of the Rmd file would be enough, correct?

UPDATE The rmarkdown YAML matter is more complicated than the Rnw preamble and is handled in the rmarkdown::render(). So if we use knitr::set_parent(), it may only be able to inherit the params values or some specific settings. Or we can add a new slot in the YAML matter parent: xxx.Rmd and then it will be handled in the rmarkdown::render() function instead of in knitr.

shrektan commented 4 years ago

@maxpel After some investigations, I realized that it's rather complicated than I thought. Would you mind give me some hints about what you expect to have from the parent's YAML matters? I think inheriting the param values should be fine, but I'm not sure if that's enough for your cases.

maxpel commented 4 years ago

The best would be if that child just knits as in the parent document but without any of other content in the parent file. I guess having a custom tex template could create problems here (creating a title page for the child for example).

shrektan commented 4 years ago

Thanks. Then it looks like we need to define a new entry in the YAML matter and handle this in the rmarkdown::render(). knitr::set_parent() doesn't seem the right place to go. However, I may be wrong so let's wait for @yihui 's opinion.

yihui commented 4 years ago

I thought for a while and posted an answer to your SO question: https://stackoverflow.com/a/60083597/559676 You probably don't need my support in knitr.

github-actions[bot] commented 7 months ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.