[Tex/LaTex] Left Quotation Marks when using RMarkdown and knitR

knitrmarkdownpandocpunctuationr

Normally when you want left quotation marks in LaTeX, you type the following:

``

However, in RMarkdown, you will trigger a block of R code to run when you type two pairs of backticks on the same line, causing the LaTeX to render incorrectly.

For example,

``Sticks and stones may break my bones,'' he said. ``But words will never hurt me.''

Will be rendered incorrectly in the output document; specifically, the stuff enclosed by the backticks will be printed out by R, and everything after will be rendered properly by LaTeX. Here is a picture:

bad rendering

I then attempted to use backslashes in order to escape the R code, and this got me closer, but now the right quotation marks are now recognized as a pair of single quotes right next to each other:

\`\`Sticks and stones may break my bones,'' he said. \`\`But words will never hurt me.''

closer, but no cigar

How can I properly obtain two left quotation marks on the same line using RMarkdown, without having these render issues?

Best Answer

First of all, you need to be aware of this fact:

Markdown is not LaTeX.

So in general you should not expect LaTeX syntax to work in Markdown documents. The correct way to write quotes in Markdown is to just write quotes literally, i.e., use " ". They will be converted to the correct LaTeX code (i.e., `` '') when Markdown is converted to LaTeX (via Pandoc). The same thing applies to single quotes.

Backticks have a special meaning in Markdown: they are used to write text verbatim. You can use any number of backticks (one, two, three, ...), as long as the backticks come in pairs. In your case, you have a pair of double backticks, which mark the text Sticks and stones may break my bones,'' he said. as verbatim.

I strongly recommend you to read the Pandoc's Markdown syntax at least once before using R Markdown. It will save you a lot of time in the future, and you probably won't have questions about the Markdown basics.