Learn R Programming

knitr (version 1.48)

set_parent: Specify the parent document of child documents

Description

This function extracts the LaTeX preamble of the parent document to use for the child document, so that the child document can be compiled as an individual document.

Usage

set_parent(parent)

Value

The preamble is extracted and stored to be used later when the complete output is written.

Arguments

parent

Path to the parent document, relative to the current child document.

Details

When the preamble of the parent document also contains code chunks and inline R code, they will be evaluated as if they were in this child document. For examples, when knitr hooks or other options are set in the preamble of the parent document, it will apply to the child document as well.

References

https://yihui.org/knitr/demo/child/

Examples

Run this code
## can use, e.g. \Sexpr{set_parent('parent_doc.Rnw')} or

# <>=

# set_parent('parent_doc.Rnw')

# @

Run the code above in your browser using DataLab