1

I'm using a master-child file approach to structure my rmd project and build it with Bookdown to generated both a Word document and a git_book site. What I want to achieve is some kind parameter-controlled compilation (using the knitr block engine mentioned in this post).

For example, my index.Rmd will have its YAML like this:

params:
  RootTitle: true
  Demand: false
  FeatureDesign: true
  TitleApp: true

Then the child rmd will be structured like this:

```{block eval=FALSE, include=params$RootTitle}
# Research
Some text
```

```{block eval=FALSE, include=params$Demand}
## Customer's demand
Some text
```
```{block eval=FALSE, include=params$FeatureDesign}
# Feature design
## Primary features
Some text

## Secondary features
Some text

```

And i do this for every child rmd files to be included. Then I can switch off a certain part (like the feature design part) of all the child files by simply change FeatureDesign to false in params.

The problem is how will I insert images in these rmd files? I have two choices:

  1. the markdown vanilla way : ![title](image.jpg), but you can't have centered images in git_book site with this approach.

  2. the rmarkdown way, which can have centered images

    ` ``{r, fig.align = 'center', fig.cap = ""}

    knitr::include_graphics("")

    ` ``

The problem is, I now have to nested an r code chunk into the block chunk, with will have mixed backticks and warnings are thrown:

Warning messages: 1: In hook(x[i], reduce_plot_opts(options)) : Chunk options fig.align is not supported for docx output

2: In xfun::prose_index(content) : Code fences are not balanced

3: In xfun::prose_index(content) : Code fences are not balanced

and the result git_book or docx have trailing backticks

here's a minimum example :

Kemcy
  • 11
  • 2

0 Answers0