2

None of the inside-chunk Quarto codes (#|) are working properly. I have a document with the following header.

title: "Title"
subtitle: "Subtitle"
author: 
  - "Author 1"
  - "Author 2"
date: "November 8, 2022"
date-format: long
format:
  html: 
    code-fold: true
    html-math-method: katex
  pdf:
    cap-location: top
    fig-cap-location: top
    tab-cap-location: top
    papersize: "a4paper"
    geometry: 
      - top=20mm
      - left=25mm
    include-in-header:
      text: |
        \addtokomafont{disposition}{\rmfamily}
  docx: default
```
With several code chunks inside it. 

```{r}

#| label: #fig-atrip-hist
#| echo: false
#| error: false

#| fig-cap: "atrip Histogram and Density Plot"
#| fig-width: 2
#| fig-height: 3
    
  
ggplot(data=df.scaled, aes(atrip))+
              geom_histogram(aes(y = ..density..))+
              geom_density(color = "dark grey", linetype="dashed", fill = "#89f0f4", alpha = 0.6)+
              theme_custom()

```

When I render the document to PDF, all codes are printed. To avoid that, I have to put the code inside the brackets, as if the document was a RMD.

{r echo=FALSE, message=FALSE, warning=FALSE}

In addition, the Figure captions are not printed in Quarto. They are only printed if I put the caption inside the brackets.

{r fig-cap: "atrip Histogram and Density Plot", echo=FALSE, message=FALSE, warning=FALSE}

My document is saved as a Quarto documento. I created it as a Quarto document. It has a .qmd extension. But it behaves as a RMD document.

shafee
  • 15,566
  • 3
  • 19
  • 47
FPM
  • 21
  • 1
  • 1
    You have to start using `#|` immediately after the chunk header `{r}`, otherwise it will not work. Since you have a blank line after the chunk header that's why it isn't working. Also, you are writing `fig-cap:` which is again the wrong syntax, AFAIK. instead try with `#| fig-cap:` in the chunk body. – shafee Nov 08 '22 at 14:56

0 Answers0