I might have discovered a bug in the RStudio IDE. I'd also love to know a better way to handle what I'm trying to do.
I use the visual editor to insert citations (would be great if I could do this one day without the visual editor, working in source mode). I also want to automatically wrap long lines of code in the PDF output rather than having them fall off the edge of the page, and I use the embedded LaTeX in the Rmd header as shown below to achieve this.
---
title: "My title"
author: "Stephen Turner"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output:
pdf_document:
fig_caption: yes
toc: yes
header-includes:
- |
```{=latex}
\usepackage{fvextra}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{
breaksymbolleft={},
showspaces = false,
showtabs = false,
breaklines,
commandchars=\\\{\}
}
```
---
However, when I do this, I can't use the visual editor ("Unable to activate visual mode (unsupported front matter format or non-top-level YAML block)"). There's nothing actually wrong with the front matter. The PDF compiles just fine.
Is there another way to achieve what I'm trying to do here in a way that doesn't fool the visual editor into thinking something's wrong?