0

I am trying to style the word document using the Rmarkdown. I have successfully applied the basic styles by providing the reference word document under the YAML.

However, I am looking at some advanced styling like applying the different font size or colour to the paragraphs/headers in the same document.

Right now if I change the colour of any one paragraph to blue, colour of all the paragraphs get's changed to blue where I wanted to change the colour of only some of the paragraphs.

current rmarkdown:

---
title: "`r params$report_title`"
params:
  report_title: NA
  absolute_application_path: NA
output:
  word_document:
    md_extensions: +styles
    reference_docx: "mmr_tec_report_reference-file.docx"
---

```{r setup, include=FALSE, echo=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(pander)

```

```{r echo = FALSE}
application_path = params$absolute_application_path
signature_note <- ""
summary_note <- ""
```

## Template Instructions:

::: {custom-style="MMR_BodyText"}

The blue text are instructions or guidance for preparing the Sample or examples.  Delete the blue highlighted instructions as the document is being drafted.  
:::

Am I doing anything wrong up there?

I would like to know if there is any way to get it worked?

Abhinandan Satpute
  • 2,558
  • 6
  • 25
  • 43
  • 1
    sounds like you want http://pandoc.org/MANUAL.html#custom-styles – mb21 Feb 13 '19 at 08:34
  • Thanks @mb21. I will try it out. I think this will be useful. – Abhinandan Satpute Feb 13 '19 at 09:01
  • @mb21 I tried using this but I couldn't able to successfully integrate and use it. Do you know how to add extensions to rmarkdown? I tried using the md_extensions but no luck. – Abhinandan Satpute Feb 20 '19 at 15:41
  • The `styles` extension should be enabled by default on the markdown reader, and the docx writer doesn't need it. – mb21 Feb 20 '19 at 16:01
  • @mb21I don't think so. The pandoc documentation http://pandoc.org/MANUAL.html#other-extensions says it's disabled by default and I am not able to find how to enable it. – Abhinandan Satpute Feb 20 '19 at 16:03
  • Ah yes, correction: neither the markdown reader nor the docx writer use the extension. It's only the docx reader (which you would only use when converting _from_ docx – that's why it says _input formats_) that makes use of that extension, and yes in that case it's disabled by default. – mb21 Feb 20 '19 at 16:29
  • @mb21 No problem. Please let me know if you come across anything which will help me format the output word document. – Abhinandan Satpute Feb 20 '19 at 16:38
  • I tried using the `variant` as mentioned here. https://stackoverflow.com/questions/32492145/how-can-i-specify-pandocs-markdown-extensions-using-a-yaml-block but it also didn't help me. – Abhinandan Satpute Feb 20 '19 at 16:40
  • There's something wrong with you markdown text, not the enabled extensions. Also make sure you use a recent pandoc version... – mb21 Feb 20 '19 at 16:46

0 Answers0