I want to write my thesis in Rmarkdown and am just trying to figure out how to merge multiple .Rmd files into one big file using the example here. It all works fine, but as soon as I add a figure to one of my child files I get an error message. I think it has something to do with the directories but I'm struggling to wrap my head around it. This is what I'm doing:
This is my parent file thesis.Rmd
:
---
output:
pdf_document:
toc: yes
---
```{r child = 'chapter3/chapter3.Rmd'}
```
```{r child = 'chapter4/chapter4.Rmd'}
```
with
---
title: chapter 3
output: pdf_document:
---
```{r child = '3-1-test.Rmd'}
```
3-1-test.Rmd
is just the standard .Rmd file you get when you create a new .Rmd file in Rstudio.
chapter4.Rmd
looks like this:
---
title: chapter 4
output: pdf_document:
---
```{r child = '4-1-test.Rmd'}
```
With 4-1-test.Rmd
---
output:
pdf_document:
fig_caption: yes
---
text text text

Resulting in an error: pandoc.exe: Could not find image `figure.pdf', skipping...
If I remove the figure everything works just fine. How do I run thesis.Rmd
with the figure in 4-1-test.Rmd
without getting an error?
Edit:
As @rawr suggested, I can make all the file path relative to the thesis.Rmd
file. That is a good start. I would also like to know if there is a way to reset the root directory for every child directory (so that within a child directory, the root directory becomes that of the child directory).