Search code examples
rmarkdownr-markdowntufte

code chunks float into margin area with tufte markdown r


I have a problem with the tufte markdown style...

Some of my code chunks are not formatted properly. The newline is not recognised and text is floating (is this the correct word?) into the side area where the comments and images are.

Example:

---
title: "test"
author: "user"
date: "Now"
output:
  tufte::tufte_handout: 
    number_sections: yes
    toc: yes
    toc_depth: 1
---

Some test lines

```{r, eval=FALSE}
re_quantify_setting <- 
  parameters[,'Value'][parameters[,'Parameter'] == 'Re-quantify']
if(re_quantify_setting != 'False') {
  stop('Re-quantify was set to \'True\'! ',    
       'Please reanalyse data with correct MaxQuant settings.')
}
```

```{marginfigure}
Also a common problem is that people often just mark all lines of code and then 
just executing (Run) it. Here it might happen that an error occured at the beginning
of the script but was not seen by the user because code is executing so fast.  
This can be prevent by using the **Source**-button. The script will stop in case 
of an error message!
```

And here the result:

pdf output

Has anyone an idea why this happens and how to get the correct line breaks?


Solution

  • You could disable tidying:

    ```{r, echo=FALSE}
    knitr::opts_chunk$set(tidy=FALSE)
    ```