Nicholas Pfau
Nicholas Pfau

Reputation: 11

Why does text turn grey when editing a document in R Markdown?

On occasion, starting paragraphs with excess spaces in R Markdown/RStudio changes the text color from the color I expect to grey. This behavior isn't consistent, and it doesn't affect the output in any appreciable way. Does anyone know what's happening?

On my machine the second **Response** is grey, and all others are blue.

---
title: "Untitled"
author: "Unnamed"
date: "6/1/2018"
output: pdf_document
---

**Response**

      **Response**

**Response**
      **Response**

enter image description here

enter image description here

As far as I can tell, everything about the conditions in the two examples is the same.

Upvotes: 1

Views: 1798

Answers (1)

Ralf Stubner
Ralf Stubner

Reputation: 26833

If you process your document you will see something like this:

enter image description here

The empty line plus before the second "Response" together with the indentation makes markdown interpret this as code. In RStudio code sections are shown with a grey font. In the PDF output, a fixed width font is used and the ** are treated literally instead of interpreted as commands for bold.

Since there is no empty line between the third and the forth "Response", these are treated as one paragraph, making the indentation irrelevant.

Solution: Do not indent text but only code.

Upvotes: 1

Related Questions