Is there a way to add a MS Word "Comment" via a R markdown file? I'm using a reference_docx, and familiar with adding custom styles...but haven't figured out how to get a comment to show up on the side like this:
To clarify: I want to add a tag (or something?) to my plaintext Rmd file, so that when I "knit" the resulting MS Word doc has a rendered comment.
Actually, this is possible. Yes, Markdown (and RMarkdown) are for plain text writing, but they are translated using pandoc. So I googled this and found the following code, which works well:
---
title: "test"
output:
word_document: default
---
This text contains a [This is the comment]{.comment-start id="0" author="Johannes G." date="2020-01-13T10:12:00Z"}comment.[]{.comment-end id="0"}.
This will create a bit of a mess when knitting to other formats, so you might want to think about using an R
functions instead:
```{r echo=FALSE}
word_comment <- function(comment, highlight = "") {
if (isTRUE(knitr:::pandoc_to() == "docx")) {
paste0('[', comment, ']{.comment-start id="0" author="Johannes G."',
'date="2020-01-13T10:12:00Z"}', highlight, '[]{.comment-end id="0"}')
}
}
```
This text contains a `r word_comment("This is the comment", "comment.")`.
The code can probably be improved but I couldn't find documentation for the chunk that creates the comment so this works well enough for the moment.