When knitting to word, unwanted brackets are placed around section headers

When knitting to word I get unwanted brackets around section headers. In the image below I used R Studio wizard to create standard R Markdown file with default output options to word. Here is the default code I used:

Too see if this was an issue with word styles, I tried messing around with a docx template for styling and this did not seem to be the result of a style. I know this because when I cleared all styles in word the brackets are still there.

Here is a picture of the unwanted output I'm getting:

Here is the standard code I used to create the document:

---
title: "Untitled"
author: "Max Carey"
date: "4/21/2019"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)

Including Plots

You can also embed plots, for example:

plot(pressure)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

1 Like

The brackets around the section headers in your document are due to a setting in Microsoft Word. The following steps will solve your issue.

  1. Click on File (in the menu)
  2. Options
  3. Advanced
  4. Scroll down to the "Show document content" section
  5. Deselect "Show bookmarks"

Hope this helps.

4 Likes

Great thanks for pointing out the problem with this, weird I don't remember enabling these settings.

Also in Word for Mac it's a little different:

Click on Word -> Preferences -> View

Then deselect bookmarks. Also those pesky little dots that you can see in there are removed by deselecting "Paragraph Marks". I

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.